--- cauldron/dhcp/current/SOURCES/dhcpd.init 2011/09/05 09:13:09 138690 +++ cauldron/dhcp/current/SOURCES/dhcpd.init 2011/09/05 09:17:05 138691 @@ -1,35 +1,29 @@ -#!/bin/bash -# -# dhcpd This shell script takes care of starting and stopping -# dhcpd. -# -# chkconfig: 345 65 35 -# description: dhcpd provides the Dynamic Host Configuration Protocol service. -# -# processname: dhcpd -# config: /etc/dhcpd.conf -# pidfile: /var/run/dhcpd/dhcpd.pid +#!/bin/sh # ### BEGIN INIT INFO # Provides: dhcpd -# Required-Start: $network -# Should-Start: ldap -# Required-Stop: $network +# Default-Start: # Default-Stop: 0 6 +# Should-Start: ldap +# Required-Start: $network # Should-Stop: ldap -# Short-Description: The dhcpd daemon -# Description: dhcpd provides the Dynamic Host Configuration Protocol service. +# Short-Description: Start and stop the DHCP server +# Description: dhcpd provides the Dynamic Host Configuration Protocol (DHCP) +# server. ### END INIT INFO +# +# The fields below are left around for legacy tools (will remove later). +# +# chkconfig: - 65 35 +# description: dhcpd provides the Dynamic Host Configuration Protocol (DHCP) \ +# server +# processname: dhcpd +# config: /etc/dhcp/dhcpd.conf +# config: /var/lib/dhcpd/dhcpd.leases +# pidfile: /var/run/dhcpd.pid -# Source function library. . /etc/rc.d/init.d/functions -# Source networking configuration. -. /etc/sysconfig/network - -# Check that networking is up. -[ ${NETWORKING} = "no" ] && exit 0 - [ -x /usr/sbin/dhcpd ] || exit 0 # The following variables should be set in the file @@ -60,62 +54,76 @@ RETVAL=0 start() { - # Start daemons. - echo -n "Starting dhcpd: " - if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then - OPTIONS="${OPTIONS} -chroot ${ROOTDIR}" - fi - daemon /usr/sbin/dhcpd -cf $CONFIGFILE -lf $LEASEFILE $OPTIONS $INTERFACES - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd - return $RETVAL + # Start daemons. + echo -n "Starting dhcpd: " + if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then + OPTIONS="${OPTIONS} -chroot ${ROOTDIR}" + fi + daemon /usr/sbin/dhcpd -cf $CONFIGFILE -lf $LEASEFILE $OPTIONS $INTERFACES + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd + return $RETVAL } stop() { - # Stop daemons. - echo -n "Shutting down dhcpd: " - if [ -r ${ROOTDIR}/var/run/dhcpd/dhcpd.pid ]; then - kill -TERM `cat ${ROOTDIR}/var/run/dhcpd/dhcpd.pid` - RETVAL=$? - [ "$RETVAL" = 0 ] && success "stop" || failure "stop" - else - success "already stopped" - RETVAL=0 - fi + # Stop daemons. + echo -n "Shutting down dhcpd: " + if [ -r ${ROOTDIR}/var/run/dhcpd/dhcpd.pid ]; then + kill -TERM `cat ${ROOTDIR}/var/run/dhcpd/dhcpd.pid` + RETVAL=$? + [ "$RETVAL" = 0 ] && success "stop" || failure "stop" + else + success "already stopped" + RETVAL=0 + fi [ $RETVAL -eq 0 ] && rm -f ${ROOTDIR}/var/run/dhcpd/dhcpd.pid - [ $RETVAL = 0 ] && rm -f /var/lock/subsys/dhcpd - echo - return $RETVAL + [ $RETVAL = 0 ] && rm -f /var/lock/subsys/dhcpd + echo + return $RETVAL +} + +configtest() { + /usr/sbin/dhcpd -q -t -cf $CONFIGFILE + RETVAL=$? + if [ $RETVAL -eq 1 ]; then + /usr/sbin/dhcpd -t -cf $CONFIGFILE + else + echo "Syntax: OK" >&2 + fi + return $RETVAL } # See how we were called. case "$1" in - start) - start - ;; - stop) - stop - ;; - restart|reload) - stop - start - RETVAL=$? - ;; - condrestart) - if [ -f /var/lock/subsys/dhcpd ]; then - stop - start - RETVAL=$? - fi - ;; - status) - status dhcpd - RETVAL=$? - ;; - *) - echo "Usage: dhcpd {start|stop|restart|condrestart|status}" - exit 1 + start) + start + ;; + stop) + stop + ;; + restart|reload) + stop + start + RETVAL=$? + ;; + condrestart) + if [ -f /var/lock/subsys/dhcpd ]; then + stop + start + RETVAL=$? + fi + ;; + configtest) + configtest + ;; + status) + status dhcpd + RETVAL=$? + ;; + *) + echo "Usage: dhcpd {start|stop|restart|condrestart|status}" + exit 1 esac exit $RETVAL