diff --git a/ssh/Dockerfile b/ssh/Dockerfile index c73597f50..a67cd7632 100644 --- a/ssh/Dockerfile +++ b/ssh/Dockerfile @@ -6,7 +6,9 @@ FROM ${BUILD_FROM} SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Add env -ENV TERM="xterm-256color" +ENV \ + TERM="xterm-256color" \ + S6_STAGE2_HOOK=/etc/s6-overlay/scripts/enable-check.sh # Copy Python requirements file COPY requirements.txt /tmp/ diff --git a/ssh/rootfs/etc/s6-overlay/s6-rc.d/sshd/run b/ssh/rootfs/etc/s6-overlay/s6-rc.d/sshd/run index fe8227e46..792b39692 100755 --- a/ssh/rootfs/etc/s6-overlay/s6-rc.d/sshd/run +++ b/ssh/rootfs/etc/s6-overlay/s6-rc.d/sshd/run @@ -6,11 +6,6 @@ # ============================================================================== declare -a options -# If SSH is disabled, use a fake sleep process -if ! bashio::var.has_value "$(bashio::addon.port 22)"; then - exec sleep 864000 -fi - bashio::log.info 'Starting the SSH daemon...' # Default options diff --git a/ssh/rootfs/etc/s6-overlay/scripts/enable-check.sh b/ssh/rootfs/etc/s6-overlay/scripts/enable-check.sh new file mode 100755 index 000000000..db5d27b6b --- /dev/null +++ b/ssh/rootfs/etc/s6-overlay/scripts/enable-check.sh @@ -0,0 +1,13 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== +# Enable optional services based on the add-on configuration +# ============================================================================== + +# Disable the SSH daemon when no SSH port is exposed +if ! bashio::var.has_value "$(bashio::addon.port 22)"; then + bashio::log.info \ + "No network port is defined in the configuration so access" \ + "will only be available via the web interface." + rm -f /etc/s6-overlay/s6-rc.d/user/contents.d/sshd +fi