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 |
# Define SERVERS with a list of one or more DHCP servers where |
28 |
# DHCP packets are to be relayed to and from. This is mandatory. |
29 |
SERVERS="" |
30 |
# Define OPTIONS with any other options to pass to the dhcrelay server. |
31 |
OPTIONS="-q" |
32 |
|
33 |
# Values specified in this file override the defaults above. |
34 |
[ -f /etc/sysconfig/dhcrelay ] && . /etc/sysconfig/dhcrelay |
35 |
|
36 |
# Check that at least one DHCP server to relay to was specified. |
37 |
[ "${SERVERS}" = "" ] && exit 0 |
38 |
|
39 |
RETVAL=0 |
40 |
|
41 |
start() { |
42 |
# Start daemons. |
43 |
echo -n "Starting dhcrelay: " |
44 |
daemon /usr/sbin/dhcrelay $OPTIONS $SERVERS |
45 |
RETVAL=$? |
46 |
echo |
47 |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcrelay |
48 |
return $RETVAL |
49 |
} |
50 |
|
51 |
stop() { |
52 |
# Stop daemons. |
53 |
echo -n "Shutting down dhcrelay: " |
54 |
killproc dhcrelay |
55 |
RETVAL=$? |
56 |
echo |
57 |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dhcrelay |
58 |
return $RETVAL |
59 |
} |
60 |
|
61 |
# See how we were called. |
62 |
case "$1" in |
63 |
start) |
64 |
start |
65 |
;; |
66 |
stop) |
67 |
stop |
68 |
;; |
69 |
restart|reload) |
70 |
stop |
71 |
start |
72 |
RETVAL=$? |
73 |
;; |
74 |
condrestart) |
75 |
if [ -f /var/lock/subsys/dhcrelay ]; then |
76 |
stop |
77 |
start |
78 |
RETVAL=$? |
79 |
fi |
80 |
;; |
81 |
status) |
82 |
status dhcrelay |
83 |
RETVAL=$? |
84 |
;; |
85 |
*) |
86 |
echo "Usage: dhcrelay {start|stop|restart|condrestart|status}" |
87 |
exit 1 |
88 |
esac |
89 |
|
90 |
exit $RETVAL |