Init script of community/domoticz package fails to properly start domoticz
When trying to start the domoticz daemon via the init script, it immediately crashes. This is caused by the PID file, which both the domoticz process (due to the explicit
-pidfile arguments) as well as start-stop-daemon (due to
command_background=YES) try to create. Since start-stop-daemon creates the PID file as root, the domoticz process is unable to overwrite the file (which it probably shouldn't do anyway) and then immediately terminates.
command_args line in
command_args="-daemon -userdata $userdata -approot $approot -pidfile $pidfile $daemon_args"
command_args="-userdata $userdata -approot $approot $daemon_args"
fixes the issue.
false instead, does not seem to work, because the PID file created by domoticz has its read permissions set to allow only the owner to read it, so that start-stop-daemon does not recognize it as running.