Add ENV-Variable, reset authorized_keys, run.sh as entrypoint

(cherry picked from commit 993b9f0cc674974c5f008a4c3fd0d2bbcd397c7e)
This commit is contained in:
nold 2017-11-01 17:51:51 +01:00
parent 184a435060
commit d471015ecb
2 changed files with 8 additions and 2 deletions

View file

@ -22,7 +22,7 @@ RUN rm -f /etc/ssh/ssh_host*key* ; \
COPY ./data/run.sh /run.sh
COPY ./data/sshd_config /etc/ssh/sshd_config
CMD /bin/bash /run.sh
ENTRYPOINT /run.sh
# Default SSH-Port for clients
EXPOSE 22

8
data/run.sh Normal file → Executable file
View file

@ -2,9 +2,14 @@
# Init borg-users .ssh/authorized_keys
BORG_DATA_DIR=/backup
BORG_CMD='cd ${BORG_DATA_DIR}/${client_name}; borg serve --append-only --restrict-to-path ${BORG_DATA_DIR}/${client_name}'
BORG_CMD='cd ${BORG_DATA_DIR}/${client_name}; borg serve --restrict-to-path ${BORG_DATA_DIR}/${client_name}'
SSH_KEY_DIR=/sshkeys
# Parse environment
if [ ! -z "${BORG_SERVE_ARGS}" ] ; then
BORG_CMD="${BORG_CMD} ${BORG_SERVE_ARGS}"
fi
# add all sshkeys to borg-user's authorized_keys & create repositories
echo "########################################################"
for dir in BORG_DATA_DIR SSH_KEY_DIR ; do
@ -40,6 +45,7 @@ done
echo "########################################################"
echo " * Starting SSH-Key import..."
rm /home/borg/.ssh/authorized_keys &>/dev/null
for keyfile in $(find "${SSH_KEY_DIR}/clients" -type f); do
client_name=$(basename $keyfile)
echo " ** Adding client ${client_name} with repo path ${BORG_DATA_DIR}/${client_name}"