]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/initscripts/init.d/dhcp
Fix special character output at setup.
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / 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
10eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
11
12case "$1" in
13 start)
14 iptables -F DHCPBLUEINPUT
15 if [ -e /var/ipfire/dhcp/enable_green ]; then
16 devices="${GREEN_DEV}"
17 fi
18 if [ -e /var/ipfire/dhcp/enable_blue ]; then
8e8bbd9d 19 devices+=" ${BLUE_DEV}"
6bdd769d
MT
20
21 iptables -A DHCPBLUEINPUT -p tcp --source-port 68 --destination-port 67 -i ${BLUE_DEV} -j ACCEPT > /dev/null 2>&1
22 iptables -A DHCPBLUEINPUT -p udp --source-port 68 --destination-port 67 -i ${BLUE_DEV} -j ACCEPT > /dev/null 2>&1
23 fi
24
25 boot_mesg "Starting DHCP Server..."
26 loadproc /usr/sbin/dhcpd -q ${devices}
27
a2d5130f 28 (sleep 5 && chmod 644 /var/run/dhcpd.pid) & # Fix because silly dhcpd creates its pid with mode 640
6bdd769d
MT
29 ;;
30
31 stop)
32 boot_mesg "Stopping DHCP Server..."
e5ba3160 33 killproc -p /var/run/dhcpd.pid /usr/sbin/dhcpd
274a6064
AF
34 if [ "$(ps -A | grep " dhcpd")" != "" ] ; then
35 # if fail use the hard way ...
36 boot_mesg "Killing DHCP Server..."
37 killall -w -s KILL /usr/sbin/dhcpd > /dev/null 2>&1
38 rm -f /var/run/dhcpd.pid > /dev/null 2>&1
39 echo_ok;
40 exit 0
41 fi
6bdd769d
MT
42 ;;
43
44 reload)
45 boot_mesg "Reloading DHCP Server..."
46 reloadproc /usr/sbin/dhcpd
47 ;;
48
49 restart)
50 $0 stop
51 sleep 1
52 $0 start
53 ;;
54
55 status)
56 statusproc /usr/sbin/dhcpd
57 ;;
58
59 *)
60 echo "Usage: $0 {start|stop|reload|restart|status}"
61 exit 1
62 ;;
63esac
64
65# End $rc_base/init.d/dhcp