]>
Commit | Line | Data |
---|---|---|
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 | |
10 | eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) | |
11 | ||
8490e496 MT |
12 | function flush_chains() { |
13 | iptables -F DHCPGREENINPUT | |
14 | iptables -F DHCPGREENOUTPUT | |
15 | iptables -F DHCPBLUEINPUT | |
16 | iptables -F DHCPBLUEOUTPUT | |
17 | } | |
18 | ||
6bdd769d MT |
19 | case "$1" in |
20 | start) | |
8490e496 MT |
21 | flush_chains |
22 | ||
838925a6 | 23 | if [ -n "${GREEN_DEV}" -a -e "/var/ipfire/dhcp/enable_green" ]; then |
6bdd769d | 24 | devices="${GREEN_DEV}" |
8490e496 MT |
25 | |
26 | iptables -A DHCPGREENINPUT -i "${GREEN_DEV}" -j DHCPINPUT | |
27 | iptables -A DHCPGREENOUTPUT -o "${GREEN_DEV}" -j DHCPOUTPUT | |
6bdd769d | 28 | fi |
838925a6 | 29 | if [ -n "${BLUE_DEV}" -a -e "/var/ipfire/dhcp/enable_blue" ]; then |
8e8bbd9d | 30 | devices+=" ${BLUE_DEV}" |
8490e496 MT |
31 | |
32 | iptables -A DHCPBLUEINPUT -i "${BLUE_DEV}" -j DHCPINPUT | |
33 | iptables -A DHCPBLUEOUTPUT -o "${BLUE_DEV}" -j DHCPOUTPUT | |
34 | fi | |
35 | ||
6bdd769d MT |
36 | boot_mesg "Starting DHCP Server..." |
37 | loadproc /usr/sbin/dhcpd -q ${devices} | |
838925a6 | 38 | |
a2d5130f | 39 | (sleep 5 && chmod 644 /var/run/dhcpd.pid) & # Fix because silly dhcpd creates its pid with mode 640 |
6bdd769d MT |
40 | ;; |
41 | ||
42 | stop) | |
8490e496 MT |
43 | flush_chains |
44 | ||
6bdd769d | 45 | boot_mesg "Stopping DHCP Server..." |
e5ba3160 | 46 | killproc -p /var/run/dhcpd.pid /usr/sbin/dhcpd |
274a6064 AF |
47 | if [ "$(ps -A | grep " dhcpd")" != "" ] ; then |
48 | # if fail use the hard way ... | |
49 | boot_mesg "Killing DHCP Server..." | |
50 | killall -w -s KILL /usr/sbin/dhcpd > /dev/null 2>&1 | |
51 | rm -f /var/run/dhcpd.pid > /dev/null 2>&1 | |
52 | echo_ok; | |
53 | exit 0 | |
54 | fi | |
6bdd769d MT |
55 | ;; |
56 | ||
57 | reload) | |
58 | boot_mesg "Reloading DHCP Server..." | |
59 | reloadproc /usr/sbin/dhcpd | |
60 | ;; | |
61 | ||
62 | restart) | |
63 | $0 stop | |
64 | sleep 1 | |
65 | $0 start | |
66 | ;; | |
67 | ||
68 | status) | |
69 | statusproc /usr/sbin/dhcpd | |
70 | ;; | |
71 | ||
72 | *) | |
73 | echo "Usage: $0 {start|stop|reload|restart|status}" | |
74 | exit 1 | |
75 | ;; | |
76 | esac | |
77 | ||
78 | # End $rc_base/init.d/dhcp |