Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (38 sloc) 1.15 KB
#!/bin/sh
# Derived from https://gist.github.com/sodik82/4f4aafdb52e84102b75d
set -e
. /lib/lsb/init-functions
# Must be a valid filename
NAME=foo
PIDFILE=/run/$NAME.pid
# Full path to executable
DAEMON=/usr/local/bin/bar
# Options
DAEMON_OPTS="--baz=quux"
# User to run the command as
USER=www
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
echo -n "Starting daemon: "$NAME
start-stop-daemon --start --quiet -b -m --pidfile $PIDFILE --chdir $WORK_DIR --chuid $USER --exec $DAEMON -- $DAEMON_OPTS
echo "."
;;
stop)
echo -n "Stopping daemon: "$NAME
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
echo "."
;;
restart)
echo -n "Restarting daemon: "$NAME
start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE
start-stop-daemon --start --quiet -b -m --pidfile $PIDFILE --chdir $WORK_DIR --chuid $USER --exec $DAEMON -- $DAEMON_OPTS
echo "."
;;
status)
status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
;;
*)
echo "Usage: "$1" {start|stop|restart}"
exit 1
esac