How to save settings from org.apache.karaf.shell.cfg

Hi all!

System: OH4.1.0/WinSrv2022Latest/AzuleJDK17Latest

I can’t figure out how to configure a parameter hostKey = ${karaf.etc}/host.key in a file userdata\etc\org.apache.karaf.shell.cfg.
I can tweak it in org.apache.karaf.shell.cfg, but between OpenHab updates I have to make changes to this file every time.

For example, I can change a parameter sshHost = 0.0.0.0 in a file conf\services\runtime.cfg (org.apache.karaf.shell:sshHost = 0.0.0.0) and it will remain unchanged during OpenHab updates.

What about other parameters not described in the file runtime.cfg?

Is it possible to do this: org.apache.karaf.shell:hostKey = ${karaf.etc}/host.key or with other params prom org.apache.karaf.shell.cfg?

The runtime.cfg file is handled by config dispatcher, an openHAB only mechanism which writes configuration updates from that file into others. As far I know the syntax of file allows to write any config (based on identifier) and override key/value pairs in there through sequence of internal APIs which lead to file update.
The runtime folder where karaf reside is considered by openHAB as volatile, hence it is flushed with each update, making use of it quite hard. I’d say that going with runtime.cfg is way to go. You can also check source code comments on this component: https://github.com/openhab/openhab-core/blob/4.1.1/bundles/org.openhab.core.config.dispatch/src/main/java/org/openhab/core/config/dispatch/internal/ConfigDispatcher.java.

Thank you.
This really works.

This needs to be shown in the documentation in the appropriate section, otherwise it says something like this: you need to directly edit the org.apache.karaf.shell.cfg file (when they talk about changing the ssh port).

If you can, please submit two sentence update to openHAB docs repository. Its not very entertaining, but you will save time to others who fall into same trap.

Cheers,
Łukasz

Added a request to the bug tracker :slight_smile:

Link?