diff --git a/Dockerfile b/Dockerfile index 4ef4899..10caecb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,8 @@ COPY sshd.conf /etc/supervisor/conf.d/sshd.conf COPY cron.conf /etc/supervisor/conf.d/cron.conf COPY start /start -RUN chmod +x /start +RUN chmod +x /start ; mkdir /start.d +COPY regenerate-ssh /start.d/regenerate-ssh # Expose ssh EXPOSE 22 diff --git a/regenerate-ssh b/regenerate-ssh new file mode 100644 index 0000000..bec97ce --- /dev/null +++ b/regenerate-ssh @@ -0,0 +1,10 @@ +#! /bin/bash + +# If sshd has no config, generate new keys + config +if [ ! -f /etc/ssh/sshd_config ]; then + # Regenerate ssh key per container + dpkg-reconfigure openssh-server +fi + +# This only runs once, so remove this startup script +rm /start.d/regenerate-ssh diff --git a/start b/start old mode 100644 new mode 100755 index 24e4983..465c607 --- a/start +++ b/start @@ -1,9 +1,7 @@ #!/bin/bash -if [ ! -f /etc/ssh/sshd_config ]; then - # Regenerate ssh key per container - dpkg-reconfigure openssh-server -fi +# run everything in start.d +find /start.d -type f -executable -exec {} \; # Cleanly kill supervisor when container is stopped trap 'kill $(jobs -p)' EXIT