2004-09-09 04:10:47 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# dhcpd This shell script takes care of starting and stopping
|
|
|
|
# dhcpd.
|
|
|
|
#
|
|
|
|
# chkconfig: - 65 35
|
|
|
|
# description: dhcpd provide access to Dynamic Host Control Protocol.
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
# Source networking configuration.
|
|
|
|
. /etc/sysconfig/network
|
2004-09-09 04:11:03 +00:00
|
|
|
. /etc/sysconfig/dhcpd
|
2004-09-09 04:10:47 +00:00
|
|
|
|
|
|
|
# Check that networking is up.
|
|
|
|
[ ${NETWORKING} = "no" ] && exit 0
|
|
|
|
|
|
|
|
[ -f /usr/sbin/dhcpd ] || exit 0
|
|
|
|
[ -f /etc/dhcpd.conf ] || exit 0
|
2004-09-22 14:55:33 +00:00
|
|
|
if [ ! -f /var/lib/dhcp/dhcpd.leases ] ; then
|
|
|
|
touch /var/lib/dhcp/dhcpd.leases
|
|
|
|
[ -x /sbin/restorecon ] && [ -d /selinux ] && /sbin/restorecon /var/lib/dhcp/dhcpd.leases
|
|
|
|
fi
|
2004-09-09 04:10:47 +00:00
|
|
|
RETVAL=0
|
2004-09-09 04:10:54 +00:00
|
|
|
prog="dhcpd"
|
2004-09-09 04:10:47 +00:00
|
|
|
|
2004-09-09 04:15:43 +00:00
|
|
|
configtest()
|
|
|
|
{
|
2005-02-11 01:22:10 +00:00
|
|
|
CFA=''
|
|
|
|
if [[ "$DHCPDARGS" = *-cf* ]]; then
|
|
|
|
CFA=`echo $DHCPDARGS | sed 's/^.*-cf[\ \ ]*/-cf/;s/[\ \ ].*$//'`;
|
|
|
|
fi;
|
|
|
|
/usr/sbin/dhcpd -t $CFA
|
2004-09-22 14:55:33 +00:00
|
|
|
return $?
|
2004-09-09 04:15:43 +00:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:10:47 +00:00
|
|
|
start() {
|
|
|
|
# Start daemons.
|
2004-09-09 04:10:54 +00:00
|
|
|
echo -n $"Starting $prog: "
|
2005-02-11 01:22:10 +00:00
|
|
|
daemon /usr/sbin/dhcpd 2>/dev/null
|
2004-09-09 04:10:47 +00:00
|
|
|
RETVAL=$?
|
|
|
|
echo
|
2005-02-11 01:22:10 +00:00
|
|
|
if [ $RETVAL -eq 0 ]; then
|
|
|
|
touch /var/lock/subsys/dhcpd
|
|
|
|
if [ -x /usr/bin/logger ]; then
|
|
|
|
/usr/bin/logger -t dhcpd 'dhcpd startup succeeded'
|
|
|
|
fi;
|
|
|
|
else
|
|
|
|
if [ -x /usr/bin/logger ]; then
|
|
|
|
/usr/bin/logger -t dhcpd 'dhcpd startup failed'
|
|
|
|
fi;
|
|
|
|
fi
|
2004-09-09 04:10:47 +00:00
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
# Stop daemons.
|
2004-09-09 04:10:54 +00:00
|
|
|
echo -n $"Shutting down $prog: "
|
2004-09-09 04:10:47 +00:00
|
|
|
killproc dhcpd
|
|
|
|
RETVAL=$?
|
|
|
|
echo
|
2005-02-11 01:22:10 +00:00
|
|
|
if [ $RETVAL -eq 0 ]; then
|
|
|
|
rm -f /var/lock/subsys/dhcpd
|
|
|
|
if [ -x /usr/bin/logger ]; then
|
|
|
|
/usr/bin/logger -t dhcpd 'dhcpd shutdown succeeded'
|
|
|
|
fi;
|
|
|
|
else
|
|
|
|
if [ -x /usr/bin/logger ]; then
|
|
|
|
/usr/bin/logger -t dhcpd 'dhcpd shutdown failed'
|
|
|
|
fi;
|
|
|
|
fi
|
2004-09-09 04:10:47 +00:00
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart|reload)
|
2004-09-09 04:15:43 +00:00
|
|
|
configtest || exit $?
|
2004-09-09 04:10:47 +00:00
|
|
|
stop
|
|
|
|
start
|
|
|
|
RETVAL=$?
|
|
|
|
;;
|
|
|
|
condrestart)
|
|
|
|
if [ -f /var/lock/subsys/dhcpd ]; then
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
RETVAL=$?
|
|
|
|
fi
|
|
|
|
;;
|
2004-09-09 04:14:53 +00:00
|
|
|
configtest)
|
2004-09-09 04:15:43 +00:00
|
|
|
configtest
|
2004-09-09 04:14:53 +00:00
|
|
|
RETVAL=$?
|
|
|
|
;;
|
2004-09-09 04:10:47 +00:00
|
|
|
status)
|
|
|
|
status dhcpd
|
|
|
|
RETVAL=$?
|
|
|
|
;;
|
|
|
|
*)
|
2004-09-09 04:14:53 +00:00
|
|
|
echo $"Usage: $0 {start|stop|restart|condrestart|configtest|status}"
|
2004-09-09 04:10:47 +00:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|
|
|
|
|