← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/maas/packaging-custom-dhcpd into lp:~maas-maintainers/maas/packaging

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/packaging-custom-dhcpd into lp:~maas-maintainers/maas/packaging.

Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~jtv/maas/packaging-custom-dhcpd/+merge/124594

Pre-imp (ages ago now) with roaksoax, who told me what name this file needs to have in order to get installed properly.


Jeroen
-- 
https://code.launchpad.net/~jtv/maas/packaging-custom-dhcpd/+merge/124594
Your team MAAS Maintainers is requested to review the proposed merge of lp:~jtv/maas/packaging-custom-dhcpd into lp:~maas-maintainers/maas/packaging.
=== added file 'debian/maas-dhcp.maas-dhcp-server.upstart'
--- debian/maas-dhcp.maas-dhcp-server.upstart	1970-01-01 00:00:00 +0000
+++ debian/maas-dhcp.maas-dhcp-server.upstart	2012-09-17 03:55:22 +0000
@@ -0,0 +1,54 @@
+description "MAAS instance of ISC DHCP server"
+author "Jeroen Vermeulen <jtv@xxxxxxxxxxxxx>"
+
+start on runlevel [2345]
+stop on runlevel [!2345]
+
+env CONFIG_FILE=/etc/maas/dhcpd.conf
+env PID_DIR=/run/maas-dhcp-server
+env PID_FILE=$PID_DIR/dhcpd.pid
+env LEASES_FILE=/var/lib/maas/dhcpd.leases
+
+# This is where we write what interfaces dhcpd should listen on.
+env INTERFACES_FILE=/var/lib/maas/dhcpd-interfaces
+
+pre-start script
+    if [ ! -f $CONFIG_FILE ]; then
+        echo "$CONFIG_FILE does not exist.  Aborting."
+        stop
+        exit 0
+    fi
+
+    if [ ! -f $INTERFACES_FILE ]; then
+        echo "$INTERFACES_FILE does not exist.  Aborting."
+        stop
+        exit 0
+    fi
+
+    if ! /usr/sbin/dhcpd -t -q -4 -cf $CONFIG_FILE > /dev/null 2>&1; then
+        echo "dhcpd self-test failed.  Please fix the config file."
+        echo "The error was: "
+        /usr/sbin/dhcpd -t -4 -cf $CONFIG_FILE
+        stop
+        exit 0
+    fi
+end script
+
+respawn
+script
+    INTERFACES=`cat $INTERFACES_FILE`
+
+    # Allow dhcp server to write lease and pid file.
+    mkdir -p $PID_DIR
+    chown dhcpd:dhcpd $PID_DIR
+    [ -e $LEASES_FILE ] || touch $LEASES_FILE
+    # Leases file and backup are owned by maas, but dhcpd can write them.
+    for LFILE in $LEASES_FILE $LEASES_FILE~; do
+        if [ -e $LFILE ]; then
+            chown maas:dhcp $LFILE
+            chmod g+w $LFILE
+        fi
+    done
+
+    exec /usr/sbin/dhcpd -f -q -4 -pf $PID_FILE -cf $CONFIG_FILE -lf $LEASES_FILE $INTERFACES
+end script