etc/info: add scripts
This commit is contained in:
parent
aea509de86
commit
db67fb687c
3 changed files with 33 additions and 43 deletions
22
assets/etc-info/restic.sh
Normal file
22
assets/etc-info/restic.sh
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
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 -
|
||||
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
#!/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 -
|
||||
|
||||
|
|
@ -295,5 +295,16 @@ in {
|
|||
|
||||
memo
|
||||
|
||||
# etc-info stuff
|
||||
(pkgs.writers.writeDashBin "etc-info-sync"
|
||||
(lib.concatStringsSep "\n"
|
||||
(map
|
||||
(host: "rsync -avLz ${host}.private:/etc/info/ ~/.etc_info")
|
||||
(attrNames config.module.cluster.services.tinc."private".hosts))))
|
||||
|
||||
(pkgs.writers.writeBashBin "etc-info-restic" (lib.fileContents <assets/etc-info/restic.sh>))
|
||||
|
||||
|
||||
|
||||
] ++ (lib.crossLists pandocScript [ ["markdown" "mediawiki"] ["mediawiki" "docbook5" "html5" "man"] ]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue