openhab / openhab-linuxpkg

Repo for Linux packages
Eclipse Public License 2.0
18 stars 33 forks source link

client script misbehaving since recent build #80

Closed ThomDietrich closed 6 years ago

ThomDietrich commented 6 years ago

Hello, I suspect this to be one of the implications of the recent Karaf upgrade or the recent changes here. It seems like the client script is not working properly any longer. I have an idea what's going on but I believe @BClark09 has a better understanding of all these files by now. Please let me know how I can help fix this issue! ;) Best!

sudo su -s /bin/bash -c '/usr/share/openhab2/runtime/bin/client' openhab
mkdir: cannot create directory ‘/usr/share/openhab2/userdata/tmp’: No such file or directory
KARAF_BASE is not valid: /usr/share/openhab2/userdata
BClark09 commented 6 years ago

sudo su -s /bin/bash /usr/share/openhab2/runtime/ KARAF_BASE

The combination has not exported the OPENHAB_* variables, so KARAF assumes that it'll follow a single parent directory. So your way of calling the client script will have stopped working when openHAB and linuxpkg started sharing the same scripts. Just a question, why do you run the client this way? does running this command as root do anything differently, I was under the impression that the console shouldn't need any root access.

Try exporting the variables manually, or first calling /etc/profile.d/openhab2.sh first if you absolutely have to run the file like that. You can also use -E for sudo (without su) to preserve the environment variables.

This won't be an issue when the openhab console or openhab client command is included in linuxpkg, even if the client requires sudo.

BClark09 commented 6 years ago

In other-words, what's wrong with running /usr/share/openhab2/runtime/bin/client as an executable and without sudo?

ThomDietrich commented 6 years ago

Makes sense. Yes the script works just fine when executed by my user. The way I'm calling it, it's executed by user openhab. I honestly do not remember the reason for that step. However an alias with that command is included with openHABian. I should probably remove it.

BClark09 commented 6 years ago

If there was a reason, and you need to execute by user openhab and with sudo, then:

sudo -E su -s /bin/bash -c '/usr/share/openhab2/runtime/bin/client' openhab 

will work as a direct command, but I'd advise using /bin/sh instead.

ThomDietrich commented 6 years ago

direct command is perfectly fine. I'll change it accordingly. Thanks for your help ;)