aboutsummaryrefslogtreecommitdiff
path: root/files/borg.fact
blob: 555143d1c95ffff1bc91c3c62a6d8e08a58c43d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

echo '{'
if [ -e '/root/.ssh/borg.pub' ]; then
    pubkey=`cat /root/.ssh/borg.pub | tr -d "\n"`
    echo -ne '  "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  }"
fi
echo -ne "\n}"