packages: dhcp/dhcp6.init - sync with dhcp.init
glen
glen at pld-linux.org
Thu Nov 19 21:25:15 CET 2009
Author: glen Date: Thu Nov 19 20:25:15 2009 GMT
Module: packages Tag: HEAD
---- Log message:
- sync with dhcp.init
---- Files affected:
packages/dhcp:
dhcp6.init (1.3 -> 1.4)
---- Diffs:
================================================================
Index: packages/dhcp/dhcp6.init
diff -u packages/dhcp/dhcp6.init:1.3 packages/dhcp/dhcp6.init:1.4
--- packages/dhcp/dhcp6.init:1.3 Wed Dec 3 02:10:58 2008
+++ packages/dhcp/dhcp6.init Thu Nov 19 21:25:10 2009
@@ -23,78 +23,123 @@
exit 0
fi
-checkconfig() {
- show "Checking %s configuration" "DHCP IPv6 Server"
- out=`/sbin/dhcpd -t 2>&1`; rc=$?
- if [ $rc -gt 0 ]; then
- fail
- echo >&2 "$out"
+check_device_up()
+{
+ local DEVICE=$1
+ if LC_ALL=C ip addr show dev $DEVICE | grep -q inet6; then
+ return 0
else
- ok
+ return 1
fi
+}
+
+# configtest itself
+configtest() {
+ local rc=0
+ /sbin/dhcpd -6 -q -t -T || rc=$?
+
+ # check if interfaces specified exist and have addresses
+ for i in $DHCPD_INTERFACES; do
+ if ! check_device_up $i; then
+ echo >&2 "Device '$i' does not exist or has no address configured"
+ rc=1
+ fi
+ done
+
return $rc
}
-start() {
- # Check if the service is already running?
- if [ ! -f /var/lock/subsys/dhcpd6 ]; then
- msg_starting "DHCP IPv6 Server"
- daemon /sbin/dhcpd -6 $DHCPD_INTERFACES
+# wrapper for configtest
+checkconfig() {
+ local details=${1:-0}
+
+ if [ $details = 1 ]; then
+ # run config test and display report (status action)
+ show "Checking %s configuration" "DHCP IPv6 Server"; busy
+ local out
+ out=$(configtest 2>&1)
RETVAL=$?
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd6
+ if [ $RETVAL = 0 ]; then
+ ok
+ else
+ fail
+ fi
+ [ "$out" ] && echo >&2 "$out"
else
+ # run config test and abort with nice message if failed
+ # (for actions checking status before action).
+ configtest >/dev/null 2>&1
+ RETVAL=$?
+ if [ $RETVAL != 0 ]; then
+ show "Checking %s configuration" "DHCP IPv6 Server"; fail
+ nls 'Configuration test failed. See details with %s "checkconfig"' $0
+ exit $RETVAL
+ fi
+ fi
+}
+
+start() {
+ # Check if the service is already running?
+ if [ -f /var/lock/subsys/dhcpd ]; then
msg_already_running "DHCP IPv6 Server"
+ return
fi
+
+ checkconfig
+ msg_starting "DHCP IPv6 Server"
+ daemon /sbin/dhcpd -6 -q $DHCPD_INTERFACES
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd
}
stop() {
- if [ -f /var/lock/subsys/dhcpd6 ]; then
- msg_stopping "DHCP IPv6 Server"
- killproc dhcpd
- rm -f /var/run/dhcpd.pid /var/lock/subsys/dhcpd6 >/dev/null 2>&1
- else
+ if [ ! -f /var/lock/subsys/dhcpd ]; then
msg_not_running "DHCP IPv6 Server"
+ return
fi
+
+ msg_stopping "DHCP IPv6 Server"
+ killproc --pidfile /var/run/dhcpd6.pid dhcpd
+ rm -f /var/run/dhcpd6.pid /var/lock/subsys/dhcpd >/dev/null 2>&1
}
condrestart() {
- if [ -f /var/lock/subsys/dhcpd6 ]; then
- stop
- start
- else
- msg_not_running dhcpd
+ if [ ! -f /var/lock/subsys/dhcpd ]; then
+ msg_not_running "DHCP IPv6 Server"
RETVAL=$1
+ return
fi
+
+ checkconfig
+ stop
+ start
}
RETVAL=0
# See how we were called.
case "$1" in
start)
- checkconfig || exit 1
start
;;
stop)
stop
;;
restart)
- checkconfig || exit 1
+ checkconfig
stop
start
;;
try-restart)
- checkconfig || exit 1
condrestart 0
;;
force-reload)
- checkconfig || exit 1
condrestart 7
;;
- checkconfig)
- checkconfig
+ checkconfig|configtest)
+ checkconfig 1
;;
status)
- status dhcpd
+ status --pidfile /var/run/dhcpd6.pid dhcpd
exit $?
;;
*)
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/dhcp/dhcp6.init?r1=1.3&r2=1.4&f=u
More information about the pld-cvs-commit
mailing list