Reboot from Docker

Tags: #<Tag:0x00007f745a5926a0> #<Tag:0x00007f745a592588> #<Tag:0x00007f745a5924c0>
  • Platform information:
    • Hardware: CPUArchitecture/RAM/storage Pi 3B+
    • OS: what OS is used and which version Docker
    • Java Runtime Environment: which java platform is used and what version Docker
    • openHAB version: 2.4.0
  • Issue of the topic: please be detailed explaining your issue

Hi, I try to build a swich for openhab-docker to reboot the host system…for that, I wanted the switch to write the value 1 into a docker mounted volume (host can also read). A cronscript on the host than checks, if the one is present…when it is so, the host reboots. How is the format of the command I have to input in the exec binding? because echo “1” /openhab/scripts/reboot.trigger doesn’t seem to work…Any Ideas?

echo "1" > /openhab/scripts/reboot.trigger

would be more apropriate.

In close to 100% of cases there’s no need for a reboot and certainly not for a SW switch for this.
This question keeps appearing over and over but it’s always an instance of the XY problem:
the poster lazily wants to reboot OH instead of investigating his problem to find a proper solution.
Sorry for refusing to help with that.

1 Like

Yes thanks had a typo in the description…I tried it as you suggested but doesn’t help…

echo seems not to work …

Perhaps you try it like this

rule"Set Reboot Trigger"
when
  Item Reboot changed to ON
then
  executeCommandLine("touch /openhab/conf/scripts/reboot.trigger")
end
#!/bin/bash

if [ -f /volume1/docker/openhab/conf/scripts/reboot.trigger ]; then
  rm /volume1/docker/openhab/conf/scripts/reboot.trigger
  sudo reboot
fi

Your host system will not look for the 1 in the reboot.trigger, your host will have to check if the file exists.

Thanks I will try this tomorrow :slight_smile:

1 Like

Can you describe how the Item would be setup without a thing, to only trigger this rule? cause it is not shown in the control section if not connected to a thing…

In PaperUI Controll Section only Item’s with Things …

To show Items in BasicUI and Smartphone App you must edit your Sitemap.

Switch item=Reboot label="Reboot" //Switchable

Text item=Reboot label="Reboot"  //Not Switchable, only shows Status

Ok thanks :slight_smile: found a way around that with the exec binding. I just insert the command # which is nothing and I bind the item to the exec binding then you see the item everywhere :slight_smile: still have to test the rule @ei_Gelb_Geek thanks for contribution :slight_smile: I check it tomorrow :slight_smile: by the way: here is the inspection for the host-script that checks every minute if there is a 1 in the file. If so, it shuts down the docker host: https://github.com/gersilex/apcupsd-docker/blob/master/host-trigger-check.sh