Best way to start Openhab on linux machines?

Hi, i´m running openhab on my odroid u3 with ubuntu 14. I made a directory “openhab” and copied all the files of my former running installation from my windows pc to the linux machine.

Now i will set up my linux machine from scratch and i was wondering, what would be the best method to install and start openhab. I will also install asterisk on this linux machine and some other programs.

So i think starting with seeing the complete openhab log on the console would not be the best thing. Now i use a script to start openhab hidden, so i have a clear linux console. (from openhab wiki)

So my questions are:

1.)
What´s the better way to install openhab? Simply copy the directory to my harddisk ans start or install directly from the repository in its given directory?

2.)
What´s the better way to start openhab for me? Hidden with script or visible? I think hidden, so i have a clear linux console if i want to work on it?

And in my current installation i have a strange behaviour: If i start openhab hidden, i get date and time in english syntax and letters (e.g. mondy, tuesday, …) - if i stop and restart openhab service, i will see all the log on my console, but i get german date and time (Montag, Dienstag, …). I changed the locales on my linux machine to german, but now i only get german date if i start the openhab service directly on the console.

  1. If you are using a Debian based Linux distro, which Ubuntu it is far preferable to use the apt-get installation method described here.

With this method you will be set up to get automatic updates as new versions are released. A new openhab user and group will be created which openHAB will run under which is far safer than having it run under root. File permissions will be automatically set for you which will avoid a lot of headaches. It will automatically configure it to run as a service. And all your files will be in standard locations:

  • binaries, scripts, addons, and webapp in /usr/share/openhab
  • logs in /var/log/openhab
  • configuration in /etc/openhab
  • other stuff in /var/lib/openhab
  1. See above. It is far better to have openHAB run as a service. The stuff that is printed to the console will be logged to /var/log/openhab/openhab.log

To watch what is written to this file in real time use tail -f /var/log/openhab/openhab.log

If you install via apt-get the weirdness like what you are seeing with the date and time should resolve itself.

Concerning the locale issue, I would suggest to set LC_ALL in the script, you are using to start openHAB. Use export LC_ALL=DE_de.utf8 in the script right before you call openHAB to be started and it should start with german settings.

I would like to have the complete openhab folder on my nas.

So can i install openhab with your mentioned method - then making virtual folders (with linux-command “ln” - don´t know the right name for this…) and copy the complete openhab-folder with configuration and all other parts to a mounted partition ony my nas? So i can backup the openhab-installation very easy. If the sd-card gets unreadable, openhab is still there on my harddisk.

Or is there a better way to do this? I will make my sd-card to mostly read - so i hope to extend the life. All things which will write to the disk should be copied to a ram-disk or a folder on my nas drive.

try rsync - you can use a script to backup full or partial paths of the installation. You can define how long a backup will be stored.
rsync is almost standard for backup over network, and rsync uses softlinks to refer to unchanged files, so there is a small impact for static data.
On the other hand this means, that you should not backup the logs or the persistence in more than two generations, because these files always differ to old ones - but you wouldn’t want old (in the meaning of not-up-to-date) persistence data anyway :wink:

[quote=“Udo_Hartmann, post:5, topic:6470, full:true”]
try rsync - you can use a script to backup full or partial paths of the installation.[/quote]

And if you cannot program your own rsync script (as me), use raspiBackup.sh :grin:

Edit: oh, sorry, your are on odroid … I have no idea if that script works with odroid (don’t think so) :sunglasses:

There are lots of ways you can to this. But the only directories you need to back up in openHAB are (using standard apt-get install for OH and bindings)

  • /etc/openhab
  • /usr/share/openhab/webapps // If and only if you have added custom icons to images are a webview for weather

If you install non-standard bindings (e.g. Habmin) you might also want to back up /usr/share/openhab/addons

Personally what I did was create a git server on my NAS because I don’t just want a backup but also a history of my edits. I put the two folders above into one folder on my user’s home directory and ln -s them to the places where openHAB looks for them. Then when I’ve made significant updates I just commit and push the changes to git.

Should my openHAB server crash all I need to is reinstall openHAB using apt-get, git clone the repo, and reset the two links. BTW, one of the things I have checked into git is a shell script to do just that.

But even with your NAS idea, all you need to keep are the folders you change, not the whole thing. If your server crashes it will probably still be faster and easier to reinstall via apt-get then to copy and create users and rest permissions and trying to figure out why its not working, oh yah I need to update that permission over there…

If extending the life of your SD card is a concern, there are many tutorials and postings on this forum which will tell you how others have done this. I would think you would want to put all of /var on your NAS and symlink it to /var, not just the openHAB stuff. While running, openHAB doesn’t write anywhere else but under /var but there are a ton of other services that also write to /var while you system is running.