From 256663c4f05692b68fbda8b18f5d62fe59022101 Mon Sep 17 00:00:00 2001 From: redxef Date: Fri, 14 Apr 2023 03:30:45 +0200 Subject: [PATCH] Fix startup command and simplify. --- src/usr/local/syncthing/start.sh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) 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