Add doc to create & start XDS AGL docker container.
[src/xds/xds-server.git] / scripts / get-syncthing.sh
index 284c58e..54ca7e1 100755 (executable)
@@ -1,8 +1,11 @@
 #!/bin/bash
 
 # Configurable variables
-[ -z "$SYNCTHING_VERSION" ] && SYNCTHING_VERSION=0.14.25
-[ -z "$SYNCTHING_INOTIFY_VERSION" ] && SYNCTHING_INOTIFY_VERSION=0.8.5
+[ -z "$SYNCTHING_VERSION" ] && SYNCTHING_VERSION=0.14.28
+
+# FIXME: temporary HACK while waiting merge of #165
+#[ -z "$SYNCTHING_INOTIFY_VERSION" ] && SYNCTHING_INOTIFY_VERSION=0.8.5
+[ -z "$SYNCTHING_INOTIFY_VERSION" ] && { SYNCTHING_INOTIFY_VERSION=master; SYNCTHING_INOTIFY_CMID=af6fbf9d63f95a0; }
 [ -z "$DESTDIR" ] && DESTDIR=/usr/local/bin
 [ -z "$TMPDIR" ] && TMPDIR=/tmp
 
@@ -28,13 +31,28 @@ tarball="syncthing-linux-amd64-v${SYNCTHING_VERSION}.tar.gz" \
        && grep -E " ${tarball}\$" sha1sum.txt.asc | sha1sum -c - \
        && rm sha1sum.txt.asc \
        && tar -xvf "$tarball" --strip-components=1 "$(basename "$tarball" .tar.gz)"/syncthing \
-       && mv syncthing ${DESTDIR}/syncthing
-
+       && mv syncthing ${DESTDIR}/syncthing || exit 1
 
 echo "Get Syncthing-inotify..."
+if [ "$SYNCTHING_INOTIFY_VERSION" = "master" ]; then
+    mkdir -p ${TEMPDIR}/syncthing-inotify-build/src/github.com/syncthing || exit 1
+    cd ${TEMPDIR}/syncthing-inotify-build/src/github.com/syncthing
+    git clone https://github.com/syncthing/syncthing || exit 1
+    git clone https://github.com/syncthing/syncthing-inotify || exit 1
+    cd syncthing-inotify
+    if [ "$SYNCTHING_INOTIFY_CMID" != "" ]; then
+        git checkout -q $SYNCTHING_INOTIFY_CMID || exit 1
+    fi
+    git status
+    export GOPATH=$(realpath `pwd`/../../../..)
+    version=$(git describe --tags --always | sed 's/^v//')__patch_165
+    go build -v -i -ldflags "-w -X main.Version=$version" -o ${DESTDIR}/syncthing-inotify || exit 1
+else
+
 tarball="syncthing-inotify-linux-amd64-v${SYNCTHING_INOTIFY_VERSION}.tar.gz" \
     && curl -sfSL "https://github.com/syncthing/syncthing-inotify/releases/download/v${SYNCTHING_INOTIFY_VERSION}/${tarball}" -O \
     && tar -xvf "${tarball}" syncthing-inotify \
        && mv syncthing-inotify ${DESTDIR}/syncthing-inotify
+fi
 
 echo "DONE: syncthing and syncthing-inotify successfuly installed in ${DESTDIR}"
\ No newline at end of file