. /lib/lsb/init-functions
ADDR=::1
PORT=80
FLAGS=
DIR=/var/lib/podsync
if test -r /etc/default/podsync; then
. /etc/default/podsync
fi
binary=/usr/local/bin/podsync
log=/var/log/podsync/podsync.log
status(){
status_of_proc "podsync" "podsync service" && exit 0 || exit $?
}
emit_log(){
echo "$(date '+%Y-%m-%d %H:%M:%S'): $0: $*" >>"$log"
}
start(){
emit_log "starting"
RUST_LOG=podsync=info \
start-stop-daemon --exec "$binary" --start --chuid www-data:www-data \
--background --output "$log" \
--chdir "$DIR" \
-- \
--address "$ADDR" --port "$PORT" $FLAGS
}
stop(){
start-stop-daemon --exec "$binary" --stop --user www-data
emit_log "stopped"
}
setup(){
mkdir -p "$DIR"
chown www-data:www-data "$DIR"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
echo "$0: stopping..."
stop
echo "$0: starting..."
start
;;
status)
status
;;
setup)
setup
;;
*)
usage
;;
esac