- Added init script to also start dhcpd for IPv6 (#552453)

- Added dhcpd6.conf.sample
This commit is contained in:
Jiří Popelka 2010-01-15 12:52:28 +00:00
parent 606ac5674b
commit 9c63bd9d6e
5 changed files with 248 additions and 60 deletions

View File

@ -13,7 +13,7 @@
Summary: Dynamic host configuration protocol software
Name: dhcp
Version: %{basever}p1
Release: 16%{?dist}
Release: 17%{?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.
@ -30,6 +30,8 @@ Source4: dhclient-script
Source5: README.dhclient.d
Source6: 10-dhclient
Source7: 56dhclient
Source8: dhcpd6.init
Source9: dhcpd6.conf.sample
Patch0: %{name}-4.1.0-errwarn-message.patch
Patch1: %{name}-4.1.0-memory.patch
@ -226,6 +228,9 @@ libdhcpctl and libomapi static libraries are also included in this package.
# Copy in documentation and example scripts for LDAP patch to dhcpd
%{__install} -p -m 0755 ldap-for-dhcp-%{ldappatchver}/dhcpd-conf-to-ldap contrib/
# Copy in dhcpd6.conf.sample
%{__install} -p -m 0644 %{SOURCE9} .
# Copy in the Fedora/RHEL dhclient script
%{__install} -p -m 0755 %{SOURCE4} client/scripts/linux
%{__install} -p -m 0644 %{SOURCE5} .
@ -314,6 +319,7 @@ CFLAGS="%{optflags} -fPIC -D_GNU_SOURCE" \
# Install init scripts
%{__mkdir} -p %{buildroot}%{_initrddir}
%{__install} -p -m 0755 %{SOURCE2} %{buildroot}%{_initrddir}/dhcpd
%{__install} -p -m 0755 %{SOURCE8} %{buildroot}%{_initrddir}/dhcpd6
%{__install} -p -m 0755 %{SOURCE3} %{buildroot}%{_initrddir}/dhcrelay
# Start empty lease databases
@ -336,11 +342,16 @@ EOF
DHCPDARGS=
EOF
%{__cat} <<EOF > %{buildroot}%{_sysconfdir}/sysconfig/dhcpd6
# Command line options here
DHCPDARGS=
EOF
# Copy sample conf files into position (called by doc macro)
%{__cp} -p client/dhclient.conf dhclient.conf.sample
%{__cp} -p server/dhcpd.conf dhcpd.conf.sample
# Install default (empty) dhcpd.conf:
# Install default (empty) dhcpd.conf and dhcpd6.conf:
%{__mkdir} -p %{buildroot}%{dhcpconfdir}
%{__cat} << EOF > %{buildroot}%{dhcpconfdir}/dhcpd.conf
#
@ -350,6 +361,15 @@ EOF
#
EOF
%{__cat} << EOF > %{buildroot}%{dhcpconfdir}/dhcpd6.conf
#
# DHCP for IPv6 Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd6.conf.sample
# see 'man 5 dhcpd.conf'
# run 'service dhcpd6 start' or 'dhcpd -6 -cf /etc/dhcp/dhcpd6.conf'
#
EOF
# Install dhcp.schema for LDAP configuration
%{__mkdir} -p %{buildroot}%{_sysconfdir}/openldap/schema
%{__install} -p -m 0644 -D ldap-for-dhcp-%{ldappatchver}/dhcp.schema \
@ -389,6 +409,7 @@ if [ ! -z "${prevconf}" ]; then
fi
/sbin/chkconfig --add dhcpd
/sbin/chkconfig --add dhcpd6
/sbin/chkconfig --add dhcrelay || :
%post -n dhclient
@ -414,38 +435,48 @@ if [ $1 = 0 ]; then
/sbin/service dhcpd stop >/dev/null 2>&1
fi
/sbin/service dhcpd6 status >/dev/null 2>&1
if [ $? = 3 ]; then
/sbin/service dhcpd6 stop >/dev/null 2>&1
fi
/sbin/service dhcrelay status >/dev/null 2>&1
if [ $? = 3 ]; then
/sbin/service dhcrelay stop >/dev/null 2>&1
fi
/sbin/chkconfig --del dhcpd
/sbin/chkconfig --del dhcpd6
/sbin/chkconfig --del dhcrelay || :
fi
%postun
if [ $1 -ge 1 ]; then
/sbin/service dhcpd condrestart >/dev/null 2>&1
/sbin/service dhcpd6 condrestart >/dev/null 2>&1
/sbin/service dhcrelay condrestart >/dev/null 2>&1 || :
fi
%files
%defattr(-,root,root,-)
%doc LICENSE README ldap-for-dhcp-%{ldappatchver}/README.ldap
%doc RELNOTES dhcpd.conf.sample doc/IANA-arp-parameters doc/api+protocol
%doc RELNOTES dhcpd.conf.sample dhcpd6.conf.sample doc/IANA-arp-parameters doc/api+protocol
%doc doc/*.txt __fedora_contrib/* ldap-for-dhcp-%{ldappatchver}/*.txt
%dir %{_localstatedir}/lib/dhcpd
%attr(0750,root,root) %dir %{dhcpconfdir}
%verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/dhcpd/dhcpd.leases
%verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/dhcpd/dhcpd6.leases
%config(noreplace) %{_sysconfdir}/sysconfig/dhcpd
%config(noreplace) %{_sysconfdir}/sysconfig/dhcpd6
%config(noreplace) %{_sysconfdir}/sysconfig/dhcrelay
%config(noreplace) %{dhcpconfdir}/dhcpd.conf
%config(noreplace) %{dhcpconfdir}/dhcpd6.conf
%config(noreplace) %{_sysconfdir}/openldap/schema/dhcp.schema
%dir %{_sysconfdir}/NetworkManager
%dir %{_sysconfdir}/NetworkManager/dispatcher.d
%{_sysconfdir}/NetworkManager/dispatcher.d/10-dhclient
%{_initrddir}/dhcpd
%{_initrddir}/dhcpd6
%{_initrddir}/dhcrelay
%{_bindir}/omshell
%{_sbindir}/dhcpd
@ -486,6 +517,10 @@ fi
%attr(0644,root,root) %{_mandir}/man3/omapi.3.gz
%changelog
* Fri Jan 15 2010 Jiri Popelka <jpopelka@redhat.com> - 12:4.1.0p1-17
- Added init script to also start dhcpd for IPv6 (#552453)
- Added dhcpd6.conf.sample
* Thu Jan 07 2010 Jiri Popelka <jpopelka@redhat.com> - 12:4.1.0p1-16
- Use %%global instead of %%define.

View File

@ -70,18 +70,25 @@ configtest() {
return $RETVAL
}
rh_status() {
status -p $pidfile -l $(basename $lockfile) $exec
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
start() {
[ `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
rh_status_q && return 0
echo -n $"Starting $prog: "
daemon $exec $DHCPDARGS 2>/dev/null
daemon --pidfile=$pidfile $exec $DHCPDARGS 2>/dev/null
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $lockfile
return $RETVAL
@ -90,14 +97,10 @@ start() {
stop() {
[ `id -u` -eq 0 ] || return 4
pidofproc $prog >/dev/null 2>&1
if [ $? -ne 0 ]; then
RETVAL=0
return $RETVAL
fi
rh_status_q || return 0
echo -n $"Shutting down $prog: "
killproc $prog
killproc -p $pidfile $prog
RETVAL=$?
echo
@ -110,46 +113,38 @@ usage() {
}
if [ $# -gt 1 ]; then
RETVAL=2
exit $RETVAL
exit 2
fi
case "$1" in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
restart|force-reload)
stop ; start
RETVAL=$?
;;
condrestart|try-restart)
if [ -f $lockfile ]; then
rh_status_q || exit 0
stop ; start
RETVAL=$?
fi
;;
reload)
usage
# unimplemented feature
RETVAL=3
exit 3
;;
configtest)
configtest
RETVAL=$?
;;
status)
status $exec
RETVAL=$?
rh_status
;;
*)
usage
RETVAL=2
exit 2
;;
esac
exit $RETVAL
exit $?

17
dhcpd6.conf.sample Normal file
View File

@ -0,0 +1,17 @@
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet6 2001:db8:0:1::/64 {
# Range for clients
range6 2001:db8:0:1::129 2001:db8:0:1::254;
# Additional options
option dhcp6.name-servers fec0:0:0:1::1;
option dhcp6.domain-search "domain.example";
# Prefix range for delegation to sub-routers
prefix6 2001:db8:0:100:: 2001:db8:0:f00:: /56;
# Example for a fixed host address
host specialclient {
host-identifier option dhcp6.client-id 00:01:00:01:4a:1f:ba:e3:60:b9:1f:01:23:45;
fixed-address6 2001:db8:0:1::127;
}
}

153
dhcpd6.init Executable file
View File

@ -0,0 +1,153 @@
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: dhcpd
# Default-Start:
# Default-Stop:
# Should-Start:
# Required-Start: $network
# Required-Stop:
# Short-Description: Start and stop the DHCPv6 server
# Description: dhcpd provides the Dynamic Host Configuration Protocol (DHCPv6)
# server.
### END INIT INFO
#
# The fields below are left around for legacy tools (will remove later).
#
# chkconfig: - 65 35
# description: dhcpd provides the Dynamic Host Configuration Protocol (DHCPv6) \
# server
# processname: dhcpd
# config: /etc/dhcp/dhcpd6.conf
# config: /var/lib/dhcpd/dhcpd6.leases
# pidfile: /var/run/dhcpd6.pid
. /etc/rc.d/init.d/functions
RETVAL=0
prog=dhcpd
exec=/usr/sbin/dhcpd
lockfile=/var/lock/subsys/dhcpd6
pidfile=/var/run/dhcpd6.pid
statedir=/var/lib/dhcpd
default_config=/etc/dhcp/dhcpd6.conf
[ -f /etc/sysconfig/dhcpd6 ] && . /etc/sysconfig/dhcpd6
# if the user specified a different config file, make sure we reference it
findConfig() {
for arg in $DHCPDARGS ; do
if [ "$found" = 1 ]; then
[ -f "$arg" ] && echo "$arg"
return
fi
if [ "$arg" = "-cf" ]; then
found=1
continue
fi
done
echo $default_config
}
config="$(findConfig "$DHCPDARGS")"
if [ ! -f $statedir/dhcpd6.leases ] ; then
mkdir -p $statedir
touch $statedir/dhcpd6.leases
[ -x /sbin/restorecon ] && [ -d /selinux ] && /sbin/restorecon $statedir/dhcpd6.leases >/dev/null 2>&1
fi
configtest() {
[ -x $exec ] || return 5
[ -f $config ] || return 6
$exec -q -t -6 -cf $config
RETVAL=$?
if [ $RETVAL -eq 1 ]; then
$exec -t -6 -cf $config
else
echo "Syntax: OK" >&2
fi
return $RETVAL
}
rh_status() {
status -p $pidfile -l $(basename $lockfile) $exec
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
start() {
[ `id -u` -eq 0 ] || return 4
[ -x $exec ] || return 5
[ -f $config ] || return 6
rh_status_q && return 0
# add default dhcpd6.conf configuration file if there's no one in DHCPDARGS
[ "${config}" = "${default_config}" ] && DHCPDARGS="$DHCPDARGS -cf $default_config"
echo -n $"Starting $prog (DHCPv6): "
daemon --pidfile=$pidfile $exec -6 $DHCPDARGS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $lockfile
return $RETVAL
}
stop() {
[ `id -u` -eq 0 ] || return 4
rh_status_q || return 0
echo -n $"Shutting down $prog (DHCPv6): "
killproc -p $pidfile $prog
RETVAL=$?
echo
[ $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
exit 2
fi
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload)
stop ; start
;;
condrestart|try-restart)
rh_status_q || exit 0
stop ; start
;;
reload)
usage
# unimplemented feature
exit 3
;;
configtest)
configtest
;;
status)
rh_status
;;
*)
usage
exit 2
;;
esac
exit $?

View File

@ -39,8 +39,15 @@ configtest() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
[ -z "$DHCPSERVERS" ] && exit 6
RETVAL=0
return $RETVAL
return 0
}
rh_status() {
status $exec
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
start() {
@ -48,9 +55,7 @@ start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
pidofproc $prog >/dev/null 2>&1
RETVAL=$?
[ $RETVAL -eq 0 ] && return $RETVAL
rh_status_q && return 0
echo -n $"Starting $prog: "
daemon $exec $([ -n "$INTERFACES" ] && for int in $INTERFACES ; do echo -n " -i $int" ; done) $DHCPSERVERS 2>/dev/null
@ -63,11 +68,7 @@ start() {
stop() {
[ `id -u` -eq 0 ] || exit 4
pidofproc $prog >/dev/null 2>&1
if [ $? -ne 0 ]; then
RETVAL=0
return $RETVAL
fi
rh_status_q || return 0
echo -n $"Shutting down $prog: "
killproc $prog -TERM
@ -84,52 +85,39 @@ usage() {
echo $"Usage: $0 {start|stop|restart|force-reload|condrestart|try-restart|configtest|status}"
}
if [ ! -x $exec ]; then
RETVAL=5
exit $RETVAL
fi
if [ $# -gt 1 ]; then
RETVAL=2
exit $RETVAL
exit 2
fi
case "$1" in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
restart|force-reload)
stop && start
RETVAL=$?
stop ; start
;;
condrestart|try-restart)
if [ -f $lockfile ]; then
stop && start
RETVAL=$?
fi
rh_status_q || exit 0
stop ; start
;;
reload)
usage
# unimplemented feature
RETVAL=3
exit 3
;;
configtest)
configtest
RETVAL=$?
;;
status)
status $prog
RETVAL=$?
rh_status
;;
*)
usage
RETVAL=2
exit 2
;;
esac
exit $RETVAL
exit $?