1 |
#!/bin/sh |
2 |
# |
3 |
# dhcrelay This shell script takes care of starting and stopping |
4 |
# dhcrelay. |
5 |
# |
6 |
# chkconfig: 2345 65 35 |
7 |
# description: dhcrelay provides the DHCP Relay service. |
8 |
# |
9 |
# processname: dhcrelay |
10 |
# pidfile: /var/run/dhcrelay.pid |
11 |
# |
12 |
### BEGIN INIT INFO |
13 |
# Provides: dhcrelay |
14 |
# Required-Start: $network |
15 |
# Required-Stop: $network |
16 |
# Default-Start: 2 3 4 5 |
17 |
# Default-Stop: |
18 |
# Short-Description: The dhcrelay daemon |
19 |
# Description: dhcrelay provides the DHCP Relay service. |
20 |
### END INIT INFO |
21 |
|
22 |
# Source function library. |
23 |
. /etc/rc.d/init.d/functions |
24 |
|
25 |
# Source networking configuration. |
26 |
. /etc/sysconfig/network |
27 |
|
28 |
# Check that networking is up. |
29 |
[ ${NETWORKING} = "no" ] && exit 0 |
30 |
|
31 |
[ -x /usr/sbin/dhcrelay ] || exit 0 |
32 |
|
33 |
# The following variables can be set in the file |
34 |
# /etc/sysconfig/dhcrelay. |
35 |
|
36 |
# Define SERVERS with a list of one or more DHCP servers where |
37 |
# DHCP packets are to be relayed to and from. This is mandatory. |
38 |
#SERVERS="10.11.12.13 10.9.8.7" |
39 |
SERVERS="" |
40 |
|
41 |
# Define OPTIONS with any other options to pass to the dhcrelay server. |
42 |
# See dhcrelay(8) for available options and syntax. |
43 |
#OPTIONS="-q -i eth0 -i eth1" |
44 |
OPTIONS="-q" |
45 |
|
46 |
# Source dhcrelay configuration. Values specified in this file override |
47 |
# the defaults above. |
48 |
[ -f /etc/sysconfig/dhcrelay ] && . /etc/sysconfig/dhcrelay |
49 |
|
50 |
# Check that at least one DHCP server to relay to was specified. |
51 |
[ "${SERVERS}" = "" ] && exit 0 |
52 |
|
53 |
RETVAL=0 |
54 |
|
55 |
start() { |
56 |
# Start daemons. |
57 |
echo -n "Starting dhcrelay: " |
58 |
daemon /usr/sbin/dhcrelay $OPTIONS $SERVERS |
59 |
RETVAL=$? |
60 |
echo |
61 |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcrelay |
62 |
return $RETVAL |
63 |
} |
64 |
|
65 |
stop() { |
66 |
# Stop daemons. |
67 |
echo -n "Shutting down dhcrelay: " |
68 |
killproc dhcrelay |
69 |
RETVAL=$? |
70 |
echo |
71 |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dhcrelay |
72 |
return $RETVAL |
73 |
} |
74 |
|
75 |
# See how we were called. |
76 |
case "$1" in |
77 |
start) |
78 |
start |
79 |
;; |
80 |
stop) |
81 |
stop |
82 |
;; |
83 |
restart|reload) |
84 |
stop |
85 |
start |
86 |
RETVAL=$? |
87 |
;; |
88 |
condrestart) |
89 |
if [ -f /var/lock/subsys/dhcrelay ]; then |
90 |
stop |
91 |
start |
92 |
RETVAL=$? |
93 |
fi |
94 |
;; |
95 |
status) |
96 |
status dhcrelay |
97 |
RETVAL=$? |
98 |
;; |
99 |
*) |
100 |
echo "Usage: dhcrelay {start|stop|restart|condrestart|status}" |
101 |
exit 1 |
102 |
esac |
103 |
|
104 |
exit $RETVAL |