I have seen a post about a start script to autostart OH2 on the pi at reboot somewhere on here, but it referred to change the first part of the OH1 script. It didnt specify if the script that was provided was complete or not. Can anyone help me with a script to autostart OH2 on the pi.
Starting script openhab 2 beta1
Auto-starting openHAB 2 with Ubuntu
I have the same question.
The way I did it was to create a short systemd script to wrap about the start.sh included in the OH2 zip. Doing it this way means you don't have to modify the included script and writing a systemd script seems quite straight forward (compared to the previous
I'm not at home so can't share the systemd script at the moment but if you haven't got this sorted I'll share when I get home.
I would like to use your technique.
When you get home and get a chance could you post the details?
As mentioned here, the start scripts will change in 3 days time - so better don't spend too much effort on this right now!
@Kai any more details on this? Will the new OH2 start up script be something that can be wrapped in a systemd script?
Currently my systemd script calls start.sh so as long as it still functions in a similar manner then it shouldn't cause any problems.
Here's my systemd script:
[Unit] Description=Starts and stops the openHAB Home Automation Bus Documentation=http://www.openhab.org Wants=network-online.target After=network-online.target [Service] Type=simple GuessMainPID=yes User=**enter your openhab username here** ExecStart=/opt/openhab2/start.sh ExecStop=kill -SIGINT $MAINPID Restart=on-failure WorkingDirectory=/opt/openhab2 [Install] WantedBy=multi-user.target
Create a file with the above contents (I simply called mine "openhab.service") in /lib/systemd/system/.
Run the following command:
sudo systemctl enable openhab
sudo systemctl start openhab
You can then check if it's running with the following
sudo systemctl status openhab
Thanks Daniel, it works.
Other beginners like me note that the openhab.service file goes in:
and change the user name and paths to reflect your user and where you installed (/opt/openhab in my case).
When you enable it, it should symlink to /etc/systemd/system/openhab.service, or at least it did on my Raspberry Pi 2 running Raspbian Jessie.
However I'm glad it works for you
Here it is: https://github.com/openhab/openhab-distro/blob/master/docs/sources/getting-started.md#registering-openhab-as-a-system-service-in-the-os
Try it out and let me know if there are any issues with it!
Update: It seems that this functionality does not work on the Raspberry Pi, see https://github.com/openhab/openhab-distro/issues/63#issuecomment-171034610
@danielwalters86 Maybe you could add some information about a solution on the RaspPi to https://github.com/openhab/openhab-distro/blob/master/docs/sources/getting-started.md#registering-openhab-as-a-system-service-in-the-os?
I've been using my Win10 PC to test the new OH, I'll try it on the RPi tonight hopefully and update the wiki if the above approach works.
ok, thanks. Would be nice if you could also try the Karaf-based auto-start scripts on Win10, so that we know that at least that works!
I did not have good luck with the auto start service, nor my Raspberry Pi today.
I loaded a fresh OH2 beta download on the Pi, copied my config over (from my existing OH2 alpha install) and the runtime works (generally - I get a few errors in the logs) but when I interact with the items through the widgets, I can see the commands firing but the physical object does not react i.e. lights don't turn on/off, heating won't go on/off.
When I go back to my last OH2 alpha nightly everything works again (using same config) so I need to try and figure out what's going wrong with this new setup.
I tried to install the service on Win10 and I couldn't not get the "openHAB-service.bat" to run with the install argument. Received the following message:
C:\Users\Daniel\Downloads\openhab-online-2.0.0-SNAPSHOT\runtime\karaf\bin>openHAB-service.bat install wrapper | Unable to set working directory to: /C:/Users/Daniel/Downloads/openhab-online-2.0.0-SNAPSHOT/userdata/ (The filename, directory name, or volume label syntax is incorrect. (0x7b)) Unable to get the current logfile size with stat: The filename, directory name, or volume label syntax is incorrect. (0x7b)
starting openhab2 via systemd works fine. so, in fact, there is no need for the karaf service wrapper, obsoleting https://github.com/openhab/openhab-distro/issues/63#issuecomment-171034610
I simply used @danielwalters86 unit file and everthing is fine. q clean solution for all systemd enabled systems.
Stopping works fine, too.
I used the dirty way and placed the unit file in /etc/systemd/system ... packages (and their maintainer ) should not use this location, but the result will be the same.
Maybe there is a way to get karaf to produce and enable the above file?
@danielwalters86 I had the same problem but I noticed the path looked wrong. Keep in mind I don't really know what I'm doing....
I removed the extra "/" in from of the path in openHAB-wrapper.conf under wrapper properties where it defines a few paths.
Then I had to allow write permissions on the karaf directory again.
Run the install with administrator privileges.
It now looks like it installed correctly but when I run "net start "openHAB" I receive an error:
"The service is not responding to the control function"
@danielwalters86: I tried your systemd script following your instruction (you also PRed, however, on my Raspi 2 with Raspbian Jessie the command
sudo systemctl enable openhab2
Failed to execute operation: No such file or directory
assuming I've put my unit into a file openhab2.
As @jtmoderate876 suggested, I had to put the file not anywhere on the disk but exactly in /lib/systemd/system/ and had to suffix it with .service.