It seems like several people here on the forum managed to install openHAB in a FreeNAS jail. Does somebody have any instructions on how to do this? Or even just some pointers on how to start out? Thanks.
Documenting my progress
Create a jail with the name ‘openHAB’ from within the webGUI
Install openjdk8 and git on FreeBSD:
pkg install openjdk8 git
Install maven via ports (otherwise it’s going to download jdk7 for some reason)
cd /usr/ports/devel/maven33
make install clean
Create a local clone of the openHAB repository by running
git clone https://github.com/openhab/openhab
go into the new ‘openhab’ directory and install (this will take a few minutes - it took 24’ for me) openHAB
cd openhab
mvn clean install
Create a local clone (is that right? of the nrjavaserial repository by running (and I’m not quite sure from which directory this should be done - from the maven33 one or openhab one - but I am trying the former)
cd ..
git clone https://github.com/NeuronRobotics/nrjavaserial
cd usr/ports/devel/maven3/nrjavaserial
patch -p0 -l -i freebsd.patch
When I run the patch, it asks me the following:
root@openHAB:/usr/ports/devel/maven3/nrjavaserial # patch -p0 -l -i freebsd.patch
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: nrjavaserial/Makefile
|===================================================================
|--- nrjavaserial/Makefile (revision 185)
|+++ nrjavaserial/Makefile (working copy)
--------------------------
File to patch:
Does anybody have any idea on what to enter here? I tried Makefile, which it accepts; but it then asks me for a pom.xml, which is not in that directory…
Thanks!
I am just starting in FreeNAS 11.2 and especially an iocage jail since this is the future supported format on FreeNAS.
I found a very detailed guide for this for… HomeAssistant.
The best thing is he also shows how to install seperate iocage jails for Mosquitto and TasmoAdmin. I think that this is a great way for systems independence. Seperate jails for every service. And seperate data volumes mounting for everything. Mosquitto, Node-Red, Influx DB, Grafana etc…
I think a similar guide is essential for OH. As i said i am just staring the process, don’t know where it’s going to lead
This is going very well… I have seperate jails for every service and OH, i made 3 mount points for OH on a seperate FreeNAS Dataset and these mount points are SMB shares, just like Openhabian installations.
I am so happy to leave the Raspi and SD cards… Now i am on RAID security, i have snapshots ability for the OH data and jail.
Maybe the part of moving the OH data on a seperate dataset is not necessary, thoughts welcome…
I am making small steps on my free time on this, but it seems pretty easy and strait forward if you are a bit familiar.
The easiest part was the OH installation on a jail. There is a maintained FreeBSD port currently with OH2.4 perfectly installed. On a service owned by openhab:openhab user.
I also started with migrating my setup to a freenas iocage. I got stuck because is seems openhab on freenas cannot access the serial ports on my system. Do you also have this issue?
I am only using this as a network server. nothing physical is going to be pluged or wired, no USB either.
So i can’t help you with that.
Everything i need to feed to the system, i do it with ESP8266 nodes. For example, i am using Modbus. I didn’t use a USB-RS485 converter. I used a Tasmota-ESP8266 with TTL-RS485 converter.
I have moved my OH instance to OH.
You should create new jail and run:
pkg install openhab2
and add to /etc/rc.conf inside jail:
openhab2_java_opts="-Djava.net.preferIPv4Stack=true"
openhab2_enable=“YES”
I have installed openhab2 in a jail and thought it would be nice to do a quick summerize:
Nothing realy new. But I had to visit al lot of websites to gather all the correct information.
Like mentioned before:
Create jail.
From within the jail
pkg update
pkg install openhab2
pkg install openhab2-addons
edit rc.conf. nano -w /etc/rc.conf
add the lines:
openhab2_java_opts="-Djava.net.preferIPv4Stack=true"
openhab2_enable=“YES”
You should be able to open the website of openHab(default http://ip-adres:8080).
To add an usb stick en show up in the jail (in my case the Aetoec Z-stick).
7. Create a script in the Freenas host (on the location of your choosing). nano zwave-ruleset.sh
Add the script as a startup script in the FreeNas Gui.
Add the created alternative devfs ruleset to your openHAB jail (ruleset 99 created in step 7).
screenshot 2 next reply
Restart your server.
From within your openHAB jail add the ‘openhab’ service account to the ‘dialer’ group. To be able to acces the z-wave usb stick.
screenshot 3 next reply
Go to the openHAB website and install the ‘Z-Wave binding’.
Go to the ‘Things’ tab and add the usb z-stick.
Serial port should be configured something like /dev/cuaU0
first i upgraded the jail from 11.2-RELEASE to 11.3-RELEASE. have done this to 6 more jails, everything went smooth. I have done that because 11.2 now is EOL and some updates are sending notifications…
Notes from UPDATING
These upgrade notes are taken from /usr/ports/UPDATING
2019-12-21
Affects: users of misc/openhab2
Author: netchild@FreeBSD.org
Reason:
If you upgrade from a pevious version, make a backup of
/var/db/openhab2
read about the breaking changes in the release notes at
https://github.com/openhab/openhab-distro/releases/tag/2.5.0
and run
%%PREFIX%%/libexec/openhab2/runtime/bin/update.freebsd
which takes care about changes for:
- Textual Configuration
- Next Generation Rule Engine
i run the script
/usr/local/libexec/openhab2/runtime/bin/update.freebsd
and i think i am done. restart the jail and…
NOTHING. nothing works.
i have to search what is wrong…
be carefull and always take a snapshot before proceeding!
empty these folders inside the jail
/var/db/openhab2/userdata/cache
/var/db/openhab2/userdata/tmp
maybe a nice addon to the free-bsd update script?
also…
be aware of
Could not process config file 'runtime.cfg': /usr/local/etc/openhab2/services/runtime.cfg (Permission denied)
Could not process config file 'classicui.cfg': /usr/local/etc/openhab2/services/classicui.cfg (Permission denied)
Could not process config file 'basicui.cfg': /usr/local/etc/openhab2/services/basicui.cfg (Permission denied)
the upgrade script replaces these and root user takes ownership. give it back to openhab user.
I have upgraded from 2.4.0 to 2.5.0 with success today.
Attempt 1: upgrade jail to 11.3-STABLE, upgrade all as mentoned above with command pkg update -f && pkg upgrade. All looks ok but openhhab didn’t start with very strange exception (no key generator or no algorithm during establish https connection).I spent 10-15 minutes on investigation exception but without success. Also i got no java on service openhab2 stop but java -version wors ok. So, i just restore my previous state from snapshot ant try again.
Attempt 2:
Backup config. I didn’t find openhab-cli on FreeBSD, so i prepare script
setenv OPENHAB_HOME “/usr/local/libexec/openhab2”
setenv OPENHAB_CONF “/usr/local/etc/openhab2”
setenv OPENHAB_RUNTIME “/usr/local/libexec/openhab2/runtime”
setenv OPENHAB_USERDATA “/var/db/openhab2/userdata”
setenv OPENHAB_LOGDIR “/var/log/openhab2”
run this script and /usr/local/libexec/openhab2/runtime/bin/backup to backup current config
upgrade all exept java and openhab:
pkg update -f
pkg lock openjdk8
pkg lock openhab2
pkg upgrade
Backup jail here to save time if somethig went wrong
pkg unlock openjdk8 and run pkg upgrade. Upgrade java, restart and check that all works ok on new java version.
pkg unlock openhab2
pkg upgrade
run /usr/local/libexec/openhab2/runtime/bin/update.freebsd
service openhab2 start
all work ok after this flow. I don’t know why. I guess - i stopped OH before step 6. In first attempt i did upgrade without stop OH.
I didn’t have issues with permission. But my jail contains grafana, i had issues with permissions for grafana.
i typically stop the service prior to its upgrade. also, i have one jail for each service. ie, grafana, mqtt, tasmoadmin, influx-db, node-red evething in its own jail. thats the purpose of jails, right ?
Can you please explain this for an absolute beginner? I missed my “openhab2-conf” directory, where i can put my rules etc. to work with Visual Studio Code.
This didn’t work because of folders and files so i deleted everthing is this directory via ssh, made a SMB-Share to „/mnt/MYPOOL/openHAB“ and putted the folders „html, icons, items“ etc. in it.
Well, i’m a totally beginner and hope, that you or someone else could help me with my problem, because i love my openhab but i also want to minimize my hardware and hope, that one day it all will run on my FreeNAS resp. TrueNAS.
Now for the dataset. We need to be sure of the UserID (UID) kai GroupID of the jail’s openhab user and use the same on the FreeNAS user. BY DEFAULT the ports version creates user openhab with UID 235 and GID 235 inside the jail.
So make a user group on FreeNAS main menu. Name of the group will be openhab AND SET MANUALLY THE GID TO BE 235. Next step is to create a user with name openhab and now set the UID to be 235. (Do not use UID or GID 1000 as FreeNAS suggests)
Make a new FreeNAS dataset. Give correct permission to the FreeNAS openhab user.
Make a SMB - Windows share for the dataset. Give correct permission to the FreeNAS openhab user.
Connect to your new share from windows, just to test its ok. It’s empty. Make these new directories
OPENHAB_CONF
OPENHAB_LOGDIR
OPENHAB_USERDATA
These will be the mount points for the directories you would want to edit config files and read the logs.
These are the same as Openhabian installations and their SMB ready to use configuration.
WE MUST CONFIGURE 3 MOUNT POINTS. Not one for the whole scheme.
My method is to stop the OH service or even better shut down the jail. Then just to be sure, i go and rename the 3 directories on the jail, in their respective paths, to “clear” the way for the mount point later.
What i mean is : go to usr/local/etc/openhab2 and rename it to openhab2-not-used
If you FTP through FreeNAS root account you can find it as
/mnt/MYPOOL/iocage/jails/openhab/root/usr/local/etc/openhab2
I see you already got that.
I repeat the 3 directories inside the OH jail
/usr/local/etc/openhab2
/var/log/openhab2
/var/db/openhab2/userdata
To create the mount points, jail must be stopped. Create these 3 mount points
/mnt/MYDATAPOOL/MYOHSHARE/OPENHAB_LOGDIR -> /mnt/MYPOOL/iocage/jails/openhab/root/var/log/openhab2
/mnt/MYDATAPOOL/MYOHSHARE/OPENHAB_CONF -> /mnt/MYPOOL/iocage/jails/openhab/root/usr/local/etc/openhab2
/mnt/MYDATAPOOL/MYOHSHARE/OPENHAB_USERDATA -> /mnt/MYPOOL/iocage/jails/openhab/root/var/db/openhab2/userdata
Start the OH jail. You should see now the directories inside the jail with user openhab:openhab and permissions 755
just to be on the safe side, do these inside the jail and check previous step.
Of course, I’ll do. But I’m really busy at the moment. My first try went wrong. The SMB-Part works well and copied the things from the “not-used” directory to the new one. But after it, the openhab doesn’t work. I think I put some permissions wrong (absolute beginner). At Sunday, I tried to install openhab again, but it doesn’t work.
I think your instructions are really good. I’ll give my best and keep you up to date