#!/bin/sh -e

### BEGIN INIT INFO
# Provides:          frontol-mu-scanner
# Required-Start:    $remote_fs $syslog $local_fs $network
# Required-Stop:     $remote_fs $syslog $local_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Frontol Mark Unit Scanner
# Description:       No description
### END INIT INFO

. /lib/lsb/init-functions

start() {
    start-stop-daemon --start --quiet --chuid root:root --background --make-pidfile --pidfile /var/run/frontol-mu-scanner.pid --chdir / --startas /bin/sh -- -c "exec /usr/bin/frontol-mu-scanner" || true
}

stop() {
    start-stop-daemon --stop --pidfile /var/run/frontol-mu-scanner.pid || true
    rm -f /var/run/frontol-mu-scanner.pid
}

status() {
    status_of_proc -p /var/run/frontol-mu-scanner.pid "" frontol-mu-scanner && exit 0 || exit $?
}

case "$1" in
    start)
        start
    ;;
    stop)
        stop
    ;;
    restart|force-reload)
        stop
        start
    ;;
    status)
        status
    ;;
    *)
        echo "invalid usage" >&2
        exit 1
    ;;
esac

exit 0
