Closed BClark09 closed 7 years ago
Hi @ThomDietrich, fairly big change to allow openHAB distribution's version of oh2_dir_layout to be used. Would you mind going through it and maybe testing the changes? I'll be going through it a lot before merge.
I've done this by adding a second /etc/default/
file which contains the paths, and edited the init.d and systemd service starters to use them as environment vars.
Hey @BClark09, looking at the code all small changes look good. I can see that you took great care to make everything POSIX sh compliant. I've left a few comments.
I'm pretty much packed with events all week and will be traveling over the weekend. I'm afraid I can't test much...
Thanks @ThomDietrich, very helpful. Don't worry about testing, I can setup my usual procedure for each type of Unix on a virtual box and see if I get the same functionality. I don't expect to merge this soon.
I've done this by adding a second /etc/default/ file which contains the paths
May I ask why? Seems highly unusual...
May I ask why? Seems highly unusual...
Absolutely, it didn't seem like it fit anywhere else, and I'm worried that adding these variables to the existing /etc/default/openhab file will skip by some users, who would idly select the default "no" for overwriting it. Do you have any suggestions for this? I guess I could make sure these env vars are set in both init.d and systemd .service and use /etc/default/openhab to overwrite them if they exist.
Okay that sounds in line with what I've commented above. In my understanding everything below /etc/default should be optional and should be expected to be missing or wrong. Hence we should make sure to check all data provided via /etc/default/openhab2
Edit: found a source https://askubuntu.com/a/843068
Awesome, that's what I'll do then. Thanks Thomas!!
@ThomDietrich, Thought it'd be best to go through systemd here, from the beginning to clarify things:
User=
and Group=
are systemd specific and do not expand, these have to be written into the conf file and cannot use variables. The exception to this is that you can use %i in a template, the %i is replaced with [param] when you start the service with start openhab2@[param].service
. Otherwise, you'd make the file a conffile and allow users to type their configuration in.
At this point in the PR, openhab2.service is NOT a conffile, and is replaced on each update. This was done to make sure that everyone updates to the new format. The path environment variables must be set for this service to run correctly, so if we kept this as a connfile then I can be sure some people would be confused as to why their systems are failing.
So the way I see it, we have the following options (I'm currently leaning towards 1):
start openhab2@root.service
. People that use openhab as the user would still need to write openhab2@openhab.service
.Unless you can think of an alternative? :thinking:
Based on tests, and reading up on the use cases of setting root as the user and group for openHAB. I've decided that it's best to keep openhab2.service as static file, and that /etc/default/openhab2 can be used for path variations.
In my opinion, the user and group for openHAB should never be root. GPIO, dialout and tty groups exist for this reason. Those who really need to set a different user can do so on each update.
I can as always be persuaded the other way if you think differently?
I agree with this approach. The user should not execute openHAB as root! We shouldn't provide this option as a feature. The problems I know of can all be solved by adding openhab to gpio/dialout/tty, by setcap or by adding a sudo exception. If a user really knows what he is doing, he will know where to mess around to run openHAB as root.
Last commit looks good. Great work @BClark09
Awesome, thanks again Thom! I've updated the PR with hopefully the final changes. I've pushed packages to the test repo and will test them soon.
Changes, work across Ubuntu <14, Debian 8&9, and Fedora so will merge now and monitor any problems.
Allowing for changes upstream to pass through. Also allows users to set their own.
closes #59
Signed-off-by: Ben Clark ben@benjyc.uk