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