make adding startup tasks more easily extensible

This commit is contained in:
dpedu 2015-02-27 16:33:20 -08:00
parent 1905526711
commit a430531e06
3 changed files with 14 additions and 5 deletions

View File

@ -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

10
regenerate-ssh Normal file
View File

@ -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

6
start Normal file → Executable file
View File

@ -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