From 67218413a4137f02cf51d53b0f7ceaf8999f24ad Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Tue, 29 Oct 2019 11:42:46 +0100 Subject: [PATCH] etc/info: add script to read restic informations --- assets/info_restic.sh | 43 +++++++++++++++++++++++++++++++++++++ system/desktop/packages.nix | 1 + 2 files changed, 44 insertions(+) create mode 100644 assets/info_restic.sh diff --git a/assets/info_restic.sh b/assets/info_restic.sh new file mode 100644 index 0000000..b042e57 --- /dev/null +++ b/assets/info_restic.sh @@ -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 - + + diff --git a/system/desktop/packages.nix b/system/desktop/packages.nix index 0186279..f427bd9 100644 --- a/system/desktop/packages.nix +++ b/system/desktop/packages.nix @@ -32,6 +32,7 @@ let ${pkgs.pandoc}/bin/pandoc \ --from ${inputFormat} \ --to ${outputFormat} \ + --standalone \ "$@" '';