etc/info: add script to read restic informations
This commit is contained in:
parent
d3e9585f58
commit
67218413a4
2 changed files with 44 additions and 0 deletions
43
assets/info_restic.sh
Normal file
43
assets/info_restic.sh
Normal 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 -
|
||||
|
||||
|
|
@ -32,6 +32,7 @@ let
|
|||
${pkgs.pandoc}/bin/pandoc \
|
||||
--from ${inputFormat} \
|
||||
--to ${outputFormat} \
|
||||
--standalone \
|
||||
"$@"
|
||||
'';
|
||||
|
||||
|
|
Loading…
Reference in a new issue