OpenHAB on OpenBSD

Hi,

is anyone running OpenHAB on OpenBSD? If yes, could you please share the installation process?

Could not find OpenHab in the OpenBSD packages. Already have an OpenBSD box at home, would be great to install OpenHAB on it.

Any help would be great :slight_smile:

Thanks

There once was someone who was running on FreeBSD many many years ago. I’ve not heard anything about running on any BSD system since then. BSD isn’t a supported platform so you would likely be on your own for installation, setup, and configuration. You won’t find a package unless someone created one in secret.

But it should work. You’ll just have to do a manual install. You’ll need to install a Java 11 runtime and then follow the manual installation instructions under the Linux installation page, replacing the Linux standard paths and commands with the OpenBSD paths and commands. You’ll have to write and configure the service start script yourself since I’m pretty certain systemd isn’t on OpenBSD.

You’ll be largely on your own for installation and hardware access type issues. No one here I know of is trying to run on a BSD.

Maybe they were running it on FreeBSD because it supports docker. I dont think OpenBSD supports docker.
And yes you are right, systemd isn’t a thing in OpenBSD.
Either way thanks, will give it a try on the weekend.

FreeBSD did not support Docker at that time and they did not talk about running it in Docker. This was many years ago.

Good luck!

1 Like

I’ve something you could call a script :wink: that installs the latest OpenHAB (4.1.1) on OpenBSD 7.4.
I’m sure things can be improved, but for a test environment this works (OpenBSD as guest on Linux KVM).

#!/bin/ksh

pkg_add wget unzip-- jdk%17  javaPathHelper
group add -g 9001 _openhab
useradd -u 9001 -g 9001 -L daemon -c "openhab runtime user" -m -d /var/lib/openhab -s /sbin/nologin _openhab
wget -O /tmp/openhab-download.zip https://github.com/openhab/openhab-distro/releases/download/4.1.1/openhab-4.1.1.zip
unzip /tmp/openhab-download.zip -d /usr/local/openhab


cat > /etc/rc.d/openhab << EOF
#!/bin/ksh
daemon="/var/lib/openhab/run.sh"
daemon_logger="daemon.info"
daemon_user="_openhab"

. /etc/rc.d/rc.subr

rc_cmd \$1
EOF
chmod +x /etc/rc.d/openhab

cat > /var/lib/openhab/run.sh << EOF
#!/bin/ksh
export OPENHAB_HOME=/usr/local/openhab
export OPENHAB_RUNTIME=/usr/local/openhab/runtime
export OPENHAB_USERDATA=/var/lib/openhab
export OPENHAB_BACKUPS=/var/lib/openhab/backups
export OPENHAB_CONF=/etc/openhab
export OPENHAB_LOGDIR=/var/log/openhab
export OPENHAB_HTTPS_PORT=8443
export OPENHAB_HTTP_PORT=8080
export OPENHAB_GROUP=_openhab
export OPENHAB_USER=_openhab

# make sure Java env is set
# if set you can call /usr/local/openhab/runtime/bin/karaf
export JAVA_HOME=/usr/local/jdk-17
export PATH=\$PATH:/usr/local/jdk-17/bin
/usr/local/openhab/runtime/bin/karaf daemon
EOF
chmod +x /var/lib/openhab/run.sh

# /etc/openhab          is the configuration directory
# /var/lib/openhab      is the _openhab home directory (questions arises if this is correct, but seen on openhabian)
# /var/log/openhab      is the log directory
# /usr/local/openhab    is the package installation

mkdir -p -m 744 /etc/openhab /var/log/openhab

