Install OpenHAB2 on emonSD / emonPi

Using rc.local isn’t a good idea, not only is rc.local dependent on zero errors from all it’s entries to complete, it also doesn’t run untill after all the services are started, so then you have to restart any that have failed to start prior to the rc.local running, it undermines the whole purpose of the start up processes, dependencies and order etc.

Either the init.d script should create the folders as emonhub does or if using systemctl adding something like

PermissionsStartOnly=true
ExecStartPre=-/bin/mkdir -P /var/log/openhab2
ExecStartPre=/bin/chown -R openhab:openhab /var/log/openhab2/

before the ExecStart line in the service unit, or as in this case you already have an “ExecStartPre=/usr/share/openhab2/start_pre.sh” line in there you could simply add the log file creation to that additional file, although IMO I would possibly consider moving the contents of that script directly into the service unit to avoid the need for a separate script (and whether it’s executable) and to maximize on the systemctl error logging.