]>
Commit | Line | Data |
---|---|---|
cd77786f | 1 | #!/bin/sh |
7b0d0d3a | 2 | # |
6c233b96 | 3 | # chkconfig: 345 55 45 |
7b0d0d3a AF |
4 | # description: The arpwatch daemon attempts to keep track of ethernet/ip \ |
5 | # address pairings. | |
a1de136a | 6 | # processname: arpwatch |
63276756 | 7 | |
8 | # Source function library | |
7b0d0d3a AF |
9 | . /etc/rc.d/init.d/functions |
10 | ||
63276756 | 11 | # Get network config |
7b0d0d3a AF |
12 | . /etc/sysconfig/network |
13 | ||
63276756 | 14 | # Get service config |
15 | [ -f /etc/sysconfig/arpwatch ] && . /etc/sysconfig/arpwatch | |
16 | ||
7b0d0d3a | 17 | # Check that networking is up. |
c3cea41e | 18 | if is_yes "${NETWORKING}"; then |
97b606a9 | 19 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then |
c3cea41e | 20 | msg_network_down "arpwatch" |
21 | exit 1 | |
22 | fi | |
23 | else | |
24 | exit 0 | |
a454c97d | 25 | fi |
63276756 | 26 | |
87912837 | 27 | RETVAL=0 |
7b0d0d3a AF |
28 | # See how we were called. |
29 | case "$1" in | |
30 | start) | |
63276756 | 31 | # Check if the service is already running? |
32 | if [ ! -f /var/lock/subsys/arpwatch ]; then | |
59e8e33f AF |
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 | |
82ef92d3 | 38 | [ ! -z "$NETWORKS" ] && NETWORKS="-n $NETWORKS" |
59e8e33f | 39 | for IFC in $INTERFACES; do |
0276d822 | 40 | msg_starting "arpwatch ($IFC)" |
12c0e377 | 41 | touch /var/lib/arpwatch/$IFC.dat |
f246cdf8 | 42 | chown 2:2 /var/lib/arpwatch/$IFC.dat |
82ef92d3 | 43 | daemon arpwatch $NETWORKS -i $IFC -f /var/lib/arpwatch/$IFC.dat -u daemon |
86be8f28 | 44 | RETVAL=$? |
45 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/arpwatch | |
59e8e33f | 46 | done |
63276756 | 47 | else |
bade4eed | 48 | msg_already_running "arpwatch" |
63276756 | 49 | fi |
7b0d0d3a AF |
50 | ;; |
51 | stop) | |
86be8f28 | 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 | |
bade4eed | 57 | msg_not_running "arpwatch" |
86be8f28 | 58 | fi |
7b0d0d3a AF |
59 | ;; |
60 | status) | |
61 | status arpwatch | |
87912837 | 62 | exit $? |
7b0d0d3a | 63 | ;; |
87912837 | 64 | restart|force-reload) |
7b0d0d3a AF |
65 | $0 stop |
66 | $0 start | |
87912837 | 67 | exit $? |
7b0d0d3a AF |
68 | ;; |
69 | *) | |
87912837 | 70 | msg_usage "$0 {start|stop|restart|force-reload|status}" |
71 | exit 3 | |
7b0d0d3a AF |
72 | esac |
73 | ||
86be8f28 | 74 | exit $RETVAL |