#!/bin/sh

DAEMON=tinyfeedback
DAEMON_OPTS=
NAME=tinyfeedback
DECS=tinyfeedback

# Make sure the daemon is executable
test -x $DAEMON || exit 0

set -e

case $1 in
    start)
        echo "Starting $NAME... "
        start-stop-daemon --start --pidfile /var/run/$NAME.pid --make-pidfile \
            --background --startas $DAEMON -- $DAEMON_OPTS
        echo "done!"
        ;;
    stop)
        echo "Stopping $NAME... "
        start-stop-daemon --stop --pidfile /var/run/$NAME.pid
        echo "done!"
        ;;
    restart)
        echo "Restarting $NAME... "
        start-stop-daemon --stop --pidfile /var/run/$NAME.pid
        sleep 1
        start-stop-daemon --start --pidfile /var/run/$NAME.pid --make-pidfile \
            --background --startas $DAEMON -- $DAEMON_OPTS
        echo "done!"
        ;;
    *)
        echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2
        exit 1
        ;;
esac

exit 0
