#!/bin/sh # # /etc/rc.d/rc.dhcpd - Start/stop/restart the DHCP daemon. # Thanks to Michiel P.H. van Wessem and Steven Robson INTERFACES="eth0 ath0" OPTIONS="-q" CONFIGFILE="/etc/dhcpd.conf" LEASEFILE="/var/state/dhcp/dhcpd.leases" PIDFILE="/var/run/dhcpd.pid" dhcpd_start() { if [ -x /usr/sbin/dhcpd -a -r $CONFIGFILE ]; then echo "Starting DHCP Daemon on $INTERFACES..." /usr/sbin/dhcpd -cf $CONFIGFILE -lf $LEASEFILE $OPTIONS $INTERFACES fi } dhcpd_stop() { #there be demons here. I am sure we can get the pid from /var/run/ #for a much cleaner echo -n "Stopping DHCP Daemon..." if [ -r $PIDFILE ]; then kill `cat $PIDFILE` rm $PIDFILE echo "Done" else killall dhcpd echo "Done" fi } dhcpd_restart() { dhcpd_stop sleep 2 dhcpd_start } case "$1" in 'start') dhcpd_start ;; 'stop') dhcpd_stop ;; 'restart') dhcpd_restart ;; *) echo "Usage: $prog {start|stop|restart}" exit 1 ;; esac