5 # description: DHCP Server
7 # Source function library
8 . /etc/rc.d/init.d/functions
11 . /etc/sysconfig/network
13 # Check that networking is up.
14 if ! is_yes "${IPV4_NETWORKING}"; then
19 [ -f /etc/sysconfig/dhcpd ] && . /etc/sysconfig/dhcpd
21 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
22 msg_network_down "DHCP Server"
29 if LC_ALL=C ip addr show dev $DEVICE | grep -q inet; then
39 /sbin/dhcpd -4 -t -T || rc=$?
41 # check if interfaces specified exist and have addresses
42 for i in $DHCPD_INTERFACES; do
43 if ! check_device_up $i; then
44 echo >&2 "Device '$i' does not exist or has no address configured"
52 # wrapper for configtest
57 # run checkconfig only once
58 if [ $checkconfig -ne -1 ]; then
62 if [ "$details" = "1" ]; then
63 # run config test and display report (status action)
64 show "Checking %s configuration" "DHCP Server"; busy
66 out=$(configtest 2>&1)
68 if [ $checkconfig -eq 0 ]; then
73 [ "$out" ] && echo >&2 "$out"
76 # run config test and abort with nice message if failed
77 # (for actions checking status before action).
78 configtest >/dev/null 2>&1
80 if [ $checkconfig -ne 0 ]; then
81 show "Checking %s configuration" "DHCP Server"; fail
82 nls 'Configuration test failed. See details with %s "checkconfig"' $0
89 # Check if the service is already running?
90 if [ -f /var/lock/subsys/dhcpd ]; then
91 msg_already_running "DHCP Server"
96 msg_starting "DHCP Server"
97 daemon /sbin/dhcpd -4 -q $DHCPD_INTERFACES
99 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd
103 if [ ! -f /var/lock/subsys/dhcpd ]; then
104 msg_not_running "DHCP Server"
108 msg_stopping "DHCP Server"
109 killproc --pidfile /var/run/dhcpd.pid dhcpd
110 rm -f /var/run/dhcpd.pid /var/lock/subsys/dhcpd >/dev/null 2>&1
114 if [ ! -f /var/lock/subsys/dhcpd ]; then
115 msg_not_running "DHCP Server"
126 # See how we were called.
145 checkconfig|configtest)
149 status --pidfile /var/run/dhcpd.pid dhcpd
153 msg_usage "$0 {start|stop|restart|try-restart|force-reload|checkconfig|status}"