From 3e5e60efe20de2e109ad48745a5dcee04d7417a1 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Tue, 23 Apr 2024 20:51:06 -0400 Subject: [PATCH] dns fix, some improvements --- brc | 35 ++++++++++++++++++++++------------- brc2 | 49 ++++++++++++++++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/brc b/brc index 5105c59..4a6f672 100644 --- a/brc +++ b/brc @@ -879,14 +879,14 @@ _khfix-common() { fi ll ~/.ssh/known_hosts } -khfix-r() { # known hosts fix + root +khfix-r() { # known hosts fix without syncing to root user _khfix-common "$@" || return 1 ssh $1 : - rootsshsync } khfix() { _khfix-common "$@" || return 1 ssh $1 : + rootsshsync } # copy path into clipboard @@ -1672,9 +1672,9 @@ grr() { # grep recursive # Don't return 1 on nonmatch because this is meant to be # interactive, not in a conditional. if [[ ${#@} == 1 ]]; then - grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -riIP --color=auto "$@" . || [[ $? == 1 ]] + grep -E --exclude-dir='*.emacs.d' --exclude-dir='*.git' -riIP --color=auto "$@" . || [[ $? == 1 ]] else - grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -riIP --color=auto "$@" || [[ $? == 1 ]] + grep -E --exclude-dir='*.emacs.d' --exclude-dir='*.git' -riIP --color=auto "$@" || [[ $? == 1 ]] fi } ccomp grep gr grr @@ -3243,6 +3243,16 @@ if [[ $- == *i* ]]; then # so I've thrown a bunch of things at the wall to speed it up. prompt-command() { local return=$? # this MUST COME FIRST + + # all usable colors: + # black + # green nonzero exit (pri 1) + # purple default + # purple bold + # red pwd different owner & group & not writable (pri 2) + # red bold pwd different owner & group & writable (pri 2) + # yellow + local ps_char ps_color unset IFS @@ -3250,22 +3260,21 @@ if [[ $- == *i* ]]; then history -a # save history fi - case $return in - 0) ps_color="$term_purple" - ps_char='\$' - ;; - *) ps_color="$term_green" - ps_char="$return \\$" - ;; - esac + ps_color="$term_purple" + ps_char='\$' if [[ ! -O . ]]; then # not owner if [[ -w . ]]; then # writable ps_color="$term_bold$term_red" else - ps_color="$term_bold$term_green" + ps_color="$term_red" fi fi + if [[ $return != 0 ]]; then + ps_color="$term_green" + ps_char="$return \\$" + fi + # faster than sourceing the file im guessing if [[ -e /dev/shm/iank-status && ! -e /tmp/quiet-status ]]; then eval "$(< /dev/shm/iank-status)" diff --git a/brc2 b/brc2 index 5804466..33384bc 100644 --- a/brc2 +++ b/brc2 @@ -1792,21 +1792,13 @@ bindpush() { dsign iankelling.org expertpathologyreview.com zroe.org amnimal.ninja lipush for h in li bk; do - e sshing $h - ssh $h.b8.nz <<'EOF' -source ~/.bashrc -m dnsup -EOF + m ssh $h.b8.nz dnsup done } bindpushb8() { lipush for h in li bk; do - e sshing $h - ssh $h.b8.nz <<'EOF' -source ~/.bashrc -m dnsb8 -EOF + m ssh $h.b8.nz dnsb8 done } @@ -1817,8 +1809,18 @@ dnsup() { dnsb8() { local f=/var/lib/bind/db.b8.nz m ser stop named - m sleep 1 - m sudo rm -fv $f.jnl $f.signed.jnl + # jbk is like a temp file. dunno if removing it helps + + i=0 + while pgrep '^named$' &>/dev/null; do + sleep .5 + i=$(( i + 1 )) + if (( i > 100 )); then + echo "dnsb8: error: timeout waiting for named to exit" + return 1 + fi + done + m sudo rm -fv $f.jnl $f.signed.jnl $f.jbk m sudo install -m 644 -o bind -g bind /p/c/machine_specific/vps/bind-initial/db.b8.nz $f m ser restart named } @@ -2630,6 +2632,16 @@ wgkey() { umask $umask_orig } +host-info-all() { + host-info-update + bindpushb8 + wrt-setup +} + + +# if you change a host's ip, then run +# bindpushb8 +# wrt-setup host-info-update() { local -A vpn_ips host_ips host_macs nonvpn_ips @@ -2673,8 +2685,6 @@ IdentityFile ~/.ssh/home EOF - grep -E '^[a-z0-9]+[[:space:]]' /p/c/machine_specific/vps/bind-initial/db.b8.nz | awk '{print $1,$3}' - local host ipsuf f files sedi '/edits below here are made automatically/,$d' /p/c/machine_specific/li/filesystem/etc/wireguard/wgmail.conf @@ -2728,7 +2738,7 @@ EOF echo 'local-data-ptr: "$l.'$ipsuf $host.b8.nz'"' done echo "EOF" - } | u /p/ptr-data + } | u /p/c/ptr-data { echo "cat <