Bundle installation over CLI

I’m working on a small bash script that installs/configure OH for me with some extra’s (samba, nginx, backupcron, binding, basic scripts…).

Over 300 lines of scripting already? :scream:
Yeah, IT-guys are lazy, I know. :wink:

I want now to install some bundles (fe knx, zwave, regex…) in OH. Is there a way to install this by CLI (bash script)? I was looking if I could do it over karaf, but in there, I’m getting an error. Guess this is because I didn’t install the local addons package?

bundle:install org.eclipse.smarthome.transform.regex

Bundle IDs: 
 Error executing command: Error installing bundles:
 	Unable to install bundle org.eclipse.smarthome.transform.regex: org.osgi.framework.BundleException: Error reading bundle content.

Was thinking about downloading (wget) it in the addons folder, but maybe there’s a better way to have the latest versions?

Look at using the REST API. That is what PaperUI and HABmin use anyway.

Use cURL instead of wget.

Alternatively, you can use the Karaf client. For example

/path/to/openhab2/runtime/bin/client -p habopen -l 0 -- bundle:install org.eclipse.smarthome.transform.regex
1 Like

Will have a look later on how this can helps me to install bindings. Thanks!

For the moment, I’m getting an error:
KARAF_BASE is not valid: /usr/share/openhab2/userdata
But this can be caused by my installation. It’s messed out right now after 25 installations. Should reinstall the OS. Time, time…

If you were lazy, you’d use something like Ansible. There are published roles for openHAB installation on this forum and in ansible-galaxy. If you were really lazy you’d use openHABian which is already exactly what you are trying to build, some bash scripts that install and configure openHAB and related software, complete with a nice curses UI.

Add them to /etc/openhab2/services/addons.cfg.

To provide an example, I have two OH instances running, a remote one and a local one. The remote one is running on an RPi and is set up using the manual installation of openHABian (not the SD card image). The local one runs in Docker.

The configurations for each are checked into git.

Setting up a new local instance on a brand new VM involves running my ansible playbook and checking out my configs from git. Setting up the remote machine requires running openhabian-config and then checking out the config.

If you include both $OH_CONF and parts of $OH_USERDATA than all that you do in openHAB either through config files or through the REST API gets preserved. When OH first comes up, any addons defined to be used in addons.cfg, or any addons that are defined to be used in userdata (i.e. those installed through PaperUI NOTE: you cannot mix the two approaches, you can use either one or the other) will be downloaded and installed by openHAB.

1 Like

Will take some time to see if ansible does what I need. Used it a few years ago, but could find my way in it. Taking time to learn/understanding something ‘new’, is again time consuming… And I would rarther just play around with some rules. Things you see happen in our daily life… :wink:

Today, I wrote a bash script with dialog to (not) install/configure the different parts. Works great, except a few small things that I’m missing (like installing the bundles).