mv /usr/local/openhab/userdata/* /var/lib/openhab/   
mv /usr/local/openhab/conf/* /etc/openhab

chown -R _openhab:_openhab  /etc/openhab /var/lib/openhab /var/log/openhab /usr/local/openhab

rcctl enable openhab
rcctl start openhab
1 Like

Cool!

Ideally we/someone could create a binary package for openbsd and freebsd. Just need a volunteer :slight_smile:

  • I suspect openbsd and freebsd users are in the extreme minority (in general)
  • They are usually more technically proficient than the general users, so installing openhab “manually” shouldn’t be too hard for them. IMO it is probably very easy in fact.
  • However, FreeNAS is based on freebsd so there might be a “market” there.

On the openHAB download page, perhaps add an extra item along with Pi, Linux, Windows, Mac, Docker, called “Manual Installation”, or “Other Platform”. WDYT @rlkoshak

Essentially just to make it clear that one could download the distribution zip and use it on any java-supported platform.

@phixenl would you mind telling me why the user/group names (_openhab) are prefixed with an underscore?

The challenge is the proper file paths and how to get it running as a service is going to be different for the different platforms. The common stuff is pretty straight forward: “install Java, download and unzip the OH package”. The complicated parts come after that and that stuff is OS specific. Note that the Windows and Mac instructions are manual instructions.

A short section on the downloads page wouldn’t be terrible. But I imagine anyone intrepid enough to try to get OH running on something like FreeBSD is going to be able to figure that part on their own fairly easily without a couple sentences. It’s the rest of the OS specific stuff that gets complicated (how does OH find Java? how to run OH as a service?) and not generic.

For a time we did have BSD as one of the options in the docs but no one maintained it and it got dropped some time ago. Ultimately the instructions are likely to look a lot like the Mac and Windows instructions.

In fact, it’s more complicated than expected. Several scripts are run to determine many environment variables. It’s not just JAVA_HOME and the obvious OPENHAB_* but also the more hidden KARAF_* variables.

Using the _ is more of a convention to distinguish daeomon/system accounts from user accounts. It has no technical reason

There seems to be official OpenBSD and FreeBSD ports, in fact more (FreeBSD) or less (OpenBSD) outdated. Did not try them, though (yet).

There is someone who has taken up the work and the maintainers are currently working through how to keep it up long term so it doesn’t depend on just the efforts of one person.

See Add openHAB on OpenBSD installation instructions by realPyR3X · Pull Request #2649 · openhab/openhab-docs · GitHub

2 Likes

If it helps, I’m running 4.3.9 on FreeBSD 15.0-stable, installation is just…

pkg install misc/openhab

…and then you can connect to the web interface - so far the only issue I had was exposing a zigbee dongle to the jail openhab was running in.

The FreeBSD port maintainer @netchild has an account on this forum. Last I saw on freshports the log mentioned an issue with 5.x and a dependency that fails an OS check.

1 Like

Thanks a lot! This explains why there is no v.5.x in the ports.

Hi,

I maintain the FreeBSD port. I’m an official FreeBSD developer (write access to the FreeBSD source and to the 3rd party package build instruction repository). The FreeBSD project provides OpenHAB packages as part of their 3rd party software package repo.

OpenHAB just works on FreeBSD (except: graalvm issue, but this is not the fault of the OpenHAB project and as soon as a suitable version (planned for 25.1.0) of the fixed 3rd party framework is integrated into OpenHAB, OpenHAB 5 will be made available as a FreeBSD package). It’s a java application in an unixoid environment (no docker in use for the port), so it is similar to running it on any Linux distro.

The only FreeBSD specific part is the start script (integrated into the FreeBSD way), a little patch for setenv, and that you are supposed to update via the FreeBSD package management instead of the update script.

@jimtng and @rlkoshak for FreeBSD it would be enough to mention that a FreeBSD package is available in the FreeBSD package repository and it can be installed via “pkg install misc/openhab misc/openhab-plugins” (it may not get updates as fast as the official OpenHAB packages). The file paths are adapted to the FreeBSD file hierarchy convention (but can be changed via variables in the system config):

openhab_backup_dir (path): Set to /var/db/openhab/backups by default.
openhab_home_dir (path): Set to /usr/local/libexec/openhab by default.
openhab_conf_dir (path): Set to /usr/local/etc/openhab by default.
openhab_runtime_dir (path): Set to /usr/local/libexec/openhab/runtime by default.
openhab_userdata_dir (path): Set to /var/db/openhab/userdata by default.
openhab_log_dir (path): Set to /var/log/openhab by default.

There are users of the FreeBSD port. I can not tell how much, I don’t have statistics, but from time to time I get questions about the FreeBSD port, or get asked when OpenHAB 5 will be available.

I agree to what was mentioned here already, FreeBSD users are typically savvy in IT topics. I would expect them to reach out to the FreeBSD community for FreeBSD specific issues with OpenHAB, and I would also assume they would not run around with a big FreeBSD flag when they discuss generic OpenHAB stuff here. So you may not be able to identify FreeBSD users here.

Bye,
Alexander.

2 Likes