summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-06-15 19:55:28 +0200
committertv <tv@krebsco.de>2017-06-15 19:55:28 +0200
commita74be81827b4cd70f738633de03f56c9349484f3 (patch)
tree6972f176cfb9e1b971dbe897b49b996146bada51 /krebs/5pkgs/simple/whatsupnix/whatsupnix.bash
parent1f8ef7803e0df423532cf8fbdd6d83250ab52bd6 (diff)
whatsupnix: add support for remote hosts
Diffstat (limited to 'krebs/5pkgs/simple/whatsupnix/whatsupnix.bash')
-rw-r--r--krebs/5pkgs/simple/whatsupnix/whatsupnix.bash43
1 files changed, 36 insertions, 7 deletions
diff --git a/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash b/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash
index a19410055..eba44be1c 100644
--- a/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash
+++ b/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash
@@ -6,7 +6,7 @@
# Usage:
#
# set -o pipefail
-# nix-build ... -Q ... | whatsupnix
+# nix-build ... -Q ... | whatsupnix [user@target[:port]]
#
@@ -18,17 +18,46 @@ trap 'rm -f -- "$broken"' EXIT
exec >&2
-$GAWK -v broken="$broken" -f <(cat - <<- 'AWK'
- match($0, /builder for .*(\/nix\/store\/.+\.drv).* failed/, m) {
+$GAWK -v broken="$broken" '
+ match($0, /^builder for ‘(\/nix\/store\/[^’]+\.drv)’ failed/, m) {
print m[1] >> broken
}
{ print $0 }
-AWK
-)
+'
+
+case $# in
+ 0)
+ print_log() {
+ $NIX_STORE -l "$1"
+ }
+ ;;
+ 1)
+ remote_user=${1%%@*}
+ if test "$remote_user" = "$1"; then
+ remote_user=root
+ else
+ set -- "${1#$remote_user@}"
+ fi
+ remote_port=${1##*:}
+ if test "$remote_port" = "$1"; then
+ remote_port=22
+ else
+ set -- "${1%:$remote_port}"
+ fi
+ remote_host=$1
+ print_log() {
+ ssh "$remote_user@$remote_host" -p "$remote_port" \
+ nix-store -l "$1"
+ }
+ ;;
+ *)
+ echo "usage: whatsupnix [[USER@]HOST[:PORT]]" >&2
+ exit 1
+esac
export NIX_PAGER='' # for nix-store
while read -r drv; do
- title="** FAILED $drv LOG **"
+ title="** FAILED $drv LOG **"
frame=${title//?/*}
echo "$frame"
@@ -36,7 +65,7 @@ while read -r drv; do
echo "$frame"
echo
- $NIX_STORE -l "$drv"
+ print_log "$drv"
echo
done < "$broken"