]> git.pld-linux.org Git - packages/arpwatch.git/blobdiff - arpwatch.init
- added ac264.patch
[packages/arpwatch.git] / arpwatch.init
index 717d18e791da9162883db734f88a782389901dfc..f50694b7f3471a1adc38729b8fba3e30eef9de8f 100644 (file)
@@ -1,10 +1,9 @@
 #!/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
 . /etc/rc.d/init.d/functions
 # Get network config
 . /etc/sysconfig/network
 
+# Initial values
+GLOBAL_OPTIONS=""
+
 # Get service config
 [ -f /etc/sysconfig/arpwatch ] && . /etc/sysconfig/arpwatch
 
 # Check that networking is up.
-if [ "${NETWORKING}" = "no" ]; then
-       echo "WARNING: Networking is down. Arpwatch service can't be runed."
-       exit 1
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down "arpwatch"
+               exit 1
+       fi
+else
+       exit 0
 fi
 
+if is_yes "${NO_BOGON}"; then
+       GLOBAL_OPTIONS="$GLOBAL_OPTIONS -N"
+else
+       if [ -n "${LOCAL_NETWORKS}" ]; then
+               for i in ${LOCAL_NETWORKS}; do
+                       GLOBAL_OPTIONS="$GLOBAL_OPTIONS -n $i"
+               done
+       fi
+fi
 
+RETVAL=0
 # See how we were called.
 case "$1" in
   start)
@@ -32,31 +48,49 @@ case "$1" in
                          | egrep '^[^ ].*' |egrep -v "NOARP|LOOPBACK" \
                          |sed 's/[0-9]*: \([a-zA-Z0-9]*\)[@:].*/\1/'|xargs`"
                fi
+               [ ! -z "$NETWORKS" ] && NETWORKS="-n $NETWORKS"
                for IFC in $INTERFACES; do
-                       show "Starting arpwatch for $IFC"
-                       touch /var/state/arpwatch/$IFC.dat
-                       daemon arpwatch -i $IFC -f /var/state/arpwatch/$IFC.dat
+                       msg_starting "arpwatch ($IFC)"
+                       touch /var/lib/arpwatch/$IFC.dat
+                       chown 2:2 /var/lib/arpwatch/$IFC.dat
+                       OPTIONS="$GLOBAL_OPTIONS"
+                       if ! is_yes "${NO_BOGON}"; then
+                               eval IF_LOCAL_NETWORKS=\$${IFC}_LOCAL_NETWORKS
+                               if [ -n "${IF_LOCAL_NETWORKS}" ]; then
+                                       for i in ${IF_LOCAL_NETWORKS}; do
+                                               OPTIONS="$OPTIONS -n $i"
+                                       done
+                               fi
+                       fi
+                       daemon arpwatch $NETWORKS -i $IFC -f /var/lib/arpwatch/$IFC.dat -u daemon $OPTIONS
+                       RETVAL=$?
+                       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/arpwatch
                done
        else
-               echo "arpwatch already is running"
+               msg_already_running "arpwatch"
        fi
-       touch /var/lock/subsys/arpwatch
        ;;
   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"
+       fi
        ;;
   status)
        status arpwatch
+       exit $?
        ;;
-  restart|reload)
+  restart|force-reload)
        $0 stop
        $0 start
+       exit $?
        ;;
   *)
-       echo "Usage: $0 {start|stop|status|restart|reload}"
-       exit 1
+       msg_usage "$0 {start|stop|restart|force-reload|status}"
+       exit 3
 esac
 
-exit 0
+exit $RETVAL
This page took 0.032954 seconds and 4 git commands to generate.