]> git.pld-linux.org Git - packages/arpwatch.git/blob - arpwatch.init
- rel 6; update patches from debian
[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 GLOBAL_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 is_yes "${NO_BOGON}"; then
31         GLOBAL_OPTIONS="$GLOBAL_OPTIONS -N"
32 else
33         if [ -n "${LOCAL_NETWORKS}" ]; then
34                 for i in ${LOCAL_NETWORKS}; do
35                         GLOBAL_OPTIONS="$GLOBAL_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                         OPTIONS="$GLOBAL_OPTIONS"
57                         if ! is_yes "${NO_BOGON}"; then
58                                 eval IF_LOCAL_NETWORKS=\$${IFC}_LOCAL_NETWORKS
59                                 if [ -n "${IF_LOCAL_NETWORKS}" ]; then
60                                         for i in ${IF_LOCAL_NETWORKS}; do
61                                                 OPTIONS="$OPTIONS -n $i"
62                                         done
63                                 fi
64                         fi
65                         daemon arpwatch $NETWORKS -i $IFC -f /var/lib/arpwatch/$IFC.dat -u daemon $OPTIONS
66                         RETVAL=$?
67                         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/arpwatch
68                 done
69         else
70                 msg_already_running "arpwatch"
71         fi
72         ;;
73   stop)
74         if [ -f /var/lock/subsys/arpwatch ]; then
75                 msg_stopping "arpwatch"
76                 killproc arpwatch
77                 rm -f /var/lock/subsys/arpwatch >/dev/null 2>&1
78         else
79                 msg_not_running "arpwatch"
80         fi
81         ;;
82   status)
83         status arpwatch
84         exit $?
85         ;;
86   restart|force-reload)
87         $0 stop
88         $0 start
89         exit $?
90         ;;
91   *)
92         msg_usage "$0 {start|stop|restart|force-reload|status}"
93         exit 3
94 esac
95
96 exit $RETVAL
This page took 0.066607 seconds and 3 git commands to generate.