diff --git a/dhcp.spec b/dhcp.spec index 4e4567d..36246e5 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -13,7 +13,7 @@ Summary: Dynamic host configuration protocol software Name: dhcp Version: %{basever}p1 -Release: 10%{?dist} +Release: 11%{?dist} # NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to # dcantrell maintaining the package) made incorrect use of the epoch and # that's why it is at 12 now. It should have never been used, but it was. @@ -481,6 +481,9 @@ fi %attr(0644,root,root) %{_mandir}/man3/omapi.3.gz %changelog +* Thu Sep 24 2009 Jiri Popelka - 12:4.1.0p1-11 +- Make dhcpd and dhcrelay init scripts LSB compliant (#522134, #522146) + * Mon Sep 21 2009 David Cantrell - 12:4.1.0p1-10 - Obsolete the dhcpv6 and dhcpv6-client packages diff --git a/dhcpd.init b/dhcpd.init index 02977c9..ad1e04b 100644 --- a/dhcpd.init +++ b/dhcpd.init @@ -22,12 +22,12 @@ # config: /var/lib/dhcpd/dhcpd.leases # pidfile: /var/run/dhcpd.pid -. /etc/init.d/functions +. /etc/rc.d/init.d/functions RETVAL=0 prog=dhcpd -dhcpd=/usr/sbin/dhcpd +exec=/usr/sbin/dhcpd lockfile=/var/lock/subsys/dhcpd pidfile=/var/run/dhcpd.pid statedir=/var/lib/dhcpd @@ -49,7 +49,7 @@ findConfig() { echo "/etc/dhcp/dhcpd.conf" } -conf="$(findConfig "$DHCPDARGS")" +config="$(findConfig "$DHCPDARGS")" if [ ! -f $statedir/dhcpd.leases ] ; then mkdir -p $statedir @@ -58,12 +58,12 @@ if [ ! -f $statedir/dhcpd.leases ] ; then fi configtest() { - [ -x $dhcpd ] || return 5 - [ -f $conf ] || return 6 - $dhcpd -q -t -cf $conf + [ -x $exec ] || return 5 + [ -f $config ] || return 6 + $exec -q -t -cf $config RETVAL=$? if [ $RETVAL -eq 1 ]; then - $dhcpd -t -cf $conf + $exec -t -cf $config else echo "Syntax: OK" >&2 fi @@ -71,37 +71,44 @@ configtest() { } start() { - [ -x $dhcpd ] || return 5 - [ -f $conf ] || return 6 + [ `id -u` -eq 0 ] || return 4 + [ -x $exec ] || return 5 + [ -f $config ] || return 6 pidofproc $prog >/dev/null 2>&1 RETVAL=$? [ $RETVAL -eq 0 ] && return $RETVAL echo -n $"Starting $prog: " - daemon $dhcpd $DHCPDARGS 2>/dev/null + daemon $exec $DHCPDARGS 2>/dev/null RETVAL=$? echo - [ $RETVAL = 0 ] && touch $lockfile + [ $RETVAL -eq 0 ] && touch $lockfile return $RETVAL } stop() { + [ `id -u` -eq 0 ] || return 4 + pidofproc $prog >/dev/null 2>&1 if [ $? -ne 0 ]; then - RETVAL=7 + RETVAL=0 return $RETVAL fi - + echo -n $"Shutting down $prog: " killproc $prog RETVAL=$? echo - [ $RETVAL = 0 ] && rm -f $lockfile + [ $RETVAL -eq 0 ] && rm -f $lockfile return $RETVAL } +usage() { + echo $"Usage: $0 {start|stop|restart|force-reload|condrestart|try-restart|configtest|status}" +} + if [ $# -gt 1 ]; then RETVAL=2 exit $RETVAL @@ -120,23 +127,28 @@ case "$1" in stop ; start RETVAL=$? ;; - condrestart) + condrestart|try-restart) if [ -f $lockfile ]; then stop ; start RETVAL=$? fi ;; + reload) + usage + # unimplemented feature + RETVAL=3 + ;; configtest) configtest RETVAL=$? ;; status) - status $dhcpd + status $exec RETVAL=$? ;; *) - echo $"Usage: $0 {start|stop|restart|condrestart|configtest|status}" - RETVAL=3 + usage + RETVAL=2 ;; esac diff --git a/dhcrelay.init b/dhcrelay.init index 78c3c93..41e8feb 100644 --- a/dhcrelay.init +++ b/dhcrelay.init @@ -20,15 +20,15 @@ # processname: dhcrelay # # pidfile: /var/run/dhcrelay.pid -. /etc/init.d/functions +. /etc/rc.d/init.d/functions RETVAL=0 prog=dhcrelay -dhcrelay=/usr/sbin/dhcrelay +exec=/usr/sbin/dhcrelay lockfile=/var/lock/subsys/dhcrelay pidfile=/var/run/dhcrelay.pid -conf=/etc/sysconfig/dhcrelay +config=/etc/sysconfig/dhcrelay # The dhcrelay daemon uses the sysconfig file for configuration information. # There is no native configuration file for this program and you must specify @@ -36,23 +36,24 @@ conf=/etc/sysconfig/dhcrelay [ -f /etc/sysconfig/dhcrelay ] && . /etc/sysconfig/dhcrelay configtest() { - [ -x $dhcrelay ] || exit 5 - [ -f $conf ] || exit 6 + [ -x $exec ] || exit 5 + [ -f $config ] || exit 6 [ -z "$DHCPSERVERS" ] && exit 6 RETVAL=0 return $RETVAL } start() { - [ -x $dhcrelay ] || exit 5 - [ -f $conf ] || exit 6 + [ `id -u` -eq 0 ] || exit 4 + [ -x $exec ] || exit 5 + [ -f $config ] || exit 6 pidofproc $prog >/dev/null 2>&1 RETVAL=$? [ $RETVAL -eq 0 ] && return $RETVAL echo -n $"Starting $prog: " - daemon $dhcrelay $([ -n "$INTERFACES" ] && for int in $INTERFACES ; do echo -n " -i $int" ; done) $DHCPSERVERS 2>/dev/null + daemon $exec $([ -n "$INTERFACES" ] && for int in $INTERFACES ; do echo -n " -i $int" ; done) $DHCPSERVERS 2>/dev/null RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $lockfile @@ -60,9 +61,11 @@ start() { } stop() { + [ `id -u` -eq 0 ] || exit 4 + pidofproc $prog >/dev/null 2>&1 if [ $? -ne 0 ]; then - RETVAL=7 + RETVAL=0 return $RETVAL fi @@ -71,11 +74,17 @@ stop() { RETVAL=$? echo - [ $RETVAL = 0 ] && rm -f $lockfile + [ $RETVAL -eq 0 ] && rm -f $lockfile + # killproc -TERM doesn't remove pidfile, remove it manually + [ $RETVAL -eq 0 ] && rm -f $pidfile return $RETVAL } -if [ ! -x $dhcrelay ]; then +usage() { + echo $"Usage: $0 {start|stop|restart|force-reload|condrestart|try-restart|configtest|status}" +} + +if [ ! -x $exec ]; then RETVAL=5 exit $RETVAL fi @@ -98,12 +107,17 @@ case "$1" in stop && start RETVAL=$? ;; - condrestart) + condrestart|try-restart) if [ -f $lockfile ]; then stop && start RETVAL=$? fi ;; + reload) + usage + # unimplemented feature + RETVAL=3 + ;; configtest) configtest RETVAL=$? @@ -113,8 +127,8 @@ case "$1" in RETVAL=$? ;; *) - echo $"Usage: $0 {start|stop|restart|condrestart|configtest|status}" - RETVAL=3 + usage + RETVAL=2 ;; esac