Stop and Restart Binding with a Batch

I have a binding that sometime need to be restarted. I be aware of this, because my monitoring system, Zabbix, are able to understand when Binding need to be restarded.
I would like to create a batch that Zabbix can execute, to restart the binding. The command i need to run inside Openhab console are:

bundle:stop "Souliss - Arduino based SmartHome Binding"
bundle:start "Souliss - Arduino based SmartHome Binding"

but I do’t know how to access to Openhab console, via an sh script.
Someone can helpme?


I haven’t tried it, but this might help you.

Tell your script to login to the consoel and execute the command you like.

To execute a command upon logging in use:

ssh openhab@localhost -p 8101 <sshpass stuff> <command>

I have PKI set up with my OH install (I recommend this over sshpass personally) so don’t have to use a password. I just ran:

ssh openhab@localhost -p 8101 bundle:stop "Souliss - Arduino based SmartHome Binding

I received the expected:

Error executing command: No matching bundles

If I remember correctly, you can do this by editing userdata/etc/ and pasting your public key (see this for generating ssh pub/priv keys if you haven’t already) located in .ssh/ minus the "ssh-rsa " part at the beginning and the user@host part at the end between openhab= and ,_g_:admingroup, replacing what is currently there.

Therefore when you log into karaf through ssh it will authenticate you based on your possession of the corresponding private key and not require a password.

I don’t remember if there was already an openhab line in this file. If not it should look like:

openhab=<public key>,_g_:admingroup

Now be aware that if you are running this script from OH it will be executing as the openhab user so the keypair generated needs to reside in ~openhab/.ssh, be owned by openhab, and only have user rw on the private key.