From ffbb478a15cd3a65a3fefcf702f7f00cce53fc87 Mon Sep 17 00:00:00 2001 From: Stefan Wold Date: Tue, 31 Jul 2012 17:28:07 +0200 Subject: [PATCH] dhcp: Revamped the module and added systemd services --- net/dhcp/BUILD | 50 ++++++++++++------------------- net/dhcp/DEPENDS | 3 +- net/dhcp/DETAILS | 10 +++++-- net/dhcp/config.d/dhcpd | 4 +++ net/dhcp/config.d/dhcpd6 | 4 +++ net/dhcp/dhcpd.conf.sample | 27 ----------------- net/dhcp/dhcpd.config | 7 ----- net/dhcp/init.d/dhcpd | 6 ++-- net/dhcp/systemd.d/dhcpd.service | 10 +++++++ net/dhcp/systemd.d/dhcpd6.service | 10 +++++++ 10 files changed, 59 insertions(+), 72 deletions(-) create mode 100644 net/dhcp/config.d/dhcpd create mode 100644 net/dhcp/config.d/dhcpd6 delete mode 100644 net/dhcp/dhcpd.conf.sample delete mode 100644 net/dhcp/dhcpd.config create mode 100644 net/dhcp/systemd.d/dhcpd.service create mode 100644 net/dhcp/systemd.d/dhcpd6.service diff --git a/net/dhcp/BUILD b/net/dhcp/BUILD index 718cda6dc4e..a358d600f22 100644 --- a/net/dhcp/BUILD +++ b/net/dhcp/BUILD @@ -2,44 +2,32 @@ CFLAGS+=" -D_GNU_SOURCE " CFGHOME="/etc/config.d" OPTS+=" --with-srv-lease-file=/var/state/dhcp/dhcpd.leases \ - --with-cli-lease-file=/var/state/dhcp/dhclient.leases" + --with-srv6-lease-file=/var/state/dhcp/dhcpd6.leases \ + --with-cli-lease-file=/var/state/dhclient/dhclient.leases \ + --with-cli6-lease-file=/var/state/dhclient/dhclient6.leases" - if [ ! -e /proc/net/if_inet6 ]; then - OPTS+=" --disable-dhcpv6 " - fi && + # Correct paths + patch_it $SOURCE2 1 && - sedit 's;^dist_sysconf_DATA.*dhcpd.conf;dist_sysconf_DATA =;' server/Makefile.in && + # Make missing ipv6 non fatal + patch_it $SOURCE3 0 && default_build && - #make sure the config directory exists + install -D -m0755 client/scripts/linux /usr/sbin/dhclient-script && - if [ ! -d $CFGHOME ]; then - mkdir -p $CFGHOME - fi && + mkdir -p /var/state/{dhcp,dhclient} && + [ -f /var/state/dhcp/dhcpd.leases ] || touch /var/state/dhcp/dhcpd.leases && + [ -f /var/state/dhcp/dhcpd6.leases ] || touch /var/state/dhcp/dhcpd6.leases && - #copy the lunar config file into place + # Sample config files (start with empty files) + [ -f /etc/dhcpd.conf ] || touch /etc/dhcpd.conf && + [ -f /etc/dhcpd6.conf ] || touch /etc/dhcpd6.conf && - if [ ! -e /etc/config.d/dhcpd ]; then - cp $SCRIPT_DIRECTORY/dhcpd.config $CFGHOME/dhcpd - else - cp $SCRIPT_DIRECTORY/dhcpd.config $CFGHOME/dhcpd.new - fi && - - - #make sure the leases file exists or we won't run - - if [ ! -e /var/state/dhcp/dhcpd.leases ]; then - mkdir -p /var/state/dhcp/ - touch /var/state/dhcp/dhcpd.leases - fi && - - #we need a config file also - - if [ ! -e /etc/dhcpd.conf ]; then - cp $SCRIPT_DIRECTORY/dhcpd.conf.sample /etc/dhcpd.conf - else - cp $SCRIPT_DIRECTORY/dhcpd.conf.sample /etc/dhcpd.conf.new - fi + # Always overwrite sample configs + install -D -m 0644 server/dhcpd.conf /etc/dhcpd.conf.sample && + install -D -m 0644 doc/examples/dhcpd-dhcpv6.conf /etc/dhcpd6.conf.sample && + install -D -m 0644 client/dhclient.conf /etc/dhclient.conf.sample && + install -D -m 0644 doc/examples/dhclient-dhcpv6.conf /etc/dhclient6.conf.sample ) > $C_FIFO 2>&1 diff --git a/net/dhcp/DEPENDS b/net/dhcp/DEPENDS index 6448f1cf0ba..2497f389a22 100644 --- a/net/dhcp/DEPENDS +++ b/net/dhcp/DEPENDS @@ -1 +1,2 @@ -depends net-tools +depends net-tools +depends iproute2 diff --git a/net/dhcp/DETAILS b/net/dhcp/DETAILS index 64c79e023b9..1fa9763ad2a 100644 --- a/net/dhcp/DETAILS +++ b/net/dhcp/DETAILS @@ -1,13 +1,19 @@ MODULE=dhcp VERSION=4.2.4-P1 SOURCE=$MODULE-$VERSION.tar.gz + SOURCE2=dhcp-4.2.3-no-conf-and-proper-paths.patch + SOURCE3=dhcp-4.1.1-missing-ipv6-not-fatal.patch SOURCE_URL=ftp://ftp.isc.org/isc/$MODULE/$VERSION + SOURCE2_URL=$PATCH_URL + SOURCE3_URL=$PATCH_URL SOURCE_VFY=sha1:0fe0f20b7be597d60e61951d2ccafe547d3bcec2 + SOURCE2_VFY=sha1:be19c87e477c0480ae6447e06432575911eb7a95 + SOURCE3_VFY=sha1:2ea1872a8a2aa513410a278bc2cd61630fdfd03f WEB_SITE=http://www.isc.org/products/DHCP ENTERED=20010922 - UPDATED=20120729 - PSAFE=no + UPDATED=20120731 SHORT="A server and client for automatic IP configuration" +PSAFE=no cat << EOF The Internet Software Consortium DHCP distribution includes a DHCP diff --git a/net/dhcp/config.d/dhcpd b/net/dhcp/config.d/dhcpd new file mode 100644 index 00000000000..7cad63178ba --- /dev/null +++ b/net/dhcp/config.d/dhcpd @@ -0,0 +1,4 @@ +# Lunar configuration file for dhcpd +# /etc/config.d/dhcpd +# +DHCPD_ARGS="-q eth0" diff --git a/net/dhcp/config.d/dhcpd6 b/net/dhcp/config.d/dhcpd6 new file mode 100644 index 00000000000..7cad63178ba --- /dev/null +++ b/net/dhcp/config.d/dhcpd6 @@ -0,0 +1,4 @@ +# Lunar configuration file for dhcpd +# /etc/config.d/dhcpd +# +DHCPD_ARGS="-q eth0" diff --git a/net/dhcp/dhcpd.conf.sample b/net/dhcp/dhcpd.conf.sample deleted file mode 100644 index 5b5ea040502..00000000000 --- a/net/dhcp/dhcpd.conf.sample +++ /dev/null @@ -1,27 +0,0 @@ -subnet 192.168.0.0 netmask 255.255.255.0 { -# --- default gateway - option routers 192.168.0.1; - option subnet-mask 255.255.255.0; - - option nis-domain "domain.org"; - option domain-name "domain.org"; - option domain-name-servers 192.168.0.1; - - option time-offset -5; # Eastern Standard Time -# option ntp-servers 192.168.1.1; -# option netbios-name-servers 192.168.1.1; -# --- Selects point-to-point node (default is hybrid). Don't change this unless -# -- you understand Netbios very well -# option netbios-node-type 2; - - range dynamic-bootp 192.168.0.128 192.168.0.255; - default-lease-time 21600; - max-lease-time 43200; - - # we want the nameserver to appear at a fixed address - host ns { - next-server ernie.lunar-linux.org; - hardware ethernet 21:43:65:87:BA:HA; - fixed-address 192.168.0.1; - } -} diff --git a/net/dhcp/dhcpd.config b/net/dhcp/dhcpd.config deleted file mode 100644 index 93ae09c5e5d..00000000000 --- a/net/dhcp/dhcpd.config +++ /dev/null @@ -1,7 +0,0 @@ -# Lunar configuration file for dhcpd -# /etc/config.d/dhcpd -# - -# The names of the network interfaces on which dhcpd should -# listen for broadcasts (separated by space) -DHCPD_INTERFACES="eth0" diff --git a/net/dhcp/init.d/dhcpd b/net/dhcp/init.d/dhcpd index 3c73c3598ce..4a033a3b4f7 100755 --- a/net/dhcp/init.d/dhcpd +++ b/net/dhcp/init.d/dhcpd @@ -11,16 +11,14 @@ # Get service config [ -f /etc/config.d/dhcpd ] && . /etc/config.d/dhcpd -ARGS="-q $DHCPD_INTERFACES" - start() { echo -n "Starting dhcpd: " - /usr/sbin/dhcpd $ARGS && echo -e $RESULT_OK || echo -e $RESULT_FAIL + /usr/sbin/dhcpd $DHCPD_ARGS && echo -e $RESULT_OK || echo -e $RESULT_FAIL } reload () { # dhcpd cannot reload $0 restart } - + . /lib/lsb/init-functions diff --git a/net/dhcp/systemd.d/dhcpd.service b/net/dhcp/systemd.d/dhcpd.service new file mode 100644 index 00000000000..8faeffb45dd --- /dev/null +++ b/net/dhcp/systemd.d/dhcpd.service @@ -0,0 +1,10 @@ +[Unit] +Description=DHCPv4 Server Daemon +After=network.target + +[Service] +EnvironmentFile=/etc/config.d/dhcpd +ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcpd.conf --no-pid $DHCPD_ARGS + +[Install] +WantedBy=multi-user.target diff --git a/net/dhcp/systemd.d/dhcpd6.service b/net/dhcp/systemd.d/dhcpd6.service new file mode 100644 index 00000000000..db9a2d4769b --- /dev/null +++ b/net/dhcp/systemd.d/dhcpd6.service @@ -0,0 +1,10 @@ +[Unit] +Description=DHCPv6 Server Daemon +After=network.target + +[Service] +EnvironmentFile=/etc/config.d/dhcpd6 +ExecStart=/usr/sbin/dhcpd -f -6 -cf /etc/dhcpd6.conf --no-pid $DHCPD_ARGS + +[Install] +WantedBy=multi-user.target