2007-04-26 19:01:43 +00:00
|
|
|
#!/bin/bash
|
2004-09-09 04:10:47 +00:00
|
|
|
#
|
|
|
|
# chkconfig: - 65 35
|
|
|
|
# description: dhcpd provide access to Dynamic Host Control Protocol.
|
|
|
|
|
|
|
|
# Source function library.
|
2007-04-26 19:01:43 +00:00
|
|
|
. /etc/init.d/functions
|
2004-09-09 04:10:47 +00:00
|
|
|
|
2007-04-26 19:01:43 +00:00
|
|
|
RETVAL=0
|
|
|
|
prog=dhcpd
|
|
|
|
dhcpd=/usr/sbin/dhcpd
|
|
|
|
lockfile=/var/lock/subsys/dhcpd
|
2004-09-09 04:10:47 +00:00
|
|
|
|
2007-04-26 19:01:43 +00:00
|
|
|
. /etc/sysconfig/dhcpd
|
2005-11-15 17:11:05 +00:00
|
|
|
|
2007-04-26 19:01:43 +00:00
|
|
|
cfOption() {
|
|
|
|
let i=0
|
|
|
|
for a in $* ; do
|
|
|
|
((++i))
|
|
|
|
if [ $a = -cf ]; then
|
|
|
|
((++i))
|
|
|
|
eval 'echo $'$i
|
|
|
|
elif [[ $a = -cf* ]]; then
|
|
|
|
echo ${a#-cf}
|
|
|
|
fi
|
|
|
|
done
|
2005-11-15 17:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CF=`cfOption $DHCPDARGS`
|
|
|
|
if [ -z "$CF" ]; then
|
2007-04-26 19:01:43 +00:00
|
|
|
CF='/etc/dhcpd.conf'
|
2005-11-15 17:11:05 +00:00
|
|
|
fi
|
|
|
|
|
2005-02-16 00:51:18 +00:00
|
|
|
[ -f "$CF" ] || exit 0
|
2007-04-26 19:01:43 +00:00
|
|
|
|
2005-11-15 17:11:05 +00:00
|
|
|
if [ ! -f /var/lib/dhcpd/dhcpd.leases ] ; then
|
2007-04-26 19:01:43 +00:00
|
|
|
mkdir -p /var/lib/dhcpd
|
|
|
|
touch /var/lib/dhcpd/dhcpd.leases
|
|
|
|
[ -x /sbin/restorecon ] && [ -d /selinux ] && /sbin/restorecon /var/lib/dhcp/dhcpd.leases >/dev/null 2>&1
|
2004-09-22 14:55:33 +00:00
|
|
|
fi
|
2005-11-15 17:11:05 +00:00
|
|
|
|
2007-04-26 19:01:43 +00:00
|
|
|
configtest() {
|
|
|
|
[ -x $dhcpd ] || return 5
|
|
|
|
[ -f $CF ] || return 6
|
|
|
|
$dhcpd -q -t -cf $CF
|
|
|
|
RETVAL=$?
|
|
|
|
return $RETVAL
|
2004-09-09 04:15:43 +00:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:10:47 +00:00
|
|
|
start() {
|
2007-04-26 19:01:43 +00:00
|
|
|
[ -x $dhcpd ] || return 5
|
|
|
|
[ -f $CF ] || return 6
|
|
|
|
echo -n $"Starting $prog: "
|
|
|
|
daemon $dhcpd $DHCPDARGS 2>/dev/null
|
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL = 0 ] && touch $lockfile
|
|
|
|
return $RETVAL
|
2004-09-09 04:10:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2007-04-26 19:01:43 +00:00
|
|
|
echo -n $"Shutting down $prog: "
|
|
|
|
killproc $prog -TERM
|
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL = 0 ] && rm -f $lockfile
|
|
|
|
return $RETVAL
|
2004-09-09 04:10:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
2007-04-26 19:01:43 +00:00
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
RETVAL=3
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
configtest || exit $?
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
condrestart)
|
|
|
|
if [ -f $lockfile ]; then
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
configtest|check|testconfig|test)
|
|
|
|
configtest
|
|
|
|
RETVAL=$?
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
status $prog
|
|
|
|
RETVAL=$?
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo $"Usage: $0 {start|stop|restart|condrestart|configtest|status}"
|
|
|
|
RETVAL=3
|
|
|
|
;;
|
2004-09-09 04:10:47 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|