]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/dhcp
unbound: Drop certificates for local control connection
[ipfire-2.x.git] / src / initscripts / system / dhcp
1 #!/bin/sh
2 # Begin $rc_base/init.d/dhcp
3
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
7
8 . /etc/sysconfig/rc
9 . $rc_functions
10
11 [ -e "/etc/sysconfig/dhcpd" ] && . /etc/sysconfig/dhcpd
12
13 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
14 eval $(/usr/local/bin/readhash /var/ipfire/dhcp/settings)
15
16 function flush_chains() {
17 iptables -F DHCPGREENINPUT
18 iptables -F DHCPGREENOUTPUT
19 iptables -F DHCPBLUEINPUT
20 iptables -F DHCPBLUEOUTPUT
21 }
22
23 case "$1" in
24 start)
25 flush_chains
26
27 if [ -n "${GREEN_DEV}" -a -e "/var/ipfire/dhcp/enable_green" ]; then
28 LISTEN_INTERFACES+=" ${GREEN_DEV}"
29
30 iptables -A DHCPGREENINPUT -i "${GREEN_DEV}" -j DHCPINPUT
31 iptables -A DHCPGREENOUTPUT -o "${GREEN_DEV}" -j DHCPOUTPUT
32 fi
33 if [ -n "${BLUE_DEV}" -a -e "/var/ipfire/dhcp/enable_blue" ]; then
34 LISTEN_INTERFACES+=" ${BLUE_DEV}"
35
36 iptables -A DHCPBLUEINPUT -i "${BLUE_DEV}" -j DHCPINPUT
37 iptables -A DHCPBLUEOUTPUT -o "${BLUE_DEV}" -j DHCPOUTPUT
38 fi
39
40 boot_mesg "Starting DHCP Server..."
41 loadproc /usr/sbin/dhcpd -q ${LISTEN_INTERFACES}
42
43 # Start Unbound DHCP Lease Bridge unless RFC2136 is used
44 if [ "${DNS_UPDATE_ENABLED}" != on ]; then
45 boot_mesg "Starting Unbound DHCP Leases Bridge..."
46 loadproc /usr/sbin/unbound-dhcp-leases-bridge -d
47 fi
48
49 (sleep 5 && chmod 644 /var/run/dhcpd.pid) & # Fix because silly dhcpd creates its pid with mode 640
50 ;;
51
52 stop)
53 flush_chains
54
55 boot_mesg "Stopping DHCP Server..."
56 killproc -p /var/run/dhcpd.pid /usr/sbin/dhcpd
57 if [ "$(ps -A | grep " dhcpd")" != "" ] ; then
58 # if fail use the hard way ...
59 boot_mesg "Killing DHCP Server..."
60 killall -w -s KILL /usr/sbin/dhcpd > /dev/null 2>&1
61 rm -f /var/run/dhcpd.pid > /dev/null 2>&1
62 echo_ok;
63 fi
64
65 boot_mesg "Stopping Unbound DHCP Leases Bridge..."
66 killproc /usr/sbin/unbound-dhcp-leases-bridge
67 ;;
68
69 reload)
70 boot_mesg "Reloading DHCP Server..."
71 reloadproc /usr/sbin/dhcpd
72 ;;
73
74 restart)
75 $0 stop
76 sleep 1
77 $0 start
78 ;;
79
80 status)
81 statusproc /usr/sbin/dhcpd
82 statusproc /usr/sbin/unbound-dhcp-leases-bridge
83 ;;
84
85 *)
86 echo "Usage: $0 {start|stop|reload|restart|status}"
87 exit 1
88 ;;
89 esac
90
91 # End $rc_base/init.d/dhcp