Skip to content

Instantly share code, notes, and snippets.

@paulte
Created February 4, 2018 15:28
Show Gist options
  • Select an option

  • Save paulte/319e84c8e996968cc644b5c60d8a9cfe to your computer and use it in GitHub Desktop.

Select an option

Save paulte/319e84c8e996968cc644b5c60d8a9cfe to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Init script for pmacct network monitoring tool.
#
# chkconfig: 2345 13 86
# description: pmacct network monitoring tool.
#
# processname: pmacctd
# config: /etc/pmacct/pmacctd.conf
# pidfile: /var/run/pmacctd.pid
source /etc/rc.d/init.d/functions
[ -x /usr/local/sbin/pmacctd ] || exit 1
[ -r /etc/pmacct/pmacctd.conf ] || exit 1
### Default variables
CONFIG_FILE="/etc/pmacct/pmacctd.conf"
RETVAL=0
prog="pmacctd"
desc="pmacct network monitoring"
start() {
echo -n $"Starting $desc ($prog): "
/usr/local/sbin/$prog -f "$CONFIG_FILE" -D
RETVAL=$?
if [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog ; then
echo_success
echo
else
echo_failure
echo
fi
}
stop() {
echo -n $"Shutting down $desc ($prog): "
killproc $prog
RETVAL=$?
if [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog ; then
echo_success
echo
else
echo_failure
echo
fi
}
reload() {
echo -n $"Reloading $desc ($prog): "
killproc $prog -HUP
RETVAL=$?
echo
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
condrestart)
[ -e /var/lock/subsys/$prog ] && restart
RETVAL=$?
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
RETVAL=1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment