[mrtg] Re: UNIX/Linux startup script, anyone??
Michael Marziani
michaelm at kw.com
Thu Mar 14 01:12:32 MET 2002
I figured I'd write one. I took a "skeleton" script that was in my
/etc/init directory and did a good bit of modifying. The fact that MRTG
creates it's own PID file is nice, but it will depend on where you
install MRTG where the PID file will be. I put all the variables that
might need modification right at the top. Hopefully this will work for
everyone. Comments are welcome.
-Mike
-----------------BEGIN SCRIPT------------------
#!/bin/sh
#
# mrtg Multi Router Traffic Grapher init script. I tried to
# make this as portable as possible. Comments welcome.
#
# Written by Michael Marziani <mdmarziani at yahoo.com>.
#
# Built from the "skeleton" script written by
# Miquel van Smoorenburg <miquels at cistron.nl>.
#
# Version: @(#)skeleton 1.8 03-Mar-1998 miquels at cistron.nl
#
MrtgBin=/usr/local/mrtg/bin/mrtg
MrtgCfg=/usr/local/mrtg/cfg/mrtg.cfg
MrtgUsr=mrtg
MrtgPidFile=/usr/local/mrtg/cfg/mrtg.pid
Name=mrtg
Desc="Multi Router Traffic Grapher"
getpidofproc() {
## Check that PID file exists
if test ! -f $MrtgPidFile; then
echo "Error: No lock file found at $MrtgPidFile..."
echo " ...can't determine if $Name is running."
exit 1
fi
PID=`head -n 1 $MrtgPidFile`
}
## Check that binary exists
if test ! -f $MrtgBin; then
echo "Error: Can't find binary $MrtgBin."
exit 1
fi
## See how we were called.
case "$1" in
start)
echo -n "Starting $Desc: "
$MrtgBin --user $MrtgUsr $MrtgCfg
;;
stop)
getpidofproc
echo -n "Stopping $Desc: "
kill $PID
;;
restart|force-reload)
echo -n "Restarting $Desc: "
$0 stop
sleep 3
$0 start
;;
*)
N=/etc/init.d/$Name
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
------------------END SCRIPT-------------------
_____________________________
Michael D. Marziani
Systems Administrator
Keller Williams Realty International
(512) 327-3070
--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive http://www.ee.ethz.ch/~slist/mrtg
FAQ http://faq.mrtg.org Homepage http://www.mrtg.org
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the mrtg
mailing list