Fix startup command and simplify.

This commit is contained in:
redxef 2023-04-14 03:30:45 +02:00
parent fd0fedd695
commit 256663c4f0
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921

View file

@ -1,19 +1,27 @@
#!/bin/sh #!/bin/sh
if [ "$SETSID" != '1' ]; then set -ex
SETSID=1 setsid "$0" "$@" &
exit 0
fi
if pgrep syncthing; then log_s() {
exit 0 echo "$@" >&2
fi }
: "${HOME:=/}"
SYNCTHING_HOME=/mnt/onboard/.adds/syncthing SYNCTHING_HOME=/mnt/onboard/.adds/syncthing
# add 127.0.0.1 to loopback device # add 127.0.0.1 to loopback device
ip addr add 127.0.0.1/32 dev lo || true ip addr add 127.0.0.1/32 dev lo || true
/usr/local/syncthing/syncthing serve --no-browser --no-restart --logflags=0 \ # don't start if its already running
--no-default-folder --home="$SYNCTHING_HOME" if pgrep syncthing; then
exit $? 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