Skip to content

Commit

Permalink
dhcp: Revamped the module and added systemd services
Browse files Browse the repository at this point in the history
  • Loading branch information
Ratler committed Jul 31, 2012
1 parent 98fc438 commit ffbb478
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 72 deletions.
50 changes: 19 additions & 31 deletions net/dhcp/BUILD
Expand Up @@ -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
3 changes: 2 additions & 1 deletion net/dhcp/DEPENDS
@@ -1 +1,2 @@
depends net-tools
depends net-tools
depends iproute2
10 changes: 8 additions & 2 deletions 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
Expand Down
4 changes: 4 additions & 0 deletions net/dhcp/config.d/dhcpd
@@ -0,0 +1,4 @@
# Lunar configuration file for dhcpd
# /etc/config.d/dhcpd
#
DHCPD_ARGS="-q eth0"
4 changes: 4 additions & 0 deletions net/dhcp/config.d/dhcpd6
@@ -0,0 +1,4 @@
# Lunar configuration file for dhcpd
# /etc/config.d/dhcpd
#
DHCPD_ARGS="-q eth0"
27 changes: 0 additions & 27 deletions net/dhcp/dhcpd.conf.sample

This file was deleted.

7 changes: 0 additions & 7 deletions net/dhcp/dhcpd.config

This file was deleted.

6 changes: 2 additions & 4 deletions net/dhcp/init.d/dhcpd
Expand Up @@ -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
10 changes: 10 additions & 0 deletions 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
10 changes: 10 additions & 0 deletions 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

0 comments on commit ffbb478

Please sign in to comment.