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
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
|
||||||
RUN apt-get update && apt-get -y --no-install-recommends install \
|
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 && \
|
useradd -s /bin/bash -m borg && \
|
||||||
mkdir /home/borg/.ssh && \
|
mkdir /home/borg/.ssh && \
|
||||||
chmod 700 /home/borg/.ssh && \
|
chmod 700 /home/borg/.ssh && \
|
||||||
|
|
20
data/run.sh
20
data/run.sh
|
@ -1,12 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Start Script for docker-borgserver
|
# Start Script for docker-borgserver
|
||||||
|
#set -x
|
||||||
|
|
||||||
BORG_DATA_DIR=/backup
|
#BORG_SERVE_ARGS=${BORG_SERVE_ARGS:=""}
|
||||||
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_APPEND_ONLY=${BORG_APPEND_ONLY:=no}
|
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 "########################################################"
|
||||||
echo -n " * Docker BorgServer powered by "
|
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!"
|
echo "WARNING: BORG_APPEND_ONLY is active, but no BORG_ADMIN was specified!"
|
||||||
fi
|
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
|
# Precheck directories & client ssh-keys
|
||||||
for dir in BORG_DATA_DIR SSH_KEY_DIR ; do
|
for dir in BORG_DATA_DIR SSH_KEY_DIR ; do
|
||||||
dirpath=$(eval echo '$'${dir})
|
dirpath=$(eval echo '$'${dir})
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
borgserver:
|
borgserver:
|
||||||
image: nold360/borgserver
|
#image: nold360/borgserver
|
||||||
#build: .
|
build: .
|
||||||
volumes:
|
volumes:
|
||||||
- ./backup:/backup
|
- ./backup:/backup
|
||||||
- ./sshkeys:/sshkeys
|
- ./sshkeys:/sshkeys
|
||||||
|
@ -17,4 +17,7 @@ services:
|
||||||
|
|
||||||
# Hostname of Admin's SSH-Key
|
# Hostname of Admin's SSH-Key
|
||||||
BORG_ADMIN: ""
|
BORG_ADMIN: ""
|
||||||
|
|
||||||
|
# Client Pubkeys in git:
|
||||||
|
SSH_KEY_GIT: "https://github.com/<username>/<repo>.git"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
Loading…
Reference in a new issue