- Make dhcpd and dhcrelay init scripts LSB compliant (#522134, #522146)

This commit is contained in:
Jiří Popelka 2009-09-24 09:29:34 +00:00
parent 043ad2a7a6
commit e648291901
3 changed files with 62 additions and 33 deletions

View File

@ -13,7 +13,7 @@
Summary: Dynamic host configuration protocol software Summary: Dynamic host configuration protocol software
Name: dhcp Name: dhcp
Version: %{basever}p1 Version: %{basever}p1
Release: 10%{?dist} Release: 11%{?dist}
# NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to # NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to
# dcantrell maintaining the package) made incorrect use of the epoch and # 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. # 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 %attr(0644,root,root) %{_mandir}/man3/omapi.3.gz
%changelog %changelog
* Thu Sep 24 2009 Jiri Popelka <jpopelka@redhat.com> - 12:4.1.0p1-11
- Make dhcpd and dhcrelay init scripts LSB compliant (#522134, #522146)
* Mon Sep 21 2009 David Cantrell <dcantrell@redhat.com> - 12:4.1.0p1-10 * Mon Sep 21 2009 David Cantrell <dcantrell@redhat.com> - 12:4.1.0p1-10
- Obsolete the dhcpv6 and dhcpv6-client packages - Obsolete the dhcpv6 and dhcpv6-client packages

View File

@ -22,12 +22,12 @@
# config: /var/lib/dhcpd/dhcpd.leases # config: /var/lib/dhcpd/dhcpd.leases
# pidfile: /var/run/dhcpd.pid # pidfile: /var/run/dhcpd.pid
. /etc/init.d/functions . /etc/rc.d/init.d/functions
RETVAL=0 RETVAL=0
prog=dhcpd prog=dhcpd
dhcpd=/usr/sbin/dhcpd exec=/usr/sbin/dhcpd
lockfile=/var/lock/subsys/dhcpd lockfile=/var/lock/subsys/dhcpd
pidfile=/var/run/dhcpd.pid pidfile=/var/run/dhcpd.pid
statedir=/var/lib/dhcpd statedir=/var/lib/dhcpd
@ -49,7 +49,7 @@ findConfig() {
echo "/etc/dhcp/dhcpd.conf" echo "/etc/dhcp/dhcpd.conf"
} }
conf="$(findConfig "$DHCPDARGS")" config="$(findConfig "$DHCPDARGS")"
if [ ! -f $statedir/dhcpd.leases ] ; then if [ ! -f $statedir/dhcpd.leases ] ; then
mkdir -p $statedir mkdir -p $statedir
@ -58,12 +58,12 @@ if [ ! -f $statedir/dhcpd.leases ] ; then
fi fi
configtest() { configtest() {
[ -x $dhcpd ] || return 5 [ -x $exec ] || return 5
[ -f $conf ] || return 6 [ -f $config ] || return 6
$dhcpd -q -t -cf $conf $exec -q -t -cf $config
RETVAL=$? RETVAL=$?
if [ $RETVAL -eq 1 ]; then if [ $RETVAL -eq 1 ]; then
$dhcpd -t -cf $conf $exec -t -cf $config
else else
echo "Syntax: OK" >&2 echo "Syntax: OK" >&2
fi fi
@ -71,25 +71,28 @@ configtest() {
} }
start() { start() {
[ -x $dhcpd ] || return 5 [ `id -u` -eq 0 ] || return 4
[ -f $conf ] || return 6 [ -x $exec ] || return 5
[ -f $config ] || return 6
pidofproc $prog >/dev/null 2>&1 pidofproc $prog >/dev/null 2>&1
RETVAL=$? RETVAL=$?
[ $RETVAL -eq 0 ] && return $RETVAL [ $RETVAL -eq 0 ] && return $RETVAL
echo -n $"Starting $prog: " echo -n $"Starting $prog: "
daemon $dhcpd $DHCPDARGS 2>/dev/null daemon $exec $DHCPDARGS 2>/dev/null
RETVAL=$? RETVAL=$?
echo echo
[ $RETVAL = 0 ] && touch $lockfile [ $RETVAL -eq 0 ] && touch $lockfile
return $RETVAL return $RETVAL
} }
stop() { stop() {
[ `id -u` -eq 0 ] || return 4
pidofproc $prog >/dev/null 2>&1 pidofproc $prog >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
RETVAL=7 RETVAL=0
return $RETVAL return $RETVAL
fi fi
@ -98,10 +101,14 @@ stop() {
RETVAL=$? RETVAL=$?
echo echo
[ $RETVAL = 0 ] && rm -f $lockfile [ $RETVAL -eq 0 ] && rm -f $lockfile
return $RETVAL return $RETVAL
} }
usage() {
echo $"Usage: $0 {start|stop|restart|force-reload|condrestart|try-restart|configtest|status}"
}
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then
RETVAL=2 RETVAL=2
exit $RETVAL exit $RETVAL
@ -120,23 +127,28 @@ case "$1" in
stop ; start stop ; start
RETVAL=$? RETVAL=$?
;; ;;
condrestart) condrestart|try-restart)
if [ -f $lockfile ]; then if [ -f $lockfile ]; then
stop ; start stop ; start
RETVAL=$? RETVAL=$?
fi fi
;; ;;
reload)
usage
# unimplemented feature
RETVAL=3
;;
configtest) configtest)
configtest configtest
RETVAL=$? RETVAL=$?
;; ;;
status) status)
status $dhcpd status $exec
RETVAL=$? RETVAL=$?
;; ;;
*) *)
echo $"Usage: $0 {start|stop|restart|condrestart|configtest|status}" usage
RETVAL=3 RETVAL=2
;; ;;
esac esac

