-#! /bin/sh
+#!/bin/sh
#
-# chkconfig: - 55 45
+# chkconfig: 345 55 45
# description: The arpwatch daemon attempts to keep track of ethernet/ip \
# address pairings.
-# processname: arpwatch
+# processname: arpwatch
-# Source function library.
+# Source function library
. /etc/rc.d/init.d/functions
-# Get config.
+# Get network config
. /etc/sysconfig/network
+# Get service config
+[ -f /etc/sysconfig/arpwatch ] && . /etc/sysconfig/arpwatch
+
# Check that networking is up.
-if [ ${NETWORKING} = "no" ]
-then
- exit 0
+if [ "${NETWORKING}" = "no" ]; then
+ msg_Network_Down "arpwatch"
+ exit 1
fi
+
# See how we were called.
case "$1" in
start)
- show Starting arpwatch:
- daemon arpwatch
- touch /var/lock/subsys/arpwatch
+ # Check if the service is already running?
+ if [ ! -f /var/lock/subsys/arpwatch ]; then
+ if [ -z "$INTERFACES" ]; then
+ INTERFACES="`/sbin/ip link show \
+ | egrep '^[^ ].*' |egrep -v "NOARP|LOOPBACK" \
+ |sed 's/[0-9]*: \([a-zA-Z0-9]*\)[@:].*/\1/'|xargs`"
+ fi
+ for IFC in $INTERFACES; do
+ msg_starting "arpwatch ($IFC)"
+ touch /var/lib/arpwatch/$IFC.dat
+ daemon arpwatch -i $IFC -f /var/lib/arpwatch/$IFC.dat
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/arpwatch
+ done
+ else
+ msg_Already_Running "arpwatch"
+ fi
;;
stop)
- show Stopping arpwatch:
- killproc arpwatch
- rm -f /var/lock/subsys/arpwatch
+ if [ -f /var/lock/subsys/arpwatch ]; then
+ msg_stopping "arpwatch"
+ killproc arpwatch
+ rm -f /var/lock/subsys/arpwatch >/dev/null 2>&1
+ else
+ msg_Not_Running "arpwatch"
+ exit 1
+ fi
;;
status)
status arpwatch
$0 start
;;
*)
- echo "Usage: arpwatch {start|stop|status|restart|reload}"
+ msg_Usage "$0 {start|stop|status|restart|reload}"
exit 1
esac
-exit 0
+exit $RETVAL