1
0
Fork 0

Revitalized the borg role

This commit is contained in:
Julien Dessaux 2021-02-11 19:10:38 +01:00
parent 0087b1fc16
commit 6e49d2b6c7
11 changed files with 85 additions and 37 deletions

View file

@ -4,19 +4,21 @@
# ~~~~ ~~~~ #
###############################################################################
echo '{'
printf "{\n"
if [ -e '/root/.ssh/borg.pub' ]; then
pubkey=`cat /root/.ssh/borg.pub | tr -d "\n"`
echo -ne ' "pubkey": "'$pubkey'"'
pubkey_prefix=",\n"
pubkey=`cat /root/.ssh/borg.pub | tr -d "\n"`
printf " \"pubkey\": \"$pubkey\""
pubkey_prefix=",\n"
fi
if [ -e '/srv/borg/repos/' ]; then
echo -ne "${pubkey_prefix:-}"' "repos": {'"\n"
for repo in `ls /srv/borg/repos/`; do
id=`awk '/^id =/ {print $3}' /srv/borg/repos/${repo}/config`
echo -ne ${repo_prefix:-}' "'$repo'": "'$id'"'
repo_prefix=",\n"
done
echo -ne "\n }"
printf "${pubkey_prefix:-} \"repos\": {\n"
for repo in `ls /srv/borg/repos/`; do
if [ -e "/srv/borg/repos/${repo}/config" ]; then
id=`awk '/^id =/ {print $3}' /srv/borg/repos/${repo}/config`
printf "${repo_prefix:-} \"$repo\": \"$id\""
repo_prefix=",\n"
fi
done
printf "\n }"
fi
echo -ne "\n}"
printf "\n}"