Add ENV-Variable, reset authorized_keys, run.sh as entrypoint
(cherry picked from commit 993b9f0cc674974c5f008a4c3fd0d2bbcd397c7e)
This commit is contained in:
parent
184a435060
commit
d471015ecb
|
@ -22,7 +22,7 @@ RUN rm -f /etc/ssh/ssh_host*key* ; \
|
||||||
COPY ./data/run.sh /run.sh
|
COPY ./data/run.sh /run.sh
|
||||||
COPY ./data/sshd_config /etc/ssh/sshd_config
|
COPY ./data/sshd_config /etc/ssh/sshd_config
|
||||||
|
|
||||||
CMD /bin/bash /run.sh
|
ENTRYPOINT /run.sh
|
||||||
|
|
||||||
# Default SSH-Port for clients
|
# Default SSH-Port for clients
|
||||||
EXPOSE 22
|
EXPOSE 22
|
||||||
|
|
8
data/run.sh
Normal file → Executable file
8
data/run.sh
Normal file → Executable file
|
@ -2,9 +2,14 @@
|
||||||
# Init borg-users .ssh/authorized_keys
|
# Init borg-users .ssh/authorized_keys
|
||||||
|
|
||||||
BORG_DATA_DIR=/backup
|
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
|
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
|
# add all sshkeys to borg-user's authorized_keys & create repositories
|
||||||
echo "########################################################"
|
echo "########################################################"
|
||||||
for dir in BORG_DATA_DIR SSH_KEY_DIR ; do
|
for dir in BORG_DATA_DIR SSH_KEY_DIR ; do
|
||||||
|
@ -40,6 +45,7 @@ done
|
||||||
echo "########################################################"
|
echo "########################################################"
|
||||||
|
|
||||||
echo " * Starting SSH-Key import..."
|
echo " * Starting SSH-Key import..."
|
||||||
|
rm /home/borg/.ssh/authorized_keys &>/dev/null
|
||||||
for keyfile in $(find "${SSH_KEY_DIR}/clients" -type f); do
|
for keyfile in $(find "${SSH_KEY_DIR}/clients" -type f); do
|
||||||
client_name=$(basename $keyfile)
|
client_name=$(basename $keyfile)
|
||||||
echo " ** Adding client ${client_name} with repo path ${BORG_DATA_DIR}/${client_name}"
|
echo " ** Adding client ${client_name} with repo path ${BORG_DATA_DIR}/${client_name}"
|
||||||
|
|
Loading…
Reference in a new issue