#! /bin/sh
### BEGIN INIT INFO
# Provides:          arpwatch_sendmail
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: arpwatch_sendmail
# Description:       Report mail d'arpwatch
### END INIT INFO

NAME=arpwatch_sendmail
PIDF=/var/run/$NAME.pid
BIN_PATH=/usr/scripts/surveillance/arpwatch
PATH=/sbin:/bin:/usr/sbin:/usr/bin
ARGS=root@crans.org
BIN="$BIN_PATH/sendmail_server.py"
DESCR="Script d'envoi de mails arpwatch"

. /lib/lsb/init-functions

set -e

case "$1" in
  start)
	echo -n "Démarrage de $NAME"
	/sbin/start-stop-daemon --start --quiet --pidfile $PIDF --exec $BIN $ARGS
    echo "."
	;;
  stop)
        echo -n "Arrêt de $NAME"
	/sbin/start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDF
        echo "."
	;;

  restart)
        echo -n "Redémarrage (arrêt) de $NAME"
	/sbin/start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDF
        /bin/sleep 1
	echo -n "Redémarrage (démarrage) de $NAME"
	/sbin/start-stop-daemon --start --quiet --pidfile $PIDF --exec $BIN $ARGS
        echo "."
	;;

  *)
	echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
	exit 1
esac
 
exit 0
