Split run.sh and add git retrival

This patch modularize run.sh, adding two new helper scripts and
make it possible to specify a git repository for ssh keys via a
new env variable `BORG_SSHKEYS_REPO`.

the modularization add two new files :
- `env.sh` : define a few envriroment variables
- `create-client-dirs.sh`  : update and create user directories and
  re-create authorized_keys

We also add a new script `update-ssh-keys.sh` to be called regurlarly
in a cron job to check if the git repository is up-to-date and
eventually adding/removing users.
This commit is contained in:
Pietro 2020-03-23 12:38:34 +01:00
parent ac797c90f6
commit 0108fcf653
No known key found for this signature in database
GPG key ID: 375CEF476926787B
5 changed files with 118 additions and 38 deletions

17
data/update-ssh-keys.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
set -e
source env.sh
if [ -d "${SSH_KEY_DIR}/clients/.git" ] ; then
cd "${SSH_KEY_DIR}/clients" || exit 0
git fetch
if ! git diff --quiet remotes/origin/HEAD; then
echo "Pull from git repository"
git pull
create-client-dirs.sh
else
echo "$0: Nothing to do"
fi
fi