]> git.pld-linux.org Git - packages/arpwatch.git/blob - arpwatch.init
cosmetics
[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 is_yes "${NETWORKING}"; then
19         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
20                 msg_network_down "arpwatch"
21                 exit 1
22         fi
23 else
24         exit 0
25 fi
26
27 RETVAL=0
28 # See how we were called.
29 case "$1" in
30   start)
31         # Check if the service is already running?
32         if [ ! -f /var/lock/subsys/arpwatch ]; then
33                 if [ -z "$INTERFACES" ]; then
34                         INTERFACES="`/sbin/ip link show \
35                           | egrep '^[^ ].*' |egrep -v "NOARP|LOOPBACK" \
36                           |sed 's/[0-9]*: \([a-zA-Z0-9]*\)[@:].*/\1/'|xargs`"
37                 fi
38                 [ ! -z "$NETWORKS" ] && NETWORKS="-n $NETWORKS"
39                 for IFC in $INTERFACES; do
40                         msg_starting "arpwatch ($IFC)"
41                         touch /var/lib/arpwatch/$IFC.dat
42                         chown 2:2 /var/lib/arpwatch/$IFC.dat
43                         daemon arpwatch $NETWORKS -i $IFC -f /var/lib/arpwatch/$IFC.dat -u daemon
44                         RETVAL=$?
45                         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/arpwatch
46                 done
47         else
48                 msg_already_running "arpwatch"
49         fi
50         ;;
51   stop)
52         if [ -f /var/lock/subsys/arpwatch ]; then
53                 msg_stopping "arpwatch"
54                 killproc arpwatch
55                 rm -f /var/lock/subsys/arpwatch >/dev/null 2>&1
56         else
57                 msg_not_running "arpwatch"
58         fi      
59         ;;
60   status)
61         status arpwatch
62         exit $?
63         ;;
64   restart|force-reload)
65         $0 stop
66         $0 start
67         exit $?
68         ;;
69   *)
70         msg_usage "$0 {start|stop|restart|force-reload|status}"
71         exit 3
72 esac
73
74 exit $RETVAL
This page took 0.032406 seconds and 3 git commands to generate.