]>
Commit | Line | Data |
---|---|---|
0d9e0091 JR |
1 | #!/bin/sh |
2 | # | |
3 | # chkconfig: 2345 65 35 | |
4 | # description: dhcp_probe attempts to discover DHCP and BootP servers on a directly-attached | |
5 | # Ethernet network. A network administrator can use this tool to locate | |
6 | # unauthorized DHCP and BootP servers. | |
7 | # processname: dhcp_probe | |
8 | # pidfile: /var/run/dhcp_probe.pid | |
9 | # config: /etc/dhcp_probe.cf | |
10 | ### BEGIN INIT INFO | |
11 | # Provides: dhcp_probe | |
12 | # Required-Start: $network | |
13 | # Required-Stop: $network | |
14 | # Default-Stop: 0 1 2 6 | |
15 | # Short-Description: start/stop/restart the dhcp_probe daemon | |
16 | # Description: dhcp_probe attempts to discover DHCP and BootP servers. | |
17 | ### END INIT INFO | |
18 | ||
19 | # Source function library | |
20 | . /etc/rc.d/init.d/functions | |
21 | ||
22 | # Get network config | |
23 | . /etc/sysconfig/network | |
24 | ||
25 | [ -f /etc/sysconfig/dhcp_probe ] && . /etc/sysconfig/dhcp_probe | |
26 | ||
27 | start() { | |
28 | if [ -f /var/lock/subsys/dhcp_probe ]; then | |
29 | msg_already_running "dhcp_probe" | |
30 | return | |
31 | fi | |
32 | for nic in $INTERFACES; do | |
33 | msg_starting "dhcp_probe on $nic" | |
34 | daemon /usr/sbin/dhcp_probe -p /var/run/dhcp_probe.$nic.pid $nic | |
35 | done | |
36 | touch /var/lock/subsys/dhcp_probe | |
37 | } | |
38 | ||
39 | stop() { | |
40 | if [ ! -f /var/lock/subsys/dhcp_probe ]; then | |
41 | msg_not_running "dhcp_probe" | |
42 | return | |
43 | fi | |
44 | for nic in $INTERFACES; do | |
ca629ece | 45 | msg_stopping "dhcp_probe on $nic" |
0d9e0091 JR |
46 | killproc --pidfile /var/run/dhcp_probe.$nic.pid dhcp_probe |
47 | done | |
85965b55 JR |
48 | # kill leftovers if an interface was removed from $INTERFACES |
49 | for file in /var/run/dhcp_probe*pid ; do | |
50 | nic=${file##/var/run/dhcp_probe.} | |
51 | nic=${nic%%pid} | |
52 | [ -z "$nic" ] && nic="unknown interface" | |
53 | msg_stopping "dhcp_probe on $nic" | |
54 | killproc --pidfile $file dhcp_probe | |
55 | done | |
0d9e0091 JR |
56 | rm -f /var/lock/subsys/dhcp_probe >/dev/null 2>&1 |
57 | } | |
58 | ||
59 | reload(){ | |
60 | for nic in $INTERFACES; do | |
61 | killproc --pidfile /var/run/dhcp_probe.$nic.pid dhcp_probe -HUP | |
62 | done | |
63 | } | |
64 | ||
ca629ece | 65 | status_f() { |
0d9e0091 | 66 | for nic in $INTERFACES; do |
ca629ece | 67 | status --pidfile /var/run/dhcp_probe.$nic.pid "dhcp_probe on $nic" |
0d9e0091 JR |
68 | done |
69 | } | |
70 | ||
71 | condrestart() { | |
72 | if [ ! -f /var/lock/subsys/dhcp_probe ]; then | |
73 | msg_not_running "dhcp_probe" | |
74 | return | |
75 | fi | |
76 | stop | |
77 | start | |
78 | } | |
79 | ||
80 | RETVAL=0 | |
81 | # See how we were called. | |
82 | case "$1" in | |
83 | start) | |
84 | start | |
85 | ;; | |
86 | stop) | |
87 | stop | |
88 | ;; | |
89 | status) | |
ca629ece | 90 | status_f |
0d9e0091 JR |
91 | ;; |
92 | restart|force-reload) | |
ca629ece JR |
93 | stop |
94 | start | |
0d9e0091 JR |
95 | ;; |
96 | reload) | |
97 | reload | |
98 | ;; | |
99 | condrestart|try-restart) | |
100 | restart | |
101 | ;; | |
102 | *) | |
103 | msg_usage "$0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" | |
104 | exit 3 | |
105 | ;; | |
106 | esac | |
107 | ||
108 | exit $RETVAL |