Reboot on openHab 3

Yes that worked.

Thank you @rpwong and @rlkoshak for your great help!

Maybe you can add to your guide adding the reboot as well:

# Allow openhab user to execute shutdown, poweroff, and systemctl commands
openhab   ALL=(ALL) NOPASSWD: /sbin/shutdown, /sbin/poweroff, /sbin/systemctl /sbin/reboot

I’ve done just that. I wanted to make sure it solved your problem before making the edit.

If I recall correctly, when Debian Buster came out, it was unclear which commands would work in both Buster and Jessie. I had written this note:

EDIT: The code below has been updated to delete /sbin/reboot and add /sbin/shutdown and /sbin/systemctl, which should enable this tutorial to work with both the Debian Jessie and the newest Debian Buster operating systems. However, I have not personally tested/confirmed that it works on Debian Buster. See the discussion comments for more information, and please provide feedback if it does/doesn’t work for you.

However, I didn’t update the rule to match. Now that we know sbin/reboot works in Buster, it’s easiest to just add that back.

The problem was that the zram implementation in openHABian didn’t work correctly when one used reboot as opposed to shutdown -r. That has since been resolved so both commands work correctly with zram now.

1 Like

Well I wouldn’t call it misconfigured. It’s the default, and for good reasons so.
Under normal operating conditions, the openhab user should not need to have access to system level privileges.
The OP shouldn’t be booting his server anyway.

Misconfigured for what the OP wants to accomplish.

Hello there! I’m moving to OH3 and at this point i’m copying rules from my OH2 environment. I have 2 rules (working on OH2) that launch a reboot of service/shoutdown the servoce of OH2,but won’t work on OH3.
My command is: sudo systemctl restart openhab.service
I’ve followed above steps to update sudoers etc,but won’t work.
Btw, raspi reboot/shutdown are working correctly. I run rule on openhabian image and the command has been executed with executeCommandLine.
Last,if i run from ssh the command sudo systemctl restart openhwb.service, it shows me an info and then restart the service correctly without any other input.
Any help from any guru will be appreciated a lot.

Thanks!

Show your rules to get more help.
You adapted your executeCommandLine syntax from OH2 to the syntax of OH3 ?
In case it does not work get the returned string from executeCommandLine and print it to loginfo to check what the output message / error message is.

thx i’ve solved it adding a new path to sudoers file :wink:

1 Like