minor shell improvements
authorIan Kelling <ian@iankelling.org>
Wed, 23 Oct 2019 03:26:52 +0000 (23:26 -0400)
committerIan Kelling <ian@iankelling.org>
Wed, 23 Oct 2019 03:26:52 +0000 (23:26 -0400)
brc
brc2

diff --git a/brc b/brc
index 9e368d471a21a93ec3d4786e2513c0f442f5be5f..37e09a0c13399224b748366482fc84b22f7a96ed 100644 (file)
--- a/brc
+++ b/brc
@@ -412,6 +412,39 @@ despace() {
   done
 }
 
+dig() {
+  command dig +nostats +nocmd "$@"
+}
+# Output with sections sorted, and removal of query id, so 2 dig outputs can be diffed.
+digsort() {
+  local sec
+  sec=
+  dig +nordflag "$@" | sed -r 's/^(;; ->>HEADER<<-.*), id: .*/\1/' | while read -r l; do
+    if [[ $l == [^\;]* ]]; then
+      sec+="$l"$'\n'
+    else
+      if [[ $sec ]]; then
+        printf "%s" "$sec" | sort
+        sec=
+      fi
+      printf "%s\n" "$l"
+    fi
+  done
+}
+# compare digs to the 2 servers
+# usage: digdiff @server1 @server2 DIG_ARGS
+# note: only the soa master nameserver will respond with
+# ra "recursive answer" flag. That difference is meaningless afaik.
+digdiff() {
+  local s1 s2
+  s1=$1
+  shift
+  s2=$1
+  shift
+  digsort $s1 "$@" | tee /tmp/digdiff
+  diff -u /tmp/digdiff <(digsort $s2 "$@")
+}
+
 dt() {
   date "+%A, %B %d, %r" "$@"
 }
diff --git a/brc2 b/brc2
index 220f1241890f111bbf114f9fc5e1685342f2a768..577631eed08c9a7a19161fc046d5047af73ebb82 100644 (file)
--- a/brc2
+++ b/brc2
@@ -232,14 +232,15 @@ chrome() {
 }
 
 
-dat() { # do all tee, for more complex scripts
-  tee >(ssh frodo bash -l) >(bash -l) >(ssh x2 bash -l) >(ssh tp bash -l)
+# do all tee.
+# pipe to this, or just type like a shell
+dat() {
+  tee >(ssh frodo.b8.nz bash -l) >(ssh x2 bash -l) >(ssh tp.b8.nz bash -l) >(ssh kw bash -l) >(ssh tp.b8.nz bash -l)
 }
 da() { # do all
   local host
-  "$@"
-  for host in x2 tp kd; do
-    ssh $host $(printf "")
+  for host in x2 kw tp.b8.nz x3.b8.nz frodo.b8.nz; do
+    ssh $host "$@"
   done
 }
 
@@ -263,31 +264,8 @@ debian_pick_mirror () {
   sudo sed -ri "/http.us.debian.org/ s@( *[^ #]+ +)[^ ]+([^#]+).*@\1$url\2# http.us.debian.org@" /etc/apt/sources.list
   sudo apt-get update
 }
-dig() {
-  command dig +nostats +nocmd "$@"
-}
-# Output with sections sorted, and removal of query id, so 2 dig outputs can be diffed.
-digsort() {
-  local sec
-  sec=
-  dig +nordflag "$@" | sed -r 's/^(;; ->>HEADER<<-.*), id: .*/\1/' | while read -r l; do
-    if [[ $l == [^\;]* ]]; then
-      sec+="$l"$'\n'
-    else
-      if [[ $sec ]]; then
-        printf "%s" "$sec" | sort
-        sec=
-      fi
-      printf "%s\n" "$l"
-    fi
-  done
-}
-# note: only the soa master nameserver will respond with
-# ra "recursive answer" flag. That difference is meaningless afaik.
-# Same thing happens with gnu nameservers.
 digme() {
-  digsort "$@" @ns1.iankelling.org | tee /tmp/digme
-  diff -u /tmp/digme <(digsort "$@" @ns2.iankelling.org)
+  digdiff @ns{1,2}.iankelling.org "$@"
 }