2020-03-23 11:38:34 +00:00
|
|
|
#!/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
|
2020-03-23 11:38:34 +00:00
|
|
|
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
|
2020-03-23 11:38:34 +00:00
|
|
|
echo "Pull from git repository"
|
2020-03-26 17:16:56 +00:00
|
|
|
git -C "${SSH_KEY_DIR}/clients" pull
|
2020-03-23 11:38:34 +00:00
|
|
|
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
|
2020-03-23 11:38:34 +00:00
|
|
|
fi
|
2020-03-26 17:16:56 +00:00
|
|
|
|
|
|
|
exit 0
|