#!/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 -