Skip to content

Instantly share code, notes, and snippets.

@mbrownnycnyc
Last active December 17, 2015 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbrownnycnyc/5585281 to your computer and use it in GitHub Desktop.
Save mbrownnycnyc/5585281 to your computer and use it in GitHub Desktop.
argusd init rc severely edited
#! /bin/sh
### BEGIN INIT INFO
# Provides: argus-server
# Required-Start: $network
# Required-Stop:
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Network auditing daemon
# Description:
### END INIT INFO
# /etc/init.d/argus. Ripped from exim's init script.
# Modified by Yotam Rubin <yotam@makif.omer.k12.il>
# re-modiifed by matt brown (mbrownnyc) for centos/redhat/fedora/el
LOGFILE=/var/log/argus/argus.log
CONFFILE=/etc/argus.conf
PROG=rastream
DAEMON=/usr/local/sbin/$PROG
NAME=argusd
INSTANCE=0
INTERFACE=eth0
. /etc/rc.d/init.d/functions
[ -e /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
#for some reason, 3.0.6.1 wasn't generating the pid by default, even though it's stated in the argus.conf man page to do this.
# I had to set the settings in argus.conf
# ARGUS_SET_PID=yes
# ARGUS_PID_PATH=/var/run
PIDFILE=/var/run/argus.${INTERFACE}.${INSTANCE}.pid
if [ ! -f $CONFFILE ]; then
echo_failure
echo "$CONFFILE doesn't exist or is not a regular file."
exit 1
fi
testrunning ()
{
if [ -f $PIDFILE ] && [ -n "$(ps -p $(cat $PIDFILE) | grep $PROG)" ];
then
echo_success
echo "$DAEMON is running with PID $(cat $PIDFILE)."
exit 1
else
echo_warning
echo "$DAEMON is not running."
fi
}
testpid ()
{
if [ ! -f $PIDFILE ]; then
echo_warning
echo "$DAEMON is stopped."
exit 1
fi
}
#returns 1 if FILE exists and execute (or search) permission is granted
test -x $DAEMON || exit 1
case "$1" in
start)
echo -n "Starting argus: "
testrunning
$DAEMON -d -i $INTERFACE
testrunning
echo_success
echo ""
;;
stop)
echo -n "Stopping argus: "
testpid
kill `cat $PIDFILE`
rm -f "$PIDFILE"
echo_success
echo ""
;;
restart)
echo -n "Restarting argus: "
kill `cat $PIDFILE` > /dev/null 2>&1 || true
rm -f "$PIDFILE"
$DAEMON -d -i $INTERFACE
echo_successi
echo ""
;;
status)
echo "Checking argus status: "
testrunning
echo ""
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|status}"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment