dotfiles/termux/services/syncthing

60 lines
962 B
Plaintext
Raw Normal View History

2017-09-17 13:36:17 +02:00
#!/data/data/com.termux/files/usr/bin/bash
#
# Start Syncthing synchronization service
#
PIDFILE="$HOME/.local/run/syncthing.pid"
LOGFILE="$HOME/.local/log/syncthing.log"
start() {
printf "Starting Syncthing: "
2018-05-19 13:48:47 +02:00
sudo start-stop-daemon -p "$PIDFILE" -x syncthing -S -b -N 5 -m -- -logfile="$LOGFILE" -home ~/.config/syncthing
2017-09-17 13:36:17 +02:00
echo "OK"
}
stop() {
printf "Stopping Syncthing: "
sudo start-stop-daemon -p "$PIDFILE" -x syncthing -K
echo "OK"
}
status() {
printf "Syncthing: "
2017-09-17 13:57:44 +02:00
PID="$(sudo cat "$PIDFILE" 2> /dev/null)"
2017-09-17 13:36:17 +02:00
if [[ -n "$PID" && -d "/proc/$PID" ]]
then
echo "running"
else
echo "stopped"
fi
}
log() {
sudo tail "$@" "$LOGFILE"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
status)
status
;;
log)
shift
log "$@"
;;
*)
echo "Usage: $0 {start|stop|restart|status|log}"
exit 1
esac
exit $?