aboutsummaryrefslogtreecommitdiff
path: root/files/borg.fact
blob: a27d5b033d4202810c6663e97d0e92728c584297 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
###############################################################################
#     \_o<     WARNING : This file is being managed by ansible!      >o_/     #
#     ~~~~                                                           ~~~~     #
###############################################################################

printf "{\n"
if [ -e '/root/.ssh/borg.pub' ]; then
	pubkey=`cat /root/.ssh/borg.pub | tr -d "\n"`
	printf "  \"pubkey\": \"$pubkey\""
	pubkey_prefix=",\n"
fi
if [ -e '/srv/borg/repos/' ]; then
	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
printf "\n}"