diff --git a/src/usr/local/syncthing/start.sh b/src/usr/local/syncthing/start.sh index 6f97b97..85602da 100755 --- a/src/usr/local/syncthing/start.sh +++ b/src/usr/local/syncthing/start.sh @@ -1,19 +1,27 @@ #!/bin/sh -if [ "$SETSID" != '1' ]; then - SETSID=1 setsid "$0" "$@" & - exit 0 -fi +set -ex -if pgrep syncthing; then - exit 0 -fi +log_s() { + echo "$@" >&2 +} +: "${HOME:=/}" SYNCTHING_HOME=/mnt/onboard/.adds/syncthing # add 127.0.0.1 to loopback device ip addr add 127.0.0.1/32 dev lo || true -/usr/local/syncthing/syncthing serve --no-browser --no-restart --logflags=0 \ - --no-default-folder --home="$SYNCTHING_HOME" -exit $? +# don't start if its already running +if pgrep syncthing; then + log_s Syncthing is already running, exiting + exit 0 +fi +log_s Syncthing home is "SYNCTHING_HOME" +log_s Starting Syncthing +HOME="$HOME" setsid sh -c "/usr/local/syncthing/syncthing serve --no-browser --no-restart --logflags=0 \ + --no-default-folder --home='$SYNCTHING_HOME'" + +code=$? +log_s Syncthing exited with code $code +exit $code