2 # Begin $rc_base/init.d/dhcp
4 # Based on sysklogd script from LFS-3.1 and earlier.
5 # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
6 # Modified for IPFire by Michael Tremer - mitch@ipfire.org
11 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ethernet
/settings
)
12 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/dhcp
/settings
)
14 function flush_chains
() {
15 iptables
-F DHCPGREENINPUT
16 iptables
-F DHCPGREENOUTPUT
17 iptables
-F DHCPBLUEINPUT
18 iptables
-F DHCPBLUEOUTPUT
25 if [ -n "${GREEN_DEV}" -a -e "/var/ipfire/dhcp/enable_green" ]; then
26 devices
="${GREEN_DEV}"
28 iptables
-A DHCPGREENINPUT
-i "${GREEN_DEV}" -j DHCPINPUT
29 iptables
-A DHCPGREENOUTPUT
-o "${GREEN_DEV}" -j DHCPOUTPUT
31 if [ -n "${BLUE_DEV}" -a -e "/var/ipfire/dhcp/enable_blue" ]; then
32 devices
+=" ${BLUE_DEV}"
34 iptables
-A DHCPBLUEINPUT
-i "${BLUE_DEV}" -j DHCPINPUT
35 iptables
-A DHCPBLUEOUTPUT
-o "${BLUE_DEV}" -j DHCPOUTPUT
38 boot_mesg
"Starting DHCP Server..."
39 loadproc
/usr
/sbin
/dhcpd
-q ${devices}
41 # Start Unbound DHCP Lease Bridge unless RFC2136 is used
42 if [ "${DNS_UPDATE_ENABLED}" != on
]; then
43 boot_mesg
"Starting Unbound DHCP Leases Bridge..."
44 loadproc
/usr
/sbin
/unbound-dhcp-leases-bridge
-d
47 (sleep 5 && chmod 644 /var
/run
/dhcpd.pid
) & # Fix because silly dhcpd creates its pid with mode 640
53 boot_mesg
"Stopping DHCP Server..."
54 killproc
-p /var
/run
/dhcpd.pid
/usr
/sbin
/dhcpd
55 if [ "$(ps -A | grep " dhcpd
")" != "" ] ; then
56 # if fail use the hard way ...
57 boot_mesg
"Killing DHCP Server..."
58 killall
-w -s KILL
/usr
/sbin
/dhcpd
> /dev
/null
2>&1
59 rm -f /var
/run
/dhcpd.pid
> /dev
/null
2>&1
64 boot_mesg
"Stopping Unbound DHCP Leases Bridge..."
65 killproc
/usr
/sbin
/unbound-dhcp-leases-bridge
69 boot_mesg
"Reloading DHCP Server..."
70 reloadproc
/usr
/sbin
/dhcpd
80 statusproc
/usr
/sbin
/dhcpd
81 statusproc
/usr
/sbin
/unbound-dhcp-leases-bridge
85 echo "Usage: $0 {start|stop|reload|restart|status}"
90 # End $rc_base/init.d/dhcp