View File

@ -20,15 +20,15 @@
# processname: dhcrelay # processname: dhcrelay
# # pidfile: /var/run/dhcrelay.pid # # pidfile: /var/run/dhcrelay.pid
. /etc/init.d/functions . /etc/rc.d/init.d/functions
RETVAL=0 RETVAL=0
prog=dhcrelay prog=dhcrelay
dhcrelay=/usr/sbin/dhcrelay exec=/usr/sbin/dhcrelay
lockfile=/var/lock/subsys/dhcrelay lockfile=/var/lock/subsys/dhcrelay
pidfile=/var/run/dhcrelay.pid pidfile=/var/run/dhcrelay.pid
conf=/etc/sysconfig/dhcrelay config=/etc/sysconfig/dhcrelay
# The dhcrelay daemon uses the sysconfig file for configuration information. # The dhcrelay daemon uses the sysconfig file for configuration information.
# There is no native configuration file for this program and you must specify # 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 [ -f /etc/sysconfig/dhcrelay ] && . /etc/sysconfig/dhcrelay
configtest() { configtest() {
[ -x $dhcrelay ] || exit 5 [ -x $exec ] || exit 5
[ -f $conf ] || exit 6 [ -f $config ] || exit 6
[ -z "$DHCPSERVERS" ] && exit 6 [ -z "$DHCPSERVERS" ] && exit 6
RETVAL=0 RETVAL=0
return $RETVAL return $RETVAL
} }
start() { start() {
[ -x $dhcrelay ] || exit 5 [ `id -u` -eq 0 ] || exit 4
[ -f $conf ] || exit 6 [ -x $exec ] || exit 5
[ -f $config ] || exit 6
pidofproc $prog >/dev/null 2>&1 pidofproc $prog >/dev/null 2>&1
RETVAL=$? RETVAL=$?
[ $RETVAL -eq 0 ] && return $RETVAL [ $RETVAL -eq 0 ] && return $RETVAL
echo -n $"Starting $prog: " 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=$? RETVAL=$?
echo echo
[ $RETVAL -eq 0 ] && touch $lockfile [ $RETVAL -eq 0 ] && touch $lockfile
@ -60,9 +61,11 @@ start() {
} }
stop() { stop() {
[ `id -u` -eq 0 ] || exit 4
pidofproc $prog >/dev/null 2>&1 pidofproc $prog >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
RETVAL=7 RETVAL=0
return $RETVAL return $RETVAL
fi fi
@ -71,11 +74,17 @@ stop() {
RETVAL=$? RETVAL=$?
echo 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 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 RETVAL=5
exit $RETVAL exit $RETVAL
fi fi
@ -98,12 +107,17 @@ case "$1" in
stop && start stop && start
RETVAL=$? RETVAL=$?
;; ;;
condrestart) condrestart|try-restart)
if [ -f $lockfile ]; then if [ -f $lockfile ]; then
stop && start stop && start
RETVAL=$? RETVAL=$?
fi fi
;; ;;
reload)
usage
# unimplemented feature
RETVAL=3
;;
configtest) configtest)
configtest configtest
RETVAL=$? RETVAL=$?
@ -113,8 +127,8 @@ case "$1" in
RETVAL=$? RETVAL=$?
;; ;;
*) *)
echo $"Usage: $0 {start|stop|restart|condrestart|configtest|status}" usage
RETVAL=3 RETVAL=2
;; ;;
esac esac