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)
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
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)
git clone https://github.com/NeuronRobotics/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:
|--- 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…
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 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:
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
Affects: users of misc/openhab2
If you upgrade from a pevious version, make a backup of
read about the breaking changes in the release notes at
which takes care about changes for:
- Textual Configuration
- Next Generation Rule Engine
i run the script
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
maybe a nice addon to the free-bsd update script?
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.
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
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
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 ?
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
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
I see you already got that.
I repeat the 3 directories inside the OH jail
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