From d471015ecbc8575e76b39ae8e3e20402eddc15b6 Mon Sep 17 00:00:00 2001 From: nold Date: Wed, 1 Nov 2017 17:51:51 +0100 Subject: [PATCH] Add ENV-Variable, reset authorized_keys, run.sh as entrypoint (cherry picked from commit 993b9f0cc674974c5f008a4c3fd0d2bbcd397c7e) --- Dockerfile | 2 +- data/run.sh | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) mode change 100644 => 100755 data/run.sh diff --git a/Dockerfile b/Dockerfile index 96b6ab9..fa9f9a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/data/run.sh b/data/run.sh old mode 100644 new mode 100755 index 1d49754..3a8643e --- a/data/run.sh +++ b/data/run.sh @@ -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}"