Problem getting exec binding to execute command

I’m wondering if I need to try a different linux distrobution? Maybe I should try debian or an older ubuntu server edition.

edit /etc/default/openhab

The fifth line probably reads:

USER_AND_GROUP=openhab:openhab

change the last bit so it reads “root:root” and restart. Then openHAB should be running as root

BINGO! Looks like I had a permissions issue all along, which I guess isn’t too surprising to me, I just didn’t know the correct way to change the running user. Big thanks to Dan12345 for filling me on on how to change the openhab user. I should also thank rlkoshak since he was one of the first post replies that told me to check the OpenHAB user and I just assumed that it was running under the account that I started it from.

So relieved to have this fixed, was driving me nuts.

excellent - you’re very welcome!

Related to the topics you solved in this thread.

I did a clean fresh install on a new SD card. I was running Raspian Debian Wheezy and want to run Debian Jessie.

The openHAB installation went well but I came across a problem which I have not seen before. As I am also using some scripts I need to change the user and group to root

 USER_AND_GROUP=root:root

In Debian Jessie I get the following error when trying to start openHAB

root@raspberryPI:/etc/init.d# systemctl status openhab -l
● openhab.service - Starts and stops the openHAB Home Automation Bus
Loaded: loaded (/usr/lib/systemd/system/openhab.service; disabled)
Active: inactive (dead)
Docs: http://www.openhab.org

Oct 16 17:52:01 raspberryPI openhab.sh[4220]: 2015-10-16 17:52:01.382 [INFO ] [.o.u.w.i.servlet.WebAppServlet] - Stopped Classic UI
Oct 16 17:52:01 raspberryPI systemd[1]: Stopped Starts and stops the openHAB Home Automation Bus.
Oct 16 17:52:06 raspberryPI systemd[1]: Starting Starts and stops the openHAB Home Automation Bus…
Oct 16 17:52:06 raspberryPI setpermissions.sh[5173]: setting permissions and owner root:root recursively for /var/lib/openhab
Oct 16 17:52:07 raspberryPI setpermissions.sh[5173]: setting permissions and owner root:root recursively for /var/log/openhab
Oct 16 17:52:07 raspberryPI setpermissions.sh[5173]: setting permissions and owner root:root for /usr/share/openhab/webapps/static
Oct 16 17:52:07 raspberryPI setpermissions.sh[5173]: setting permissions and owner root:root for /etc/openhab/jetty/etc/keystore
Oct 16 17:52:07 raspberryPI setpermissions.sh[5173]: setting permissions and owner root:root for /etc/openhab/configurations/users.cfg
Oct 16 17:52:07 raspberryPI systemd[1]: Started Starts and stops the openHAB Home Automation Bus.
> Oct 16 17:52:08 raspberryPI openhab.sh[5381]: Invalid Configuration LocationThe configuration area at ‘/var/lib/openhab/workspace’ is not writable. Please choose a writable location using the ‘-configuration’ command line option.

Somehow the /var/lib/openhab/workspace is not writeable? Anybody has an idea?

Have you enabled the root user (set a password and can log onto the
terminal as root)?

No have not an account for root / is it required in Jessie? Also have not set it up on the wheezy

To find a solution I did now enable the root account (incl. password). This results in the same behavior as above (/var/lib/openhab/workspace not writeable)

So, what are the permissions on that folder? Can you cd, ls, touch a file in it, etc?

On my install that folder is owned by openhab:openhab and has drwxr-xr-x permissions. So theoretically only root and the openhab user should be able to write to it. But with you running as root there should be no problem unless the permissions are really messed up, or the folder doesn’t exist.

That seems all to be ok - for openhab and root.

When having set USER_AND_GROUP=openhab:openhab the following

root@raspberryPI:/var/lib/openhab/workspace# ls -la
total 24
drwxr-xr-x 6 openhab openhab 4096 Oct 16 22:49 .
drwxr-xr-x 4 openhab openhab 4096 Oct 16 15:58 …
drwxr-xr-x 3 openhab openhab 4096 Oct 16 22:40 .metadata
drwxr-xr-x 3 openhab openhab 4096 Oct 16 15:59 org.eclipse.core.runtime
drwxr-xr-x 3 openhab openhab 4096 Oct 16 15:59 org.eclipse.equinox.app
drwxr-xr-x 3 openhab openhab 4096 Oct 16 22:49 org.eclipse.osgi

When having set USER_AND_GROUP=root:root the following:

