diff --git a/README.md b/README.md index f030808..9b00004 100644 --- a/README.md +++ b/README.md @@ -382,6 +382,77 @@ To be able to build images for other architectures (e.g. armhf/arm64 on amd64) Q $ docker run --rm --privileged multiarch/qemu-user-static:register --reset ``` +## Executing shell scripts before openHAB is started + +It is sometimes useful to run shell scripts after the "userdata" directory is created, but before karaf itself is launched. +One such case is creating SSH host keys, and allowing access to the system from the outside via SSH. +Exemplary scripts can be found in the ([contrib] (https://github.com/openhab/openhab-docker/tree/contrib) directory + +To use this, create a directory called + +```shell +/etc/cont-init.d +``` + +and add a volume mount to your startup: + +```shell + ... + -v /etc/cont-init.d:/etc/cont-init.d \ + ... +``` + + +and put your scripts into that directory. +This can be done by either using a volume mount (see the examples above) or creating your own images which inherit from the offical ones. + +### Show the contents of the runnig docker image + +([10-show-directories] https://github.com/openhab/openhab-docker/blob/master/contrib/cont-init.d/10-show-directories) + +```shell +ls -l /openhab +ls -l /openhab/userdata +``` + +### Set a defined host key for the image + +([20-set-host-key] https://github.com/openhab/openhab-docker/blob/master/contrib/cont-init.d/20-set-host-key) + +```shell +cat > /openhab/userdata/etc/host.key < /openhab/userdata/etc/keys.properties < /openhab/userdata/etc/keys.properties < /openhab/userdata/etc/host.key <