nixos-config/assets/etc-info/restic.sh
2019-10-29 18:40:56 +01:00

22 lines
548 B
Bash

function only_service(){
local service=$1
cat ~/.etc_info/* | jq '.[] | select(has("'${service}'"))'
}
only_service "restic" \
| jq '.restic' | jq --slurp . | jq 'group_by(.from)' \
| jq --raw-output '
.[] |
.[0].from as $hostname |
.[0].folders as $folders |
[.[] | select(.enable) | .to.server ] as $servers |
"
# \($hostname)
## folders
\( $folders | reduce .[] as $item ( ""; . + "* " + $item + "\n" ) )
## to
\( $servers | reduce .[] as $item ( ""; . + "* " + $item + "\n") )
"' | pandoc-from-markdown-to-man | man --local-file -