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