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
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