summaryrefslogtreecommitdiffstats
path: root/main/dhcp/dhcpd.initd
diff options
context:
space:
mode:
Diffstat (limited to 'main/dhcp/dhcpd.initd')
-rw-r--r--main/dhcp/dhcpd.initd28
1 files changed, 25 insertions, 3 deletions
diff --git a/main/dhcp/dhcpd.initd b/main/dhcp/dhcpd.initd
index cc9727fc7..82cb26e77 100644
--- a/main/dhcp/dhcpd.initd
+++ b/main/dhcp/dhcpd.initd
@@ -1,7 +1,9 @@
#!/sbin/runscript
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/net-misc/dhcp/files/dhcpd.init,v 1.5 2007/04/02 12:34:01 uberlord Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-misc/dhcp/files/dhcpd.init2,v 1.1 2009/07/09 14:45:22 chainsaw Exp $
+
+opts="configtest"
DHCPD_CONF=${DHCPD_CONF:-/etc/dhcp/dhcpd.conf}
@@ -15,6 +17,23 @@ get_var() {
"${DHCPD_CHROOT}/${DHCPD_CONF}"
}
+checkconfig() {
+ /usr/sbin/dhcpd -cf ${DHCPD_CHROOT}/${DHCPD_CONF} -t 1>/dev/null 2>&1
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eerror "${SVCNAME} has detected a syntax error in your configuration files:"
+ /usr/sbin/dhcpd -cf ${DHCPD_CHROOT}/${DHCPD_CONF} -t
+ fi
+
+ return $ret
+}
+
+configtest() {
+ ebegin "Checking ${SVCNAME} configuration"
+ checkconfig
+ eend $?
+}
+
start() {
# Work out our cffile if it's on our DHCPD_OPTS
case " ${DHCPD_OPTS} " in
@@ -32,6 +51,8 @@ start() {
return 1
fi
+ checkconfig || return 1
+
local leasefile="$(get_var lease-file-name)"
leasefile="${DHCPD_CHROOT}/${leasefile:-/var/lib/dhcp/dhcpd.leases}"
if [ ! -f "${leasefile}" ] ; then
@@ -63,10 +84,11 @@ start() {
stop() {
local chroot="$(get_options chroot)"
+
+ checkconfig || return 1
ebegin "Stopping ${chroot:+chrooted }${SVCNAME}"
start-stop-daemon --stop --exec /usr/sbin/dhcpd \
--pidfile "${chroot}/$(get_options pidfile)"
eend $?
}
-