etc/info: add script to read restic informations

This commit is contained in:
Ingolf Wagner 2019-10-29 11:42:46 +01:00
parent d3e9585f58
commit 67218413a4
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
2 changed files with 44 additions and 0 deletions

43
assets/info_restic.sh Normal file
View file

@ -0,0 +1,43 @@
#!/usr/bin/env bash
TMPDIR=~/.etc_info
mkdir -p $TMPDIR
# todo use rsync and make and copy them to a place where
# it is stored for longer
function get_infos(){
local server=$1
cd $TMPDIR
scp "${server}:/etc/info/*.json" .
}
function only_service(){
local service=$1
cd $TMPDIR
cat * | jq '.[] | select(has("'${service}'"))'
}
# main
get_infos "workhorse.private"
get_infos "porani.private"
get_infos "workout.private"
get_infos "pepe.private"
get_infos "sterni.private"
only_service "restic" \
| jq '.restic' | jq --slurp . | jq 'group_by(.from)' \
| jq --raw-output '
.[] |
.[0].from as $hostname |
.[0].folders as $folders |
[.[].to.server] |
"
# \($hostname)
## folders
\( $folders | reduce .[] as $item ( ""; . + "*" + $item + "\n" ) )
## to
\(. | reduce .[] as $item ( ""; . + "* " + $item + "\n") )
"' | pandoc - -s -t man | man -l -

View file

@ -32,6 +32,7 @@ let
${pkgs.pandoc}/bin/pandoc \ ${pkgs.pandoc}/bin/pandoc \
--from ${inputFormat} \ --from ${inputFormat} \
--to ${outputFormat} \ --to ${outputFormat} \
--standalone \
"$@" "$@"
''; '';