#!/bin/sh
#
# Start or stop the bat alarm Daemon.
#
# Written by Francois TOURDE <fr-om@tourde.org>
#


[ -f /etc/default/batalarm ] && . /etc/default/batalarm

case "$1" in
    start)
        echo -n "Starting batalarm daemon: "
        start-stop-daemon -S -p /var/run/batalarm.pid -m -x /usr/bin/batalarm &
        if [ $? = 0 ]; then
            echo "batalarm."
        else
            echo "(failed.)"
        fi
        ;;
    stop)
        echo -n "Stopping batalarm daemon: "
        start-stop-daemon -K -p /var/run/batalarm.pid &
        echo "batalarm."
        ;;
    restart|force-reload)
        $0 stop
        $0 start
        exit
        ;;
    *)
        echo "Usage: /etc/init.d/batalarm {start|stop|restart|force-reload}"
        exit 1
        ;;
esac

exit 0