drwxr-xr-x 6 root root 4096 Oct 16 22:49 .
drwxr-xr-x 4 root root 4096 Oct 16 15:58 …
drwxr-xr-x 3 root root 4096 Oct 16 22:40 .metadata
drwxr-xr-x 3 root root 4096 Oct 16 15:59 org.eclipse.core.runtime
drwxr-xr-x 3 root root 4096 Oct 16 15:59 org.eclipse.equinox.app
drwxr-xr-x 4 root root 4096 Oct 16 22:51 org.eclipse.osgi

What about the workspace folder itself?

Not convinced anymore that it is a problem but not sure what else it could be.

That folder is also good - permissions are set accordingly (root and openhab).

Well, hope somebody had similar issues with Jessie Debian (and found a solution)

Total WAG. What happens if you stop OH, rename the workspace folder to something else (e.g. workspace.broken), and start it again.

If my suspicion is correct, everything in that folder gets autogenerated so it will get recreated the next time OH starts. It’s the last little trick in my bag.

Have not thought of that WAG. Sounds like worth a try …

  • Start OH as USER_AND_GROUP=openhab:openhab
  • No workspace dir present
  • Result: Directory is created and OH runs. When I stop and start OH again with root:root it runs into the same problems (not able to write to /var/lib/openhab/workspace)

  • Start OH as USER_AND_GROUP=root:root
  • No workspace dir present
  • Result: Directory cannot be created (error - see below).

Oct 17 08:48:53 raspberryPI openhab.sh[25384]: Invalid Configuration LocationThe configuration area at ‘/var/lib/openhab/workspace’ could not be created. Please choose a writable location using the ‘-configuration’ command line option.


I am puzzled here and imho it seems that when running in root:root setup the java process does not have the right permissions for the /var/lib/openhab/workspace dir …? Again I have not seen this on Wheezy only on the (fresh) Jessie distr.

OK finally got it figured out (SOLVED) - to sum things up:

When changing USER_AND_GROUP on Raspian Jessie Debian distr. to root do the following:

1> /etc/default/openhab - change to root (USER_AND_GROUP=root:root)
2> /usr/lib/systemd/system/openhab.service
- change user and group inside the file
User=root
Group=root
- systemctl daemon-reload
- systemctl start openhab

Pretty simple when you know what to change. Maybe we can document it somewhere?

4 Likes

Interesting. So Raspian Jessie appears to have transitioned to systemd instead of Upstart. Good to know.

I’ve left my Pis on Wheezy for now. It works and I don’t want to mess with it for an update that doesn’t really do much for me just yet.

Considering to move back to Wheezy as well - ran into some other topics and costing too much time to solve. Will ask in another thread if other people are running on Jessie and how their experience was :confused:

I’ve managed to fix my problem to shutdown ubuntu using the exec binding and ssh. What i’ve done:

from my server i’ve executed the command (did the same thing from htpc to server) :

ssh-keygen
ssh-copy-id htpc@192.168.1.201

after this i was able to ssh without the need to give a password.
I start openhab using sudo sh start.sh. I’ve altered my permissions using

sudo chown -R server Openhab/
sudo chmod -R 775 Openhab

This enables me to start openhab using the correct user (server). Before this, it was opening openhab as root and I couldn’t ssh login without giving a password.
Then I altered my shutdown command using:

ssh htpc@192.168.1.201 sudo shutdown -h now

I’ve added the -h parameter because else ubuntu wouldn’t shut down properly. After this you have to edit the /etc/sudoers file. Because you need to be root to shutdown I have to give the htpc user root acces to shutdown ubuntu. This is done by using:

sudo visudo

#add the following line:
htpc ALL=NOPASSWD: /sbin/poweroff, /sbin/start, /sbin/stop

Now everything is working fine :smile:

Hi Jeroen!

I just want to thank you for writing the solution here, you have saved me a lot of time! I didn’t know what was going on and I was going crazy.

Best regards,

Aitor

Hi,

after I have changed the user and role of openhab like in the post of Jeroen, I get a new error:

java.io.IOException: Cannot run program "/etc/openhab/configurations/scripts/setBetriebSparM1_1.sh": error=13, Permission denied

I will start a bash script. Within the script I do some stuff with ssh.
I tried to re-set the permissions for the script file

sudo chmod +x /etc/openhab/configurations/scripts/setBetriebSparM1_1.sh sudo chmod 777 /etc/openhab/configurations/scripts/setBetriebSparM1_1.sh

Any ideas what I can do?