[Lunar-commits] <moonbase-other> dhcp: Revamped the module and added systemd services

Stefan Wold ratler at lunar-linux.org
Tue Jul 31 17:28:07 CEST 2012


commit ffbb478a15cd3a65a3fefcf702f7f00cce53fc87
Author: Stefan Wold <ratler at lunar-linux.org>
Date: Tue, 31 Jul 2012 08:28:07 -0700
URL: https://github.com/lunar-linux/moonbase-other/commit/ffbb478a15cd3a65a3fefcf702f7f00cce53fc87

dhcp: Revamped the module and added systemd services
---
  net/dhcp/BUILD                                               +19/-31   
  net/dhcp/DEPENDS                                             +2/-1     
  net/dhcp/DETAILS                                             +8/-2     
  net/dhcp/config.d/dhcpd                                      +4/-0     
  net/dhcp/config.d/dhcpd6                                     +4/-0     
  net/dhcp/dhcpd.conf.sample                                   +0/-27    
  net/dhcp/dhcpd.config                                        +0/-7     
  net/dhcp/init.d/dhcpd                                        +2/-4     
  net/dhcp/systemd.d/dhcpd.service                             +10/-0    
  net/dhcp/systemd.d/dhcpd6.service                            +10/-0    
  10 files changed, 59 insertions (+), 72 deletions (-)

--- 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
--- a/net/dhcp/DEPENDS
+++ b/net/dhcp/DEPENDS
@@ -1 +1,2 @@
-depends  net-tools
+depends net-tools
+depends iproute2
--- 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
--- /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"
--- /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"
--- 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;
-	}
-}
--- 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"
--- 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
--- /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
--- /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




More information about the Lunar-commits mailing list