1 |
#!/bin/sh |
2 |
# |
3 |
### BEGIN INIT INFO |
4 |
# Provides: dhcpd |
5 |
# Default-Start: |
6 |
# Default-Stop: |
7 |
# Should-Start: |
8 |
# Required-Start: $network |
9 |
# Required-Stop: |
10 |
# Short-Description: Start and stop the DHCPv6 server |
11 |
# Description: dhcpd provides the Dynamic Host Configuration Protocol (DHCPv6) |
12 |
# server. |
13 |
### END INIT INFO |
14 |
# |
15 |
# The fields below are left around for legacy tools (will remove later). |
16 |
# |
17 |
# chkconfig: - 65 35 |
18 |
# description: dhcpd provides the Dynamic Host Configuration Protocol (DHCPv6) \ |
19 |
# server |
20 |
# processname: dhcpd |
21 |
# config: /etc/dhcpd6.conf |
22 |
# config: /var/lib/dhcpd/dhcpd6.leases |
23 |
# pidfile: /var/run/dhcpd6.pid |
24 |
|
25 |
. /etc/rc.d/init.d/functions |
26 |
|
27 |
[ -x /usr/sbin/dhcpd ] || exit 0 |
28 |
|
29 |
# Which configuration file to use. |
30 |
CONFIGFILE="/etc/dhcpd6.conf" |
31 |
# Where to store the lease state information. |
32 |
LEASEFILE="/var/lib/dhcp/dhcpd6.leases" |
33 |
# Define INTERFACES to limit which network interfaces dhcpd listens on. |
34 |
# The default null value causes dhcpd to listen on all interfaces. |
35 |
INTERFACES="" |
36 |
# Define OPTIONS with any other options to pass to the dhcpd server. |
37 |
OPTIONS="-q" |
38 |
|
39 |
# Values specified in this file override the defaults above. |
40 |
[ -f /etc/sysconfig/dhcpd6 ] && . /etc/sysconfig/dhcpd6 |
41 |
|
42 |
[ -f $CONFIGFILE ] || exit 0 |
43 |
[ -f $LEASEFILE ] || exit 0 |
44 |
|
45 |
RETVAL=0 |
46 |
|
47 |
start() { |
48 |
echo -n "Starting dhcpd (DHCPv6): " |
49 |
if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then |
50 |
OPTIONS="${OPTIONS} -chroot ${ROOTDIR}" |
51 |
fi |
52 |
daemon /usr/sbin/dhcpd -6 -cf $CONFIGFILE -lf $LEASEFILE $OPTIONS $INTERFACES |
53 |
RETVAL=$? |
54 |
echo |
55 |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd6 |
56 |
return $RETVAL |
57 |
} |
58 |
|
59 |
stop() { |
60 |
echo -n "Shutting down dhcpd (DHCPv6): " |
61 |
if [ -r ${ROOTDIR}/var/run/dhcpd/dhcpd6.pid ]; then |
62 |
kill -TERM `cat ${ROOTDIR}/var/run/dhcpd/dhcpd6.pid` |
63 |
RETVAL=$? |
64 |
[ "$RETVAL" = 0 ] && success "stop" || failure "stop" |
65 |
else |
66 |
success "already stopped" |
67 |
RETVAL=0 |
68 |
fi |
69 |
[ $RETVAL -eq 0 ] && rm -f ${ROOTDIR}/var/run/dhcpd/dhcpd6.pid |
70 |
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/dhcpd6 |
71 |
echo |
72 |
return $RETVAL |
73 |
} |
74 |
|
75 |
configtest() { |
76 |
/usr/sbin/dhcpd -q -t -6 -cf $CONFIGFILE |
77 |
RETVAL=$? |
78 |
if [ $RETVAL -eq 1 ]; then |
79 |
/usr/sbin/dhcpd -t -6 -cf $CONFIGFILE |
80 |
else |
81 |
echo "Syntax: OK" >&2 |
82 |
fi |
83 |
return $RETVAL |
84 |
} |
85 |
|
86 |
case "$1" in |
87 |
start) |
88 |
start |
89 |
;; |
90 |
stop) |
91 |
stop |
92 |
;; |
93 |
restart|reload) |
94 |
stop |
95 |
start |
96 |
RETVAL=$? |
97 |
;; |
98 |
condrestart) |
99 |
if [ -f /var/lock/subsys/dhcpd6 ]; then |
100 |
stop |
101 |
start |
102 |
RETVAL=$? |
103 |
fi |
104 |
;; |
105 |
configtest) |
106 |
configtest |
107 |
;; |
108 |
status) |
109 |
status dhcpd |
110 |
RETVAL=$? |
111 |
;; |
112 |
*) |
113 |
echo "Usage: dhcpd6 {start|stop|restart|condrestart|status}" |
114 |
exit 1 |
115 |
esac |
116 |
|
117 |
exit $RETVAL |