SHA256
1
0
forked from pool/dhcp

Updating link to change in openSUSE:Factory/dhcp revision 33.0

OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=3e128ea1dfe1f438c5c539850885a0ad
This commit is contained in:
OBS User buildservice-autocommit
2010-05-13 22:27:05 +00:00
committed by Git OBS Bridge
parent 9446034797
commit 34a5dc1e28
48 changed files with 2291 additions and 2291 deletions

164
rc.dhcpd
View File

@@ -2,63 +2,70 @@
# Copyright (c) 1996, 1997, 1998 S.u.S.E. GmbH
# Copyright (c) 1998, 1999, 2000, 2001 SuSE GmbH
# Copyright (c) 2002, 2003 SuSE Linux AG
# Copyright (c) 2004-2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# Author: Rolf Haberrecker <rolf@suse.de>, 1997, 1998, 1999
# Peter Poeml <poeml@suse.de>, 2000, 2001, 2002, 2003
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# /etc/init.d/dhcpd
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
#
# Author: Rolf Haberrecker <rolf@suse.de>, 1997-1999
# Peter Poeml <poeml@suse.de>, 2000-2006
# Marius Tomaschewski <mt@suse.de>, 2006-2010
#
# /etc/init.d/dhcp-server
# and its symbolic link
# /usr/sbin/rcdhcpd
# /usr/sbin/rcdhcp-server
#
### BEGIN INIT INFO
# Provides: dhcpd
# Required-Start: $network $remote_fs network-remotefs
# Should-Start: $named $syslog $time ldap ndsd
# Required-Stop: $network $remote_fs network-remotefs
# Should-Stop: $named $syslog ldap ndsd
# Provides: dhcp-server
# Required-Start: $remote_fs $network
# Should-Start: network-remotefs $named $syslog $time ldap ndsd
# Required-Stop: $remote_fs $network
# Should-Stop: network-remotefs $named $syslog ldap ndsd
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: DHCP Server
# Description: Start DHCP (Dynamic Host Configuration Protocol)
# server. (Note: if configured for failover it
# Short-Description: ISC DHCP 4.x Server
# Description: Start ISC DHCP (Dynamic Host Configuration Protocol)
# 4.x series server.
# (Note: if configured for failover it
# needs to rely on time synchronisation.)
### END INIT INFO
test -s /etc/sysconfig/dhcpd && . /etc/sysconfig/dhcpd
if [ -s /etc/sysconfig/dhcpd ]; then
SUPPORTS_CHROOT="yes"
SUPPORTS_RUN_AS="yes"
SUPPORTS_HUP="no"
. /etc/sysconfig/dhcpd
DHCPDv_OPT=-4
test "$SUPPORTS_CHROOT" = no && DHCPD_RUN_CHROOTED=no
test "$SUPPORTS_RUN_AS" = no && DHCPD_RUN_AS=""
test "$DHCPD_BINARY" = "/usr/sbin/dhcpd.lpf" -o \
"$DHCPD_BINARY" = "/usr/sbin/dhcpd.bsd" && \
DHCPD_BINARY=/usr/sbin/dhcpd
else
# pre 8.0
# Source SuSE config
. /etc/rc.config
test -s /etc/rc.config.d/dhcpd.rc.config && \
. /etc/rc.config.d/dhcpd.rc.config
# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}
# Force execution if not called by a runlevel directory.
test $link = $base && START_DHCPD=yes
test "$START_DHCPD" = yes || exit 0
fi
test "$DHCPD_RUN_CHROOTED" = "yes" && CHROOT_PREFIX=/var/lib/dhcp/
DAEMON="DHCP server"
[ "$DHCPD_BINARY" = /usr/sbin/dhcpd.lpf ] && DHCPD_BINARY=/usr/sbin/dhcpd
DAEMON='ISC DHCPv4 4.x Server'
DAEMON_BIN=${DHCPD_BINARY:=/usr/sbin/dhcpd}
DAEMON_CONF=/etc/dhcpd.conf
DAEMON_STATE=/var/lib/dhcp
DAEMON_LEASES=dhcpd.leases
DAEMON_PIDFILE=/var/run/dhcpd.pid
STARTPROC_LOGFILE=/var/log/rc.dhcpd.log
SUPPORTS_HUP="no"
LDAP_CONF=/etc/openldap/ldap.conf
test "$DHCPD_RUN_CHROOTED" = "yes" && \
CHROOT_PREFIX="$DAEMON_STATE" || CHROOT_PREFIX=''
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
@@ -88,11 +95,15 @@ rc_reset
# with force-reload (in case signalling is not supported) are
# considered a success.
if ! [ -x $DAEMON_BIN ]; then
if ! [ -x "$DAEMON_BIN" ]; then
if [ "$1" = "stop" ]; then exit 0; fi
echo >&2 "$0: \"$DAEMON_BIN\" is not an executable file. Exiting."
rc_failed 1
rc_status -v1
rc_exit
exit 5
fi
if ! [ -r "$DAEMON_CONF" ] ; then
if [ "$1" = "stop" ]; then exit 0; fi
echo >&2 "$0: \"$DAEMON_CONF\" config file missed. Exiting."
exit 6
fi
# remove empty pid files to avoid disturbing warnings by checkproc/killproc
@@ -117,7 +128,9 @@ case "$1" in
## If the interfaces are not set, skip starting of dhcpd
## and return with "program not configured"
if [ -z "$DHCPD_INTERFACE" ]; then
echo -n "... set DHCPD_INTERFACE in /etc/sysconfig/dhcpd"
var="DHCPD_INTERFACE"
case $DHCPDv_OPT in -6) var=DHCPD6_INTERFACE ;; esac
echo -n "... set $var in /etc/sysconfig/dhcpd"
# Tell the user this has skipped
rc_status -s
# service is not configured
@@ -128,7 +141,7 @@ case "$1" in
DHCPD_INTERFACE=""
fi
jail=/var/lib/dhcp; leases=dhcpd.leases
jail=${CHROOT_PREFIX:-${DAEMON_STATE}}; leases=$DAEMON_LEASES
if ! [ -e $jail/db/$leases ]; then
# until 9.0, the lease file was in /var/lib/dhcp and part of the package
if test -e $jail/$leases -a '!' -L $jail/$leases; then
@@ -150,7 +163,7 @@ case "$1" in
if test "$DHCPD_RUN_CHROOTED" = "yes" ; then
## copy the conf file to the chroot jail (dhcpd has to be restarted anyway,
## when it has changed) and change path to leases file
for i in $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES $LDAP_CONF; do
for i in $DAEMON_CONF $DHCPD_CONF_INCLUDE_FILES $LDAP_CONF /etc /dev; do
if test -d "${i}" ; then
test -d "$CHROOT_PREFIX/${i}" || \
mkdir -p "$CHROOT_PREFIX/${i}"
@@ -165,18 +178,19 @@ case "$1" in
cp -aL "$i" "${CHROOT_PREFIX}/${i%/*}/" &>/dev/null \
|| { echo "...$0:$LINENO: could not copy $i to chroot jail"; rc_failed; rc_status -v1; exit 6; }
done
libdir=$(basename $(echo /var/lib/dhcp/lib*))
libdir=$(basename $(echo ${CHROOT_PREFIX}/lib*))
if test -x /usr/bin/ldd ; then
get_ldd_deps()
{
ldd_wl="\/${libdir}\/lib"
ldd_bl="\/${libdir}\/libc\."
/usr/bin/ldd "$1" | \
while read -sr a b c d ; do
[ -n "$c" ] || continue
[[ $c =~ $ldd_wl ]] || continue
[[ $c =~ $ldd_bl ]] && continue
echo $c
done < <(/usr/bin/ldd "$1")
done
}
else
get_ldd_deps() { :; }
@@ -191,11 +205,16 @@ case "$1" in
done | sort -u`
for i in $cplibs ; do
if [ -s "$i" ]; then
cp -pL "$i" "/var/lib/dhcp/$libdir/" \
cp -pL "$i" "${CHROOT_PREFIX}/$libdir/" \
|| { echo "...$0:$LINENO: could not copy $i to chroot jail"; rc_failed; rc_status -v1; exit 6; }
fi
fi
done
DHCPD_ARGS="-chroot $CHROOT_PREFIX -lf /db/dhcpd.leases"
# mount /proc into the chroot; the server fails if unable to read /proc/net/{dev,if_inet6}
mkdir -p ${CHROOT_PREFIX}/proc
mount -t proc -o ro proc ${CHROOT_PREFIX}/proc 2>/dev/null
DHCPD_ARGS="-chroot $CHROOT_PREFIX -lf /db/$DAEMON_LEASES"
## If there is a pid file containing a pid, the machine might have crashed. pid files in
## /var/run are always cleaned up at boot time, but this is not the case for the pid file in
@@ -203,26 +222,32 @@ case "$1" in
## incidentally contains the pid of a running process. If this process is not a 'dhcpd',
## we remove the pid. (dhcpd itself only checks whether the pid is alive or not.)
if test -e $CHROOT_PREFIX/$DAEMON_PIDFILE -a -s $CHROOT_PREFIX/$DAEMON_PIDFILE; then
i=$(<$CHROOT_PREFIX/$DAEMON_PIDFILE)
if pidof dhcpd &>/dev/null; then
echo -n "(already running) "
else
p=$(<$CHROOT_PREFIX/$DAEMON_PIDFILE)
if test -n "$p" && grep -qE "^${DAEMON_BIN}" "/proc/$p/cmdline" ; then
echo -n '(already running) '
else
rm $CHROOT_PREFIX/$DAEMON_PIDFILE
fi
fi
else
DHCPD_ARGS="-lf ${DAEMON_STATE}/db/$DAEMON_LEASES"
fi
if [ -n "$DHCPD_RUN_AS" ]; then
DHCPD_RUN_AS_GROUP="$(getent group $(getent passwd $DHCPD_RUN_AS | cut -d: -f4) | cut -d: -f1)"
DHCPD_ARGS="$DHCPD_ARGS -user $DHCPD_RUN_AS -group $DHCPD_RUN_AS_GROUP"
if test "$DHCPD_RUN_CHROOTED" = "yes" ; then
chown "${DHCPD_RUN_AS}:${DHCPD_RUN_AS_GROUP}" \
"$CHROOT_PREFIX/${DAEMON_PIDFILE%/*}"
fi
fi
## check syntax with -t (output to log file) and start only when the syntax is okay
rm -f $STARTPROC_LOGFILE # start log
error=0
if ! $DAEMON_BIN -t -cf $CHROOT_PREFIX/$DAEMON_CONF > $STARTPROC_LOGFILE 2>&1 ; then
if ! $DAEMON_BIN $DHCPDv_OPT -t -cf $CHROOT_PREFIX/$DAEMON_CONF -pf $DAEMON_PIDFILE > $STARTPROC_LOGFILE 2>&1 ; then
error=1
else
## Start daemon. If this fails the return value is set appropriate.
@@ -230,9 +255,9 @@ case "$1" in
## to match the LSB spec.
test "$2" = "-v" && echo -en \
"\nexecuting '$DAEMON_BIN $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE'"
"\nexecuting '$DAEMON_BIN $DHCPDv_OPT -cf $DAEMON_CONF -pf $DAEMON_PIDFILE $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE'"
$DAEMON_BIN $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE &> $STARTPROC_LOGFILE
$DAEMON_BIN $DHCPDv_OPT -cf $DAEMON_CONF -pf $DAEMON_PIDFILE $DHCPD_ARGS $DHCPD_OTHER_ARGS $DHCPD_INTERFACE &> $STARTPROC_LOGFILE
ret=$?
fi
@@ -259,9 +284,10 @@ case "$1" in
kill $(<$CHROOT_PREFIX/$DAEMON_PIDFILE) 2>/dev/null
fi
# remove libraries from the chroot jail, just so they are not left over
# if the server is deinstalled
if [ "$DHCPD_RUN_CHROOTED" = yes ]; then
# umount proc and remove libraries from the chroot jail,
# so they are not left over if the server is deinstalled
if [ "$DHCPD_RUN_CHROOTED" = yes -a -n "$CHROOT_PREFIX" ]; then
umount ${CHROOT_PREFIX}/proc 2>/dev/null
rm -f $CHROOT_PREFIX/lib*/*
fi
@@ -300,8 +326,8 @@ case "$1" in
echo -n "Reload service $DAEMON"
if [ "$SUPPORTS_HUP" = "yes" ]; then
killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_PIDFILE
killproc -p $CHROOT_PREFIX/$DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $CHROOT_PREFIX/$DAEMON_PIDFILE
rc_status -v
else
$0 stop && sleep 3 && $0 start
@@ -315,8 +341,8 @@ case "$1" in
echo -n "Reload service $DAEMON"
if [ "$SUPPORTS_HUP" = "yes" ]; then
# If it supports signalling:
killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $DAEMON_PIDFILE
killproc -p $CHROOT_PREFIX/$DAEMON_PIDFILE -HUP $DAEMON_BIN
#touch $CHROOT_PREFIX/$DAEMON_PIDFILE
rc_status -v
else
## Otherwise if it does not support reload:
@@ -354,10 +380,10 @@ case "$1" in
## this nice bit is from Edwin Groothuis:
## check syntax (quiet)
$DAEMON_BIN -q -t -cf $DAEMON_CONF
$DAEMON_BIN $DHCPDv_OPT -q -t -cf $DAEMON_CONF
if ! [ $? -eq 0 ]; then
## check syntax (verbose)
$DAEMON_BIN -t -cf $DAEMON_CONF
$DAEMON_BIN $DHCPDv_OPT -t -cf $DAEMON_CONF
echo -e '\nConfig is NOT okay\n'
else
echo 'Config is okay. Hope you also specified existent network devices ;) '
@@ -365,10 +391,10 @@ case "$1" in
## in v3, lease file checking is also implemented
if [ $DAEMON_BIN != "/usr/sbin/dhcpd-2" ]; then
## check leases file (quiet)
$DAEMON_BIN -q -T -cf $DAEMON_CONF -lf /var/lib/dhcp/db/dhcpd.leases
$DAEMON_BIN $DHCPDv_OPT -q -T -cf $DAEMON_CONF -lf ${DAEMON_STATE}/db/$DAEMON_LEASES
if ! [ $? -eq 0 ]; then
## check leases file (verbose)
$DAEMON_BIN -T -cf $DAEMON_CONF -lf /var/lib/dhcp/db/dhcpd.leases
$DAEMON_BIN $DHCPDv_OPT -T -cf $DAEMON_CONF -lf ${DAEMON_STATE}/db/$DAEMON_LEASES
echo -e '\nLease file is NOT okay'
else
echo 'Lease file is okay'