I've got a problem with this (shortened) systemd service file:
[Unit] Description=control FOO daemon After=syslog.target network.target [Service] Type=forking User=FOOd Group=FOO ExecStartPre=/bin/mkdir -p /var/run/FOOd/ ExecStartPre=/bin/chown -R FOOd:FOO /var/run/FOOd/ ExecStart=/usr/local/bin/FOOd -P /var/run/FOOd/FOOd.pid PIDFile=/var/run/FOOd/FOOd.pid [Install] WantedBy=multi-user.target
Let FOOd be the user name and FOO the group name, which already exist for my daemon
I need to create the directory
/var/run/FOOd/ before starting the daemon process
# systemctl start FOOd.service. This fails, because mkdir can't create the directory due to permissions:
... Jun 03 16:18:49 PC0515546 mkdir: /bin/mkdir: cannot create directory /var/run/FOOd/: permission denied Jun 03 16:18:49 PC0515546 systemd: FOOd.service: control process exited, code=exited status=1 ...
Why does mkdir fail at ExecStartPre and how can I fix it? (And no, I can't use sudo for mkdir...)