diff --git a/salt/fwdriver/files/isc-dhcp-server.service b/salt/fwdriver/files/isc-dhcp-server.service new file mode 100644 index 0000000..3fd0532 --- /dev/null +++ b/salt/fwdriver/files/isc-dhcp-server.service @@ -0,0 +1,25 @@ +[Unit] +Description=ISC DHCP IPv4 server +Documentation=man:dhcpd(8) +Wants=network-online.target +After=network-online.target +After=time-sync.target +ConditionPathExists=/etc/default/isc-dhcp-server +ConditionPathExists=|/etc/ltsp/dhcpd.conf +ConditionPathExists=|/etc/dhcp/dhcpd.conf + +[Service] +EnvironmentFile=/etc/default/isc-dhcp-server +RuntimeDirectory=dhcp-server +# The leases files need to be root:dhcpd even when dropping privileges +ExecStart=/bin/sh -ec '\ + CONFIG_FILE=/etc/dhcp/dhcpd.conf; \ + if [ -f /etc/ltsp/dhcpd.conf ]; then CONFIG_FILE=/etc/ltsp/dhcpd.conf; fi; \ + [ -e /var/lib/dhcp/dhcpd.leases ] || touch /var/lib/dhcp/dhcpd.leases; \ + chown root:dhcpd /var/lib/dhcp /var/lib/dhcp/dhcpd.leases; \ + chmod 775 /var/lib/dhcp ; chmod 664 /var/lib/dhcp/dhcpd.leases; \ + if test -n "$INTERFACES" -a -z "$INTERFACESv4"; then INTERFACESv4="$INTERFACES"; fi; \ + ip netns exec fw dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf $CONFIG_FILE $INTERFACESv4' + +[Install] +WantedBy=multi-user.target