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

1 Like

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