docker-borgserver/data/update-ssh-keys.sh

21 lines
573 B
Bash
Raw Permalink Normal View History

#!/bin/bash
2020-03-26 17:16:56 +00:00
# This script updates the authorized_keys file
# Will clone/pull ssh-pubkeys from GIT_KEY_URL if set
set -e
source env.sh
if [ -d "${SSH_KEY_DIR}/clients/.git" ] ; then
2020-03-26 17:16:56 +00:00
git -C "${SSH_KEY_DIR}/clients" fetch
if ! git -C "${SSH_KEY_DIR}/clients" diff --quiet remotes/origin/HEAD; then
echo "Pull from git repository"
2020-03-26 17:16:56 +00:00
git -C "${SSH_KEY_DIR}/clients" pull
create-client-dirs.sh
else
echo "$0: Nothing to do"
fi
2020-03-26 17:16:56 +00:00
elif [ ! -z "${KEY_GIT_URL}" ] ; then
git clone --depth=1 -b ${KEY_GIT_BRANCH} ${KEY_GIT_URL} ${SSH_KEY_DIR}/clients
fi
2020-03-26 17:16:56 +00:00
exit 0