Add: Clone git repo with SSH public keys into SSH_KEY_DIR
This commit is contained in:
parent
a741486bb3
commit
4325a3d964
|
@ -13,7 +13,7 @@ VOLUME /backup
|
|||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt-get update && apt-get -y --no-install-recommends install \
|
||||
borgbackup openssh-server && apt-get clean && \
|
||||
borgbackup openssh-server git ca-certificates && apt-get clean && \
|
||||
useradd -s /bin/bash -m borg && \
|
||||
mkdir /home/borg/.ssh && \
|
||||
chmod 700 /home/borg/.ssh && \
|
||||
|
|
20
data/run.sh
20
data/run.sh
|
@ -1,12 +1,12 @@
|
|||
#!/bin/bash
|
||||
# Start Script for docker-borgserver
|
||||
#set -x
|
||||
|
||||
BORG_DATA_DIR=/backup
|
||||
SSH_KEY_DIR=/sshkeys
|
||||
BORG_CMD='cd ${BORG_DATA_DIR}/${client_name}; borg serve --restrict-to-path ${BORG_DATA_DIR}/${client_name} ${BORG_SERVE_ARGS}'
|
||||
|
||||
# Append only mode?
|
||||
#BORG_SERVE_ARGS=${BORG_SERVE_ARGS:=""}
|
||||
BORG_APPEND_ONLY=${BORG_APPEND_ONLY:=no}
|
||||
BORG_DATA_DIR="${BORG_DATA_DIR:=/backup}"
|
||||
SSH_KEY_DIR="${SSH_KEY_DIR:=/sshkeys}"
|
||||
BORG_CMD='cd ${BORG_DATA_DIR}/${client_name}; borg serve --restrict-to-path ${BORG_DATA_DIR}/${client_name} ${BORG_SERVE_ARGS}'
|
||||
|
||||
echo "########################################################"
|
||||
echo -n " * Docker BorgServer powered by "
|
||||
|
@ -18,6 +18,16 @@ if [ "${BORG_APPEND_ONLY}" == "yes" ] && [ -z "${BORG_ADMIN}" ] ; then
|
|||
echo "WARNING: BORG_APPEND_ONLY is active, but no BORG_ADMIN was specified!"
|
||||
fi
|
||||
|
||||
if [ ! -z "${SSH_KEY_GIT}" ] ; then
|
||||
echo "SSH_KEY_GIT set, cloning '${SSH_KEY_GIT}' into '${SSH_KEY_DIR}/clients'"
|
||||
if [ ! -d "${SSH_KEY_DIR}/clients/.git" ] ; then
|
||||
# FIXME: Should the container die here, in case of error?
|
||||
git clone "${SSH_KEY_GIT}" "${SSH_KEY_DIR}/clients"
|
||||
else
|
||||
git -C "${SSH_KEY_DIR}/clients" pull
|
||||
fi
|
||||
fi
|
||||
|
||||
# Precheck directories & client ssh-keys
|
||||
for dir in BORG_DATA_DIR SSH_KEY_DIR ; do
|
||||
dirpath=$(eval echo '$'${dir})
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
version: '3'
|
||||
services:
|
||||
borgserver:
|
||||
image: nold360/borgserver
|
||||
#build: .
|
||||
#image: nold360/borgserver
|
||||
build: .
|
||||
volumes:
|
||||
- ./backup:/backup
|
||||
- ./sshkeys:/sshkeys
|
||||
|
@ -17,4 +17,7 @@ services:
|
|||
|
||||
# Hostname of Admin's SSH-Key
|
||||
BORG_ADMIN: ""
|
||||
|
||||
# Client Pubkeys in git:
|
||||
SSH_KEY_GIT: "https://github.com/<username>/<repo>.git"
|
||||
restart: unless-stopped
|
||||
|
|
Loading…
Reference in a new issue