However, the service still couldn't create a PID-file after a reboot. So I tweaked a little bit longer.
It turns out that the isc-dhcp-server is started before the temporary filesystem "/run".
The lines "Wants=local-fs.target", "After=local-fs.target" and "sleep 3 ; \" solves that.
Security by apparmor requires the creation of the PID-file in "/{,var/}run/{,dhcp-server/}dhcpd{,6}.pid rw,". The lines
"if [ ! -d /run/dhcp-server ]; then mkdir -p /run/dhcp-server; fi; \"
"chown root:dhcpd /run/dhcp-server; \"
"chmod ug=rwx,o=rx /run/dhcp-server; \"
"sleep 1; \"
enables this.
This tweaking resulted in the following "/etc/systemd/system/isc-dhcp-server.services" file.
However, the service still couldn't create a PID-file after a reboot. So I tweaked a little bit longer.
It turns out that the isc-dhcp-server is started before the temporary filesystem "/run". local-fs. target" , "After= local-fs. target" and "sleep 3 ; \" solves that.
The lines "Wants=
Security by apparmor requires the creation of the PID-file in "/{,var/ }run/{, dhcp-server/ }dhcpd{ ,6}.pid rw,". The lines
"if [ ! -d /run/dhcp-server ]; then mkdir -p /run/dhcp-server; fi; \"
"chown root:dhcpd /run/dhcp-server; \"
"chmod ug=rwx,o=rx /run/dhcp-server; \"
"sleep 1; \"
enables this.
This tweaking resulted in the following "/etc/systemd/ system/ isc-dhcp- server. services" file.
======= ======= ======= ======= ======= ======= ======= =======
[Unit] man:dhcpd( 8) online. target fs.target online. target fs.target sync.target ists=/etc/ default/ isc-dhcp- server MountPoint= /run ists=|/ etc/ltsp/ dhcpd.conf ists=|/ etc/dhcp/ dhcpd.conf
Description=ISC DHCP IPv4 server
Documentation=
Wants=network-
Wants=local-
After=network-
After=local-
After=time-
ConditionPathEx
ConditionPathIs
ConditionPathEx
ConditionPathEx
[Service] =/etc/default/ isc-dhcp- server y=dhcp- server FILE=/etc/ dhcp/dhcpd. conf; \ dhcpd.conf ]; then CONFIG_ FILE=/etc/ ltsp/dhcpd. conf; fi; \ PID=/run/ dhcp-server/ dhcpd.pid; fi; \ dhcp/dhcpd. leases ] || touch /var/lib/ dhcp/dhcpd. leases; \ dhcp/dhcpd. leases; \ dhcp/dhcpd. leases; \
EnvironmentFile
RuntimeDirector
# The leases files need to be root:dhcpd even when dropping privileges
ExecStart=/bin/sh -ec '\
sleep 3 ; \
CONFIG_
if [ -f /etc/ltsp/
if [ ! -d /run/dhcp-server ]; then mkdir -p /run/dhcp-server; fi; \
chown root:dhcpd /run/dhcp-server; \
chmod ug=rwx,o=rx /run/dhcp-server; \
sleep 1; \
if [ ! "$DHCPDv4_PID" ] ; then DHCPDv4_
[ -e /var/lib/
chown root:dhcpd /var/lib/dhcp /var/lib/
chmod 775 /var/lib/dhcp ; chmod 664 /var/lib/
exec dhcpd -user dhcpd -group dhcpd -f -4 -pf $DHCPDv4_PID -cf $CONFIG_FILE $INTERFACESv4'
[Install] multi-user. target
WantedBy=
======= ======= ======= ======= ======= ======= ======= =
I hope this helps. Any suggestion to improve this service-file is appreciated :)