#! /bin/sh # Author: Renato Krause ### BEGIN INIT INFO # Provides: mrtg # Required-Start: $network # Required-Stop: $network # Default-Start: 2 # Default-Stop: 0 1 6 # Description: MRTG (MULTI ROUTER TRAFFIC GRAPHER) ### END INIT INFO DESC="MRTG (MULTI ROUTER TRAFFIC GRAPHER)" NAME=mrtg DAEMON=/usr/bin/$NAME CFG=/etc/mrtg/ [ -x "$DAEMON" ] || exit 0 do_start() { echo -n " * Starting $DESC... " if [ ! -d /var/lock/mrtg ]; then sudo mkdir /var/lock/mrtg fi for dir in `ls $CFG`; do for cfg in `ls $CFG$dir/*.cfg`; do env LANG=C $DAEMON $cfg > /dev/null done done echo -n "[ OK ]\n" return 0 } do_stop() { echo -n " * Stopping $DESC... " for dir in `ls $CFG`; do for dotpid in `ls $CFG$dir/*.pid 2> /dev/null`; do kill -9 `cat $dotpid` &> /dev/null rm -f $dotpid done done if [ "$dotpid" = "" ]; then echo -n "[ ERRO ]\n" else echo -n "[ OK ]\n" fi return 0 } case "$1" in start) do_start ;; stop) do_stop ;; restart) do_stop do_start ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2 exit 3 ;; esac :