#! /bin/sh -e

NAME=restarter

# Check for daemon presence
test -x /usr/bin/${NAME} || exit 0

. /lib/lsb/init-functions

# Include defaults if available
OPTIONS=""
if [ -f /etc/default/${NAME} ] ; then
	. /etc/default/${NAME}
fi

case "$1" in
  start)
    log_begin_msg "Starting ${NAME}..."
    start-stop-daemon -v --start -b --quiet --pidfile /var/run/${NAME} --exec /usr/bin/${NAME} -- ${OPTIONS}
    log_end_msg $?
    ;;
  stop)
    log_begin_msg "Stopping ${NAME}..."
    start-stop-daemon --stop --quiet --pidfile /var/run/${NAME} --oknodo --retry 2 --exec /usr/bin/${NAME}
    log_end_msg $?
    ;;
  *)
    log_success_msg "Usage: /etc/init.d/${NAME} {start|stop}"
    exit 1
esac

exit 0

