How can I shutdown / restart my Linux server from the HABPanel?

  • Platform information:
    • Hardware: Raspberry Pi 3
    • OS: Raspbian 9
    • openHAB version: 2.5.2-1
  • Issue of the topic: I want to have a button that can shutdown or restart the OS from within HABPanel. If it’s possible, how can it be implemented?
    I searched about it, but couldn’t find any information on how to do it or whether it’s possible or not.

Maybe try searching again, there are quite a few threats out there. You will need to read up on how to use the exec binding (incl whitelisting commands for version 2.5.3 at least, which you are not, yet, using), maybe this will help as a start (search terms “exec reboot”):

But watch out, I believe this solution does not address the need to whitelist exec commands that was introduced in 2.5.3

It does not. It’s also not fully up to date for Debian Buster, but there are some comments about that in the thread. I haven’t updated to 2.5.3 yet, but when I do I’ll update the tutorial to include a mention of whitelisting.

Thank you very much @lipp_markus. I guess since “reboot/shutdown” it’s written together, it doesn’t show up in the search, or maybe I was searching in the wrong place.
I was being suspicious that nobody posted about it before.

Searches check the content of a post, not just the headings. But if you search for “shutdown” or “restart”, my tutorial doesn’t come up as one of the initial results.

Note that there is a distinction between “reboot” and “restart”: rebooting the RPi entirely, or restarting only the openHAB service. My tutorial doesn’t address restarting, which can’t be done via openHAB rules (since you have to execute separate commands to stop and start the service).

executeCommandLine(“sudo reboot”) might do the trick, provided you have openhab in the sudoers group. I didn’t test it like that but executeCommandLine(“ssh user@host somePrg…”) work w/o the need to care for whitelisting…