packages/utils/domoticz/files/domoticz.init
Stijn Tintel 476dae33c7 domitcz: fix dzVents scripts
Domoticz 3.8153 introduced support for dzVents. Unfortunately this was
broken by the 902_add-scripts-path, which attempts to make Domoticz more
FHS-compliant instead of throwing everything under /opt/domoticz.

The problem is that dzVents scripts added via the webinterface will be
generated on the filesystem. With the 902_add-scripts-path patch,
Domoticz tried to write this to "scriptsdir/dzVents/generated_scripts".
As the scriptsdir contains scripts that come with upstream, and are not
meant to be changed, this defaults to /usr/share/domoticz/scripts, which
is not writeable, so Domoticz is unable to write the script to the
filesystem. What is worse is that this silently fails.

Fix this by moving the generated_scripts dir to
"userdatadir/generated_scripts". The userdatadir defaults to
/var/lib/domoticz, which is writeable.

Additionally, since this patch does more than just adding the scripts
path, rename it to something more appropriate.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2017-09-20 01:00:41 +03:00

55 lines
1.6 KiB
Bash

#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
PROG=/usr/bin/domoticz
PIDFILE=/var/run/domoticz.pid
start_domoticz() {
local section="$1"
local loglevel sslcert sslpass sslwww syslog userdata
config_get loglevel "$section" "loglevel"
config_get sslcert "$section" "sslcert"
config_get sslkey "$section" "sslkey"
config_get sslpass "$section" "sslpass"
config_get sslwww "$section" "sslwww"
config_get syslog "$section" "syslog"
config_get userdata "$section" "userdata"
[ -n "$loglevel" ] && procd_append_param command -loglevel "$loglevel"
[ -n "$syslog" ] && procd_append_param command -syslog "$syslog"
[ -n "$userdata" ] && {
mkdir -p "${userdata}/generated_scripts"
chmod -R 0770 "$userdata"
chown -R domoticz:domoticz "$userdata"
procd_append_param command -userdata "$userdata"
}
[ -n "$sslcert" -a "${sslwww:-0}" -gt 0 ] && {
procd_append_param command -sslcert "$sslcert"
procd_append_param command -sslwww "$sslwww"
[ -n "$sslkey" ] && procd_append_param command -sslkey "$sslkey"
[ -n "$sslpass" ] && procd_append_param command -sslpass "$sslpass"
} || procd_append_param command -sslwww 0
}
start_service() {
procd_open_instance
procd_set_param command "$PROG"
procd_append_param command -scripts /usr/share/domoticz/scripts/
procd_append_param command -wwwroot /usr/share/domoticz/www/
config_load "domoticz"
config_get_bool disabled "$section" "disabled" 0
[ "$disabled" -gt 0 ] && return 1
config_foreach start_domoticz domoticz
procd_set_param pidfile "$PIDFILE"
procd_set_param respawn
procd_set_param stdout 0
procd_set_param term_timeout 10
procd_set_param user "domoticz"
procd_close_instance
}