]> git.pld-linux.org Git - packages/arpwatch.git/blob - arpwatch.init
- fix: use $IFC instead $INTERFACES on each loop iteration.
[packages/arpwatch.git] / arpwatch.init
1 #!/bin/sh
2 #
3 # chkconfig: 345 55 45
4 # description:  The arpwatch daemon attempts to keep track of ethernet/ip \
5 #               address pairings.
6 # processname:  arpwatch
7
8 # Source function library
9 . /etc/rc.d/init.d/functions
10
11 # Get network config
12 . /etc/sysconfig/network
13
14 # Get service config
15 [ -f /etc/sysconfig/arpwatch ] && . /etc/sysconfig/arpwatch
16
17 # Check that networking is up.
18 if [ "${NETWORKING}" = "no" ]; then
19         msg_Network_Down "arpwatch"
20         exit 1
21 fi
22
23
24 # See how we were called.
25 case "$1" in
26   start)
27         # Check if the service is already running?
28         if [ ! -f /var/lock/subsys/arpwatch ]; then
29                 if [ -z "$INTERFACES" ]; then
30                         INTERFACES="`/sbin/ip link show \
31                           | egrep '^[^ ].*' |egrep -v "NOARP|LOOPBACK" \
32                           |sed 's/[0-9]*: \([a-zA-Z0-9]*\)[@:].*/\1/'|xargs`"
33                 fi
34                 for IFC in $INTERFACES; do
35                         msg_starting "arpwatch ($IFC)"
36                         touch /var/lib/arpwatch/$IFC.dat
37                         daemon arpwatch -i $IFC -f /var/lib/arpwatch/$IFC.dat
38                         RETVAL=$?
39                         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/arpwatch
40                 done
41         else
42                 msg_Already_Running "arpwatch"
43         fi
44         ;;
45   stop)
46         if [ -f /var/lock/subsys/arpwatch ]; then
47                 msg_stopping "arpwatch"
48                 killproc arpwatch
49                 rm -f /var/lock/subsys/arpwatch >/dev/null 2>&1
50         else
51                 msg_Not_Running "arpwatch"
52                 exit 1
53         fi      
54         ;;
55   status)
56         status arpwatch
57         ;;
58   restart|reload)
59         $0 stop
60         $0 start
61         ;;
62   *)
63         msg_Usage "$0 {start|stop|status|restart|reload}"
64         exit 1
65 esac
66
67 exit $RETVAL
This page took 0.074013 seconds and 3 git commands to generate.