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