1
0
Fork 0
This repository has been archived on 2025-03-10. You can view files and clone it, but cannot push or open issues or pull requests.
ansible-role-borg/files/borg.fact

25 lines
838 B
Text
Raw Normal View History

2019-07-09 11:45:03 +02:00
#!/bin/sh
###############################################################################
# \_o< WARNING : This file is being managed by ansible! >o_/ #
# ~~~~ ~~~~ #
###############################################################################
2019-07-09 11:45:03 +02:00
2021-02-11 19:10:38 +01:00
printf "{\n"
2019-07-09 11:45:03 +02:00
if [ -e '/root/.ssh/borg.pub' ]; then
2021-02-11 19:10:38 +01:00
pubkey=`cat /root/.ssh/borg.pub | tr -d "\n"`
printf " \"pubkey\": \"$pubkey\""
pubkey_prefix=",\n"
2019-07-09 11:45:03 +02:00
fi
if [ -e '/srv/borg/repos/' ]; then
2021-02-11 19:10:38 +01:00
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 }"
2019-07-09 11:45:03 +02:00
fi
2021-02-11 19:10:38 +01:00
printf "\n}"