]> git.ipfire.org Git - ipfire-2.x.git/blame - src/initscripts/system/dhcp
unbound: Drop certificates for local control connection
[ipfire-2.x.git] / src / initscripts / system / dhcp
CommitLineData
6bdd769d
MT
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
6f5d8f0c 10
0eccedd1
MT
11[ -e "/etc/sysconfig/dhcpd" ] && . /etc/sysconfig/dhcpd
12
6bdd769d 13eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
6f5d8f0c 14eval $(/usr/local/bin/readhash /var/ipfire/dhcp/settings)
6bdd769d 15
8490e496
MT
16function flush_chains() {
17 iptables -F DHCPGREENINPUT
18 iptables -F DHCPGREENOUTPUT
19 iptables -F DHCPBLUEINPUT
20 iptables -F DHCPBLUEOUTPUT
21}
22
6bdd769d
MT
23case "$1" in
24 start)
8490e496
MT
25 flush_chains
26
838925a6 27 if [ -n "${GREEN_DEV}" -a -e "/var/ipfire/dhcp/enable_green" ]; then
0eccedd1 28 LISTEN_INTERFACES+=" ${GREEN_DEV}"
8490e496
MT
29
30 iptables -A DHCPGREENINPUT -i "${GREEN_DEV}" -j DHCPINPUT
31 iptables -A DHCPGREENOUTPUT -o "${GREEN_DEV}" -j DHCPOUTPUT
6bdd769d 32 fi
838925a6 33 if [ -n "${BLUE_DEV}" -a -e "/var/ipfire/dhcp/enable_blue" ]; then
0eccedd1 34 LISTEN_INTERFACES+=" ${BLUE_DEV}"
8490e496
MT
35
36 iptables -A DHCPBLUEINPUT -i "${BLUE_DEV}" -j DHCPINPUT
37 iptables -A DHCPBLUEOUTPUT -o "${BLUE_DEV}" -j DHCPOUTPUT
38 fi
39
6bdd769d 40 boot_mesg "Starting DHCP Server..."
0eccedd1 41 loadproc /usr/sbin/dhcpd -q ${LISTEN_INTERFACES}
838925a6 42
6f5d8f0c
MT
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
a2d5130f 49 (sleep 5 && chmod 644 /var/run/dhcpd.pid) & # Fix because silly dhcpd creates its pid with mode 640
6bdd769d
MT
50 ;;
51
52 stop)
8490e496
MT
53 flush_chains
54
6bdd769d 55 boot_mesg "Stopping DHCP Server..."
e5ba3160 56 killproc -p /var/run/dhcpd.pid /usr/sbin/dhcpd
274a6064
AF
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;
274a6064 63 fi
6f5d8f0c
MT
64
65 boot_mesg "Stopping Unbound DHCP Leases Bridge..."
66 killproc /usr/sbin/unbound-dhcp-leases-bridge
6bdd769d
MT
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
6f5d8f0c 82 statusproc /usr/sbin/unbound-dhcp-leases-bridge
6bdd769d
MT
83 ;;
84
85 *)
86 echo "Usage: $0 {start|stop|reload|restart|status}"
87 exit 1
88 ;;
89esac
90
91# End $rc_base/init.d/dhcp