From 0efc1588436b19e8a56f4dc8e8c4846a0b190df0 Mon Sep 17 00:00:00 2001 From: akdengi Date: Thu, 7 Nov 2013 14:47:27 +0400 Subject: [PATCH] sync with OM --- .abf.yml | 4 +- dhcp-4.2.0-default-requested-options.patch | 44 ---- dhcp-4.2.5-P1-man.patch | 22 -- dhcp.spec | 243 ++++++++++----------- dhcpd-chroot.sh | 0 dhcpd.conf | 2 +- dhcpd.init | 118 ++++++++++ dhcpd.service | 9 +- dhcpd6.init | 117 ++++++++++ dhcpd6.service | 7 +- dhcrelay.init | 90 ++++++++ 11 files changed, 443 insertions(+), 213 deletions(-) delete mode 100644 dhcp-4.2.0-default-requested-options.patch delete mode 100644 dhcp-4.2.5-P1-man.patch mode change 100755 => 100644 dhcpd-chroot.sh create mode 100644 dhcpd.init create mode 100644 dhcpd6.init create mode 100644 dhcrelay.init diff --git a/.abf.yml b/.abf.yml index 3037190..21a2377 100644 --- a/.abf.yml +++ b/.abf.yml @@ -1,4 +1,4 @@ sources: - dhcp-4.2.5-P1.tar.gz: 120b6e476b2ac0d35e1dc8dee53752c42449b925 - dhcp-4.2.5-P1.tar.gz.sha512.asc: d43248ba82d8a2f393f2f6c283ea06fb2df38d18 + dhcp-4.2.5.tar.gz: d029505509aee83ea28972d5d1c95dc4b5db99f1 + dhcp-4.2.5.tar.gz.sha512.asc: ac49b30ef17acb36cc5603faa5d780e423aa0e06 dhcp-dynamic-dns-examples.tar.bz2: d33980aad3e0380fc89f8346ab37786d39157696 diff --git a/dhcp-4.2.0-default-requested-options.patch b/dhcp-4.2.0-default-requested-options.patch deleted file mode 100644 index fea8a4b..0000000 --- a/dhcp-4.2.0-default-requested-options.patch +++ /dev/null @@ -1,44 +0,0 @@ -diff -up dhcp-4.2.0/client/clparse.c.requested dhcp-4.2.0/client/clparse.c ---- dhcp-4.2.0/client/clparse.c.requested 2010-07-21 13:29:05.000000000 +0200 -+++ dhcp-4.2.0/client/clparse.c 2010-07-21 13:50:29.000000000 +0200 -@@ -37,7 +37,7 @@ - - struct client_config top_level_config; - --#define NUM_DEFAULT_REQUESTED_OPTS 9 -+#define NUM_DEFAULT_REQUESTED_OPTS 14 - struct option *default_requested_options[NUM_DEFAULT_REQUESTED_OPTS + 1]; - - static void parse_client_default_duid(struct parse *cfile); -@@ -111,6 +111,31 @@ isc_result_t read_client_conf () - option_code_hash_lookup(&default_requested_options[8], - dhcpv6_universe.code_hash, &code, 0, MDL); - -+ /* 10 */ -+ code = DHO_NIS_DOMAIN; -+ option_code_hash_lookup(&default_requested_options[9], -+ dhcp_universe.code_hash, &code, 0, MDL); -+ -+ /* 11 */ -+ code = DHO_NIS_SERVERS; -+ option_code_hash_lookup(&default_requested_options[10], -+ dhcp_universe.code_hash, &code, 0, MDL); -+ -+ /* 12 */ -+ code = DHO_NTP_SERVERS; -+ option_code_hash_lookup(&default_requested_options[11], -+ dhcp_universe.code_hash, &code, 0, MDL); -+ -+ /* 13 */ -+ code = DHO_INTERFACE_MTU; -+ option_code_hash_lookup(&default_requested_options[12], -+ dhcp_universe.code_hash, &code, 0, MDL); -+ -+ /* 14 */ -+ code = DHO_DOMAIN_SEARCH; -+ option_code_hash_lookup(&default_requested_options[13], -+ dhcp_universe.code_hash, &code, 0, MDL); -+ - for (code = 0 ; code < NUM_DEFAULT_REQUESTED_OPTS ; code++) { - if (default_requested_options[code] == NULL) - log_fatal("Unable to find option definition for " diff --git a/dhcp-4.2.5-P1-man.patch b/dhcp-4.2.5-P1-man.patch deleted file mode 100644 index 84bb383..0000000 --- a/dhcp-4.2.5-P1-man.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff -Naur dhcp-4.2.5-P1/client/dhclient.conf.5 dhcp-4.2.5-P1.oden/client/dhclient.conf.5 ---- dhcp-4.2.5-P1/client/dhclient.conf.5 2013-03-05 19:26:51.000000000 +0100 -+++ dhcp-4.2.5-P1.oden/client/dhclient.conf.5 2013-03-28 11:55:37.131387053 +0100 -@@ -202,7 +202,8 @@ - options. Only the option names should be specified in the request - statement - not option parameters. By default, the DHCPv4 client - requests the subnet-mask, broadcast-address, time-offset, routers, --domain-name, domain-name-servers and host-name options while the DHCPv6 -+domain-search, domain-name, domain-name-servers, host-name, nis-domain, -+nis-servers, ntp-servers and interface-mtu options while the DHCPv6 - client requests the dhcp6 name-servers and domain-search options. Note - that if you enter a \'request\' statement, you over-ride these defaults - and these options will not be requested. -@@ -713,7 +714,7 @@ - supersede domain-search "fugue.com", "rc.vix.com", "home.vix.com"; - prepend domain-name-servers 127.0.0.1; - request subnet-mask, broadcast-address, time-offset, routers, -- domain-name, domain-name-servers, host-name; -+ domain-search, domain-name, domain-name-servers, host-name; - require subnet-mask, domain-name-servers; - script "CLIENTBINDIR/dhclient-script"; - media "media 10baseT/UTP", "media 10base2/BNC"; diff --git a/dhcp.spec b/dhcp.spec index 98607ed..bb8ab0b 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -1,19 +1,15 @@ -%define _catdir /var/cache/man -%define _tmpfilesdir /usr/lib/tmpfiles.d/ - -%define major_version 4.2.5 -%define patch_version P1 +#define plevel P1 +Summary: The ISC DHCP (Dynamic Host Configuration Protocol) server/relay agent/client Name: dhcp Epoch: 3 -Version: %{major_version}%{patch_version} -Release: 2 -Summary: The ISC DHCP (Dynamic Host Configuration Protocol) server/relay agent/client +Version: 4.2.5 +Release: %{?plevel:0.P%{plevel}.}3 License: Distributable Group: System/Servers -URL: http://www.isc.org/software/dhcp -Source0: ftp://ftp.isc.org/isc/%{name}/%{major_version}-%{patch_version}/%{name}-%{major_version}-%{patch_version}.tar.gz -Source1: ftp://ftp.isc.org/isc/%{name}/%{major_version}-%{patch_version}/%{name}-%{major_version}-%{patch_version}.tar.gz.sha512.asc +Url: http://www.isc.org/software/dhcp +Source0: ftp://ftp.isc.org/isc/%{name}/%{version}/%{name}-%{version}%{?plevel:-%{plevel}}.tar.gz +Source1: ftp://ftp.isc.org/isc/%{name}/%{version}/%{name}-%{version}%{?plevel:-%{plevel}}.tar.gz.sha512.asc Source2: dhcpd.conf Source4: dhcp-dynamic-dns-examples.tar.bz2 Source7: dhcpreport.pl @@ -21,8 +17,11 @@ Source8: dhcpd-chroot.sh # (eugeni) dhclient-exit-hooks script Source9: dhclient-exit-hooks Source10: draft-ietf-dhc-ldap-schema-01.txt +Source11: dhcpd.init Source12: dhcpd.service +Source13: dhcpd6.init Source14: dhcpd6.service +Source15: dhcrelay.init Source16: dhcrelay.service Source17: dhcpd.tmpfiles Source18: dhclient.tmpfiles @@ -32,17 +31,23 @@ Patch100: dhcp-4.2.2-ifup.patch Patch101: dhcp-4.2.2-fix-format-errors.patch # prevents needless deassociation, working around mdv bug #43441 Patch102: dhcp-4.1.1-prevent_wireless_deassociation.patch -Patch103: dhcp-4.2.5-P1-man.patch # fedora patches -Patch7: dhcp-4.2.0-default-requested-options.patch +# Handle Xen partial UDP checksums Patch8: dhcp-4.2.2-xen-checksum.patch +# If the ipv6 kernel module is missing, do not segfault +# (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #19367]) Patch15: dhcp-4.2.2-missing-ipv6-not-fatal.patch +# Handle cases in add_timeout() where the function is called with a NULL +# value for the 'when' parameter Patch17: dhcp-4.2.0-add_timeout_when_NULL.patch +# Ensure 64-bit platforms parse lease file dates & times correctly Patch18: dhcp-4.2.4-64_bit_lease_parse.patch -BuildRequires: groff-for-man + +BuildRequires: libtool +BuildRequires: groff-base +BuildRequires: systemd-units +BuildRequires: bind-devel BuildRequires: openldap-devel -Requires(post): rpm-helper -Requires(preun): rpm-helper %description DHCP (Dynamic Host Configuration Protocol) is a protocol which allows @@ -56,11 +61,11 @@ or pump or dhcpxd, which provides the DHCP client daemon, on client machines. If you want the DHCP server and/or relay, you will also need to install the dhcp-server and/or dhcp-relay packages. -%package common +%package common Summary: The ISC DHCP (Dynamic Host Configuration Protocol) server Group: System/Servers -%description common +%description common DHCP (Dynamic Host Configuration Protocol) is a protocol which allows individual devices on an IP network to get their own network configuration information (IP address, subnetmask, broadcast address, @@ -73,11 +78,11 @@ dhcpxd, which provides the DHCP client daemon, on client machines. If you want the DHCP server and/or relay, you will also need to install the dhcp-server and/or dhcp-relay packages. -%package doc +%package doc Summary: Documentation about the ISC DHCP server/client Group: System/Servers -%description doc +%description doc This package contains RFC/API/protocol documentation about the ISC DHCP server and client. @@ -88,15 +93,14 @@ etc.) from a DHCP server. The overall purpose of DHCP is to make it easier to administer a large network. The dhcp package includes the DHCP server and a DHCP relay agent. -%package server +%package server Summary: The ISC DHCP (Dynamic Host Configuration Protocol) server Group: System/Servers -Requires: dhcp-common = %{epoch}:%{version}-%{release} -Requires(post): systemd -Requires(post): rpm-helper -Requires(preun): rpm-helper +Requires: dhcp-common >= %{EVRD} +Requires(post,preun): rpm-helper +Requires(post,postun): systemd-units -%description server +%description server DHCP server is the Internet Software Consortium (ISC) DHCP server for various UNIX operating systems. It allows a UNIX mac hine to serve DHCP requests from the network. @@ -104,13 +108,13 @@ the network. You should install dhcp-server if you want to set up a DHCP server on your network. You will also need to install the base dhcp package. -%package client +%package client Summary: The ISC DHCP (Dynamic Host Configuration Protocol) client Group: System/Servers -Requires: dhcp-common = %{epoch}:%{version}-%{release} -Requires(post): systemd +Requires: dhcp-common >= %{EVRD} +Provides: dhcp-client-daemon -%description client +%description client DHCP client is the Internet Software Consortium (ISC) DHCP client for various UNIX operating systems. It allows a UNIX mac hine to obtain it's networking parameters from a DHCP server. @@ -119,120 +123,113 @@ You should install dhcp-client if you want to use the ISC DHCP client instead of the Red Hat DHCP client, pump, or dhcpcd, or dhcpxd. You will also need to install the base dhcp package. -%package relay +%package relay Summary: The ISC DHCP (Dynamic Host Configuration Protocol) relay Group: System/Servers -Requires: dhcp-common = %{epoch}:%{version}-%{release} -Requires(post): systemd -Requires(post): rpm-helper -Requires(preun): rpm-helper +Requires: dhcp-common >= %{EVRD} +Requires(post,preun): rpm-helper -%description relay +%description relay DHCP relay is the Internet Software Consortium (ISC) relay agent for DHCP packets. It is used on a subnet with DHCP clients to "relay" their requests to a subnet that has a DHCP server on it. Because DHCP packets can be broadcast, they will not be routed off of the local subnet. The DHCP relay takes care of this for the client. You will need to set the environment -variable SERVERS and optionally OPTIONS in /etc/sysconfig/dhcrelay before +variable SERVERS and optionally OPTIONS in %{_sysconfdir}/sysconfig/dhcrelay before starting the server. -%package devel +%package devel Summary: Development headers and libraries for the dhcpctl API Group: Development/Other -Requires: dhcp-common = %{epoch}:%{version}-%{release} +Requires: dhcp-common >= %{EVRD} -%description devel +%description devel DHCP devel contains all of the libraries and headers for developing with the Internet Software Consortium (ISC) dhcpctl API. %prep -%setup -q -n %{name}-%{major_version}-%{patch_version} -%patch100 -p1 -b .ifup -%patch101 -p1 -b .format_not_a_string_literal_and_no_format_arguments -%patch102 -p1 -b .prevent_wireless_deassociation -%patch103 -p1 -b .man +%setup -qn %{name}-%{version}%{?plevel:-%{plevel}} +%apply_patches +autoreconf -fi -# Add NIS domain, NIS servers, NTP servers, interface-mtu and domain-search -# to the list of default requested DHCP options -%patch7 -p1 -b .requested -# Handle Xen partial UDP checksums -%patch8 -p1 -b .xen -# If the ipv6 kernel module is missing, do not segfault -# (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #19367]) -%patch15 -p1 -b .noipv6 -# Handle cases in add_timeout() where the function is called with a NULL -# value for the 'when' parameter -%patch17 -p1 -b .dracut -# Ensure 64-bit platforms parse lease file dates & times correctly -%patch18 -p1 -b .64-bit_lease_parse +# remove empty files +find -size 0 |grep ldap | xargs rm -rf -install -m0644 %{SOURCE10} doc +cp %{SOURCE10} doc %build -%serverbuild -%configure2_5x --enable-paranoia --enable-early-chroot \ - --with-ldapcrypto \ - --with-srv-lease-file=%{_var}/lib/dhcpd/dhcpd.leases \ - --with-srv6-lease-file=%{_var}/lib/dhcpd/dhcpd6.leases \ - --with-cli-lease-file=%{_var}/lib/dhclient/dhclient.leases \ - --with-cli6-lease-file=%{_var}/lib/dhclient/dhclient6.leases \ - --with-srv-pid-file=/run/dhcpd/dhcpd.pid \ - --with-srv6-pid-file=/run/dhcpd/dhcpd6.pid \ - --with-cli-pid-file=/run/dhclient/dhclient.pid \ - --with-cli6-pid-file=/run/dhclient/dhclient6.pid \ - --with-relay-pid-file=/run/dhcrelay/dhcrelay.pid \ - --disable-static +%serverbuild_hardened +%configure2_5x \ + --enable-paranoia \ + --enable-early-chroot \ + --with-ldapcrypto \ + --with-srv-lease-file=%{_localstatedir}/lib/dhcp/dhcpd.leases \ + --with-srv6-lease-file=%{_localstatedir}/lib/dhcp/dhcpd6.leases \ + --with-cli-lease-file=%{_localstatedir}/lib/dhcp/dhclient.leases \ + --with-cli6-lease-file=%{_localstatedir}/lib/dhcp/dhclient6.leases \ + --with-srv-pid-file=%{_var}/run/dhcpd/dhcpd.pid \ + --with-srv6-pid-file=%{_var}/run/dhcpd/dhcpd6.pid \ + --with-cli-pid-file=%{_var}/run/dhclient.pid \ + --with-cli6-pid-file=%{_var}/run/dhclient6.pid \ + --with-relay-pid-file=%{_var}/run/dhcrelay.pid + %make %install -rm -rf %{buildroot} - %makeinstall_std # Install correct dhclient-script -install -d %{buildroot}/sbin +install -p -m755 client/scripts/linux -D %{buildroot}/sbin/dhclient-script mv %{buildroot}%{_sbindir}/dhclient %{buildroot}/sbin/dhclient -install -m 755 client/scripts/linux %{buildroot}/sbin/dhclient-script -install -d %{buildroot}%{_unitdir} -install -m 644 %{SOURCE12} %{buildroot}%{_unitdir}/dhcpd.service -install -m 644 %{SOURCE14} %{buildroot}%{_unitdir}/dhcpd6.service -install -m 644 %{SOURCE16} %{buildroot}%{_unitdir}/dhcrelay.service +install -m644 %{SOURCE12} -D %{buildroot}%{_unitdir}/dhcpd.service +install -m644 %{SOURCE14} -D %{buildroot}%{_unitdir}/dhcpd6.service +install -m644 %{SOURCE16} -D %{buildroot}%{_unitdir}/dhcrelay.service install -D -p -m 644 %{SOURCE17} %{buildroot}%{_tmpfilesdir}/dhcpd.conf install -D -p -m 644 %{SOURCE18} %{buildroot}%{_tmpfilesdir}/dhclient.conf install -D -p -m 644 %{SOURCE19} %{buildroot}%{_tmpfilesdir}/dhcrelay.conf -install -m 755 %{SOURCE7} %{SOURCE8} %{buildroot}%{_sbindir} -install -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir} -install -m 755 contrib/ldap/dhcpd-conf-to-ldap %{buildroot}%{_sbindir} +install -m755 %{SOURCE11} -D %{buildroot}%{_initrddir}/dhcpd +install -m755 %{SOURCE13} -D %{buildroot}%{_initrddir}/dhcpd6 +install -m755 %{SOURCE15} -D %{buildroot}%{_initrddir}/dhcrelay + +install -m755 %{SOURCE7} -D %{buildroot}%{_sbindir}/dhcpreport.pl +install -m755 %{SOURCE8} -D %{buildroot}%{_sbindir}/dhcpd-chroot.sh +install -m644 %{SOURCE2} -D %{buildroot}%{_sysconfdir}/dhcpd.conf +install -m755 contrib/ldap/dhcpd-conf-to-ldap -D %{buildroot}%{_sbindir}/dhcpd-conf-to-ldap + +install -d %{buildroot}%{_var}/lib/dhclient +touch %{buildroot}%{_var}/lib/dhclient/dhclient.leases # install exit-hooks script to /etc/ -install -m 755 %{SOURCE9} %{buildroot}%{_sysconfdir} +install -m755 %{SOURCE9} -D %{buildroot}%{_sysconfdir}/dhclient-exit-hooks install -d %{buildroot}%{_sysconfdir}/sysconfig cat > %{buildroot}%{_sysconfdir}/sysconfig/dhcpd < %{buildroot}%{_sysconfdir}/sysconfig/dhcrelay < -- P103: rediff -- 4.2.5-P1 (fixes CVE-2013-2494) -- drop bogus br on bind-devel -- Make sure ldap service is started before dhcpd -- Use tmpfiles macros and add system version to requires -- add fedora patch adding requesting more options by default -- drop static libs -- use /run instead of /var/run for pid files -- switch to tmpfs for /run subdirectories -- use distinct state directories for client and server, as in fedora -- drop sysinit support -- Fix systemd units to report correct status on startup -- Add dhcpd user -- Fix service files extension - - diff --git a/dhcpd-chroot.sh b/dhcpd-chroot.sh old mode 100755 new mode 100644 diff --git a/dhcpd.conf b/dhcpd.conf index 6afd09e..56371db 100644 --- a/dhcpd.conf +++ b/dhcpd.conf @@ -16,7 +16,7 @@ subnet 192.168.0.0 netmask 255.255.255.0 { # we want the nameserver to appear at a fixed address host ns { - next-server fixed.domain.org; + next-server fixed.mandrakesoft.com; hardware ethernet 12:34:56:78:AB:CD; fixed-address 192.168.0.10; } diff --git a/dhcpd.init b/dhcpd.init new file mode 100644 index 0000000..8fecde8 --- /dev/null +++ b/dhcpd.init @@ -0,0 +1,118 @@ +#!/bin/sh +# +### BEGIN INIT INFO +# Provides: dhcpd +# Default-Start: +# Default-Stop: 0 6 +# Should-Start: ldap +# Required-Start: $network +# Should-Stop: ldap +# Required-Stop: +# Short-Description: Start and stop the DHCP server +# Description: dhcpd provides the Dynamic Host Configuration Protocol (DHCP) +# 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 (DHCP) \ +# server +# processname: dhcpd +# config: /etc/dhcpd.conf +# config: /var/lib/dhcpd/dhcpd.leases +# pidfile: /var/run/dhcpd.pid + +. /etc/rc.d/init.d/functions + +[ -x /usr/sbin/dhcpd ] || exit 0 + +# Which configuration file to use. +CONFIGFILE="/etc/dhcpd.conf" +# Where to store the lease state information. +LEASEFILE="/var/lib/dhcp/dhcpd.leases" +# Define INTERFACES to limit which network interfaces dhcpd listens on. +# The default null value causes dhcpd to listen on all interfaces. +INTERFACES="" +# Define OPTIONS with any other options to pass to the dhcpd server. +OPTIONS="-q" + +# Values specified in this file override the defaults above. +[ -f /etc/sysconfig/dhcpd ] && . /etc/sysconfig/dhcpd + +[ -f $CONFIGFILE ] || exit 0 +[ -f $LEASEFILE ] || exit 0 + +RETVAL=0 + +start() { + echo -n "Starting dhcpd: " + if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then + OPTIONS="${OPTIONS} -chroot ${ROOTDIR}" + fi + daemon /usr/sbin/dhcpd -cf $CONFIGFILE -lf $LEASEFILE $OPTIONS $INTERFACES + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd + return $RETVAL +} + +stop() { + echo -n "Shutting down dhcpd: " + if [ -r ${ROOTDIR}/var/run/dhcpd/dhcpd.pid ]; then + kill -TERM `cat ${ROOTDIR}/var/run/dhcpd/dhcpd.pid` + RETVAL=$? + [ "$RETVAL" = 0 ] && success "stop" || failure "stop" + else + success "already stopped" + RETVAL=0 + fi + [ $RETVAL -eq 0 ] && rm -f ${ROOTDIR}/var/run/dhcpd/dhcpd.pid + [ $RETVAL = 0 ] && rm -f /var/lock/subsys/dhcpd + echo + return $RETVAL +} + +configtest() { + /usr/sbin/dhcpd -q -t -cf $CONFIGFILE + RETVAL=$? + if [ $RETVAL -eq 1 ]; then + /usr/sbin/dhcpd -t -cf $CONFIGFILE + else + echo "Syntax: OK" >&2 + fi + return $RETVAL +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + stop + start + RETVAL=$? + ;; + condrestart) + if [ -f /var/lock/subsys/dhcpd ]; then + stop + start + RETVAL=$? + fi + ;; + configtest) + configtest + ;; + status) + status dhcpd + RETVAL=$? + ;; + *) + echo "Usage: dhcpd {start|stop|restart|condrestart|status}" + exit 1 +esac + +exit $RETVAL diff --git a/dhcpd.service b/dhcpd.service index 3ecb7d2..44e277d 100644 --- a/dhcpd.service +++ b/dhcpd.service @@ -1,13 +1,10 @@ [Unit] Description=DHCPv4 Server Daemon -After=syslog.target network.target ldap.service +After=syslog.target network.target [Service] -Environment=CONFIGFILE=/etc/dhcpd.conf LEASEFILE=/var/lib/dhcpd/dhcpd.leases -EnvironmentFile=-/etc/sysconfig/dhcpd -Type=forking -PIDFile=/var/run/dhcpd/dhcpd.pid -ExecStart=/usr/sbin/dhcpd -pf /run/dhcpd/dhcpd.pid -cf $CONFIGFILE -lf $LEASEFILE $OPTIONS $INTERFACES +EnvironmentFile=/etc/sysconfig/dhcpd +ExecStart=/usr/sbin/dhcpd -cf $CONFIGFILE -lf $LEASEFILE $INTERFACES [Install] WantedBy=multi-user.target diff --git a/dhcpd6.init b/dhcpd6.init new file mode 100644 index 0000000..ce2ac9c --- /dev/null +++ b/dhcpd6.init @@ -0,0 +1,117 @@ +#!/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/dhcpd6.conf +# config: /var/lib/dhcpd/dhcpd6.leases +# pidfile: /var/run/dhcpd6.pid + +. /etc/rc.d/init.d/functions + +[ -x /usr/sbin/dhcpd ] || exit 0 + +# Which configuration file to use. +CONFIGFILE="/etc/dhcpd6.conf" +# Where to store the lease state information. +LEASEFILE="/var/lib/dhcp/dhcpd6.leases" +# Define INTERFACES to limit which network interfaces dhcpd listens on. +# The default null value causes dhcpd to listen on all interfaces. +INTERFACES="" +# Define OPTIONS with any other options to pass to the dhcpd server. +OPTIONS="-q" + +# Values specified in this file override the defaults above. +[ -f /etc/sysconfig/dhcpd6 ] && . /etc/sysconfig/dhcpd6 + +[ -f $CONFIGFILE ] || exit 0 +[ -f $LEASEFILE ] || exit 0 + +RETVAL=0 + +start() { + echo -n "Starting dhcpd (DHCPv6): " + if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then + OPTIONS="${OPTIONS} -chroot ${ROOTDIR}" + fi + daemon /usr/sbin/dhcpd -6 -cf $CONFIGFILE -lf $LEASEFILE $OPTIONS $INTERFACES + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd6 + return $RETVAL +} + +stop() { + echo -n "Shutting down dhcpd (DHCPv6): " + if [ -r ${ROOTDIR}/var/run/dhcpd/dhcpd6.pid ]; then + kill -TERM `cat ${ROOTDIR}/var/run/dhcpd/dhcpd6.pid` + RETVAL=$? + [ "$RETVAL" = 0 ] && success "stop" || failure "stop" + else + success "already stopped" + RETVAL=0 + fi + [ $RETVAL -eq 0 ] && rm -f ${ROOTDIR}/var/run/dhcpd/dhcpd6.pid + [ $RETVAL = 0 ] && rm -f /var/lock/subsys/dhcpd6 + echo + return $RETVAL +} + +configtest() { + /usr/sbin/dhcpd -q -t -6 -cf $CONFIGFILE + RETVAL=$? + if [ $RETVAL -eq 1 ]; then + /usr/sbin/dhcpd -t -6 -cf $CONFIGFILE + else + echo "Syntax: OK" >&2 + fi + return $RETVAL +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + stop + start + RETVAL=$? + ;; + condrestart) + if [ -f /var/lock/subsys/dhcpd6 ]; then + stop + start + RETVAL=$? + fi + ;; + configtest) + configtest + ;; + status) + status dhcpd + RETVAL=$? + ;; + *) + echo "Usage: dhcpd6 {start|stop|restart|condrestart|status}" + exit 1 +esac + +exit $RETVAL diff --git a/dhcpd6.service b/dhcpd6.service index 2ecfb32..3ff18c0 100644 --- a/dhcpd6.service +++ b/dhcpd6.service @@ -3,11 +3,8 @@ Description=DHCPv6 Server Daemon After=syslog.target network.target [Service] -Environment=CONFIGFILE=/etc/dhcpd6.conf LEASEFILE=/var/lib/dhcp/dhcpd6.leases -EnvironmentFile=-/etc/sysconfig/dhcpd6 -Type=forking -PIDFile=/var/run/dhcpd6.pid -ExecStart=/usr/sbin/dhcpd -6 -pf /run/dhcpd6.pid -cf $CONFIGFILE -lf $LEASEFILE $OPTIONS $INTERFACES +EnvironmentFile=/etc/sysconfig/dhcpd6 +ExecStart=/usr/sbin/dhcpd -d 6 -cf $CONFIGFILE -lf $LEASEFILE $INTERFACES [Install] WantedBy=multi-user.target diff --git a/dhcrelay.init b/dhcrelay.init new file mode 100644 index 0000000..7a7039f --- /dev/null +++ b/dhcrelay.init @@ -0,0 +1,90 @@ +#!/bin/sh +# +### BEGIN INIT INFO +# Provides: dhcrelay +# Default-Start: 2 3 4 5 +# Default-Stop: +# Should-Start: +# Required-Start: $network +# Required-Stop: $network +# Short-Description: Start and stop the DHCP relay server +# Description: dhcrelay provides the Dynamic Host Configuration Protocol (DHCP) +# relay server. This is required when your DHCP server is on +# another network segment from the clients. +### END INIT INFO +# +# The fields below are left around for legacy tools (will remove later). +# +# chkconfig: - 65 35 +# description: dhcrelay provides a relay for Dynamic Host Control Protocol. +# processname: dhcrelay +# # pidfile: /var/run/dhcrelay.pid + +. /etc/rc.d/init.d/functions + +[ -x /usr/sbin/dhcrelay ] || exit 0 + +# Define SERVERS with a list of one or more DHCP servers where +# DHCP packets are to be relayed to and from. This is mandatory. +SERVERS="" +# Define OPTIONS with any other options to pass to the dhcrelay server. +OPTIONS="-q" + +# Values specified in this file override the defaults above. +[ -f /etc/sysconfig/dhcrelay ] && . /etc/sysconfig/dhcrelay + +# Check that at least one DHCP server to relay to was specified. +[ "${SERVERS}" = "" ] && exit 0 + +RETVAL=0 + +start() { + # Start daemons. + echo -n "Starting dhcrelay: " + daemon /usr/sbin/dhcrelay $OPTIONS $SERVERS + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcrelay + return $RETVAL +} + +stop() { + # Stop daemons. + echo -n "Shutting down dhcrelay: " + killproc dhcrelay + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dhcrelay + return $RETVAL +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + stop + start + RETVAL=$? + ;; + condrestart) + if [ -f /var/lock/subsys/dhcrelay ]; then + stop + start + RETVAL=$? + fi + ;; + status) + status dhcrelay + RETVAL=$? + ;; + *) + echo "Usage: dhcrelay {start|stop|restart|condrestart|status}" + exit 1 +esac + +exit $RETVAL