[SOLVED]Domoticz at 18.06.2

Almost done.
For anyone like me - who use domoticz with customised settings. There is custom config file from /etc/config/domoticz and startup script from /etc/init.d/domoticz.
Settings modified for:

  1. Used external partition /data/domoticz for both userdata and appdata&share
  2. Syslog was disabled.
  3. Logging path was changed to /data/logs/domoticz.log.
  4. Log level changed to "debug".
  5. WWW port was changed to 8084
  6. SSL initially disabled (not needed for me).
  7. Runing as root.
    etc.

/etc/config/domoticz:

config domoticz
	option disabled '0'
	option loglevel 'debug'
	option log '/data/logs/domoticz.log'
	# option syslog 'daemon'
	option www '8084'
	# option sslcert '/path/to/ssl.crt'
	# option sslkey '/path/to/ssl.key'
	# option sslpass 'passphrase'
	# option ssldhparam '/path/to/dhparam.pem'
	option sslwww '0'
	# CAUTION - by default, /var is not persistent accross reboots
	# Don't forget the trailing / - domoticz requires it
	option userdata '/data/domoticz/'

#config device
#	option product '658/200/0'
#	option symlink 'ttyACM-aeotec-zstick-g5'

#config device
#	option serial '526359'
#	option symlink 'ttyUSB-serial'

#config device
#	option usbif '2-1:1.0'
#	option symlink 'ttyUSB-port1'

#config device
#	option product '67b/2303/202'
#	option usbif '2-2:1.0'
#	option symlink 'ttyUSB-port2'

/etc/init.d/domoticz:

#!/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 www log 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 ssldhparam "$section" "ssldhparam"
	config_get sslwww "$section" "sslwww"
	config_get www "$section" "www"
	config_get log "$section" "log"
	config_get syslog "$section" "syslog"
	config_get userdata "$section" "userdata"

	[ -n "$loglevel" ] && procd_append_param command -debuglevel "$loglevel"
	[ -n "$syslog" ] && procd_append_param command -syslog "$syslog"
	[ -n "log" ] && procd_append_param command -log "$log"

	[ -d "${userdata}" ] || {
		mkdir -p "${userdata}"
		findLatestDatabase "$userdata"
		chmod 0770 "$userdata"
		chown root:root "$userdata"

	}

	# By default, ${userdata}/scripts is a symlink to /etc/domoticz/scripts
	# and the two dzVents directories under there which Domoticz will actually
	# write to at runtime are symlinked back to /var/lib again.
	[ -d "${userdata}/plugins" ] || ln -sf /etc/domoticz/plugins "${userdata}/plugins"
	[ -d "${userdata}/scripts" ] || ln -sf /etc/domoticz/scripts "${userdata}/scripts"
	for DIR in data generated_scripts; do
		[ -d /data/domoticz/dzVents/$DIR ] || {
			mkdir -p /data/domoticz/dzVents/$DIR
			chown root.root /data/domoticz/dzVents/$DIR
		}
	done
	procd_append_param command -userdata "$userdata"
	procd_append_param command -www "$www"

	[ -n "$sslcert" -a "${sslwww:-0}" -gt 0 ] && {
		procd_append_param command -sslcert "$sslcert"
						[ -n "$sslkey" ] && procd_append_param command -sslkey "$sslkey"
		[ -n "$sslpass" ] && procd_append_param command -sslpass "$sslpass"
		[ -n "$ssldhparam" ] && procd_append_param command -ssldhparam "$ssldhparam"
	} || procd_append_param command -sslwww "$sslwww"
}

start_service() {
	procd_open_instance

	procd_set_param command "$PROG"
	procd_append_param command -noupdates
	procd_append_param command -approot /data/domoticz/share/
#	procd_append_param command -wwwbind 192.168.1.1

	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 "root"

	procd_close_instance
}

findLatestDatabase() {
	destinationFolder=$1
	yourfilenames=`ls /root/domoticz*[0-9].db`
	LatestDate=0
	for eachfile in $yourfilenames
	do
   	   echo $eachfile
   	   if [[ "${eachfile//[!0-9]/}" > "$LatestDate" ]]; then
      		LatestDate=${eachfile//[!0-9]/}
   	   fi
	done
	if [ "$LatestDate" -gt "0" ]; then
	    cp "/root/domoticz${LatestDate}.db" "${destinationFolder}domoticz.db"
	fi
}