#!/bin/sh # # chkconfig: 345 99 01 # description: Netsaint network monitor # # File : netsaint # # Author : Jorge Sanchez Aymar (jsanchez@lanchile.cl) # # Changelog : # # 1999-07-09 Karl DeBisschop # - setup for autoconf # - add reload function # 1999-08-06 Ethan Galstad # - Added configuration info for use with RedHat's chkconfig tool # per Fran Boon's suggestion # 1999-08-13 Jim Popovitch # - added variable for netsaint/var directory # - cd into netsaint/var directory before creating tmp files on startup # 1999-08-16 Ethan Galstad # - Added test for rc.d directory as suggested by Karl DeBisschop # 2000-07-23 Karl DeBisschop # - Clean out redhat macros and other dependencies # # Description: Starts and stops the Netsaint monitor # used to provide network services status. # status () { if test ! -f $NetsaintRun; then echo "No lock file found in $NetsaintRun" return 1 fi NetsaintPID=`head -n 1 $NetsaintRun` if test -x $NetsaintCGI/daemonchk.cgi; then if $NetsaintCGI/daemonchk.cgi -l $NetsaintRun; then return 0 else return 1 fi else if ps -p $NetsaintPID; then return 0 else return 1 fi fi return 1 } killproc () { if test ! -f $NetsaintRun; then echo "No lock file found in $NetsaintRun" return 1 fi NetsaintPID=`head -n 1 $NetsaintRun` kill $2 $NetsaintPID } # Source function library if [ -f @sysconfdir@/functions ]; then . @sysconfdir@/functions fi prefix=@prefix@ exec_prefix=@exec_prefix@ NetsaintBin=@bindir@/netsaint NetsaintCfg=@sysconfdir@/netsaint.cfg NetsaintLog=@localstatedir@/status.log NetsaintTmp=@localstatedir@/netsaint.tmp NetsaintSav=@localstatedir@/status.sav NetsaintCmd=@localstatedir@/rw/netsaint.cmd NetsaintVar=@localstatedir@ NetsaintRun=@lockfile@ NetsaintLckDir=/var/lock/subsys NetsaintLckFile=netsaint NetsaintCGI=@sbindir@ Netsaint=@netsaint_user@ # Check that netsaint exists. test -f $NetsaintBin || exit 0 # Check that netsaint.cfg exists. test -f $NetsaintCfg || exit 0 # See how we were called. case "$1" in start) echo "Starting network monitor: netsaint" su -m $Netsaint -c "touch $NetsaintVar/netsaint.log $NetsaintSav" rm -f $NetsaintCmd $NetsaintBin -d $NetsaintCfg if [ -d $NetsaintLckDir ]; then touch $NetsaintLckDir/$NetsaintLckFile; fi sleep 1 status netsaint ;; stop) echo "Stopping network monitor: netsaint" killproc netsaint rm -f $NetsaintLog $NetsaintTmp $NetsaintRun $NetsaintLckDir/$NetsaintLckFile $NetsaintCmd ;; status) status netsaint ;; restart) printf "Running configuration check..." $NetsaintBin -v $NetsaintCfg > /dev/null 2>&1; if [ $? -eq 0 ]; then echo "done" $0 stop $0 start else $NetsaintBin -v $NetsaintCfg echo "failed - aborting restart." exit 1 fi ;; reload|force-reload) printf "Running configuration check..." $NetsaintBin -v $NetsaintCfg > /dev/null 2>&1; if [ $? -eq 0 ]; then echo "done" if test ! -f $NetsaintRun; then $0 start else NetsaintPID=`head -n 1 $NetsaintRun` if status netsaint > /dev/null; then $0 stop $0 start else printf "Reloading netsaint configuration..." killproc netsaint -HUP echo "done" fi fi else $NetsaintBin -v $NetsaintCfg echo "failed - aborting reload." exit 1 fi ;; *) echo "Usage: netsaint {start|stop|restart|reload|force-reload|status}" exit 1 ;; esac # End of this script