From f27856a4b5467fd6d0890f570d56af9de356317d Mon Sep 17 00:00:00 2001 From: Hakan Tandogan Date: Sun, 18 Nov 2018 23:36:30 +0100 Subject: [PATCH] Documentation and examples for the s6 init continuation scripts (#206) Signed-off-by: Hakan Tandogan --- README.md | 71 +++++++++++++++++++++ contrib/cont-init.d/10-show-directories | 5 ++ contrib/cont-init.d/20-add-allowed-ssh-keys | 12 ++++ contrib/cont-init.d/20-set-host-key | 9 +++ 4 files changed, 97 insertions(+) create mode 100644 contrib/cont-init.d/10-show-directories create mode 100644 contrib/cont-init.d/20-add-allowed-ssh-keys create mode 100644 contrib/cont-init.d/20-set-host-key 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 <