diff --git a/root/entrypoint.sh b/root/entrypoint.sh index 98f46f9..f7cc7a3 100755 --- a/root/entrypoint.sh +++ b/root/entrypoint.sh @@ -1,11 +1,6 @@ #!/bin/bash set -Eeo pipefail -if [ ! -e /etc/openvpn/sshd_config ]; then - echo "Configuration file sshd_config not found. Initializing..." - cp /config/sshd_config /etc/ssh/sshd_config -fi - # shellcheck disable=2154 trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR @@ -20,6 +15,14 @@ function log() { echo "[$0] $*" >&2 } +# Check that `sshd_config` exists +# In case `/etc/ssh/` is mounted as a volume the file `sshd_config` is not +# guaranteed to be there +if [ ! -e /etc/ssh/sshd_config ]; then + echo "Configuration file sshd_config not found. Initializing..." + cp /config/sshd_config /etc/ssh/sshd_config +fi + # Allow running other programs, e.g. bash if [[ -z "$1" || "$1" =~ $reArgsMaybe ]]; then startSshd=true