From: Ian Kelling Date: Sat, 6 Jul 2024 22:23:16 +0000 (-0400) Subject: minor improvements X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=77aca9ae11e8d19f3e499687faaf7553096c9cde;p=distro-setup minor improvements --- diff --git a/brc b/brc index d73342d..c3d7686 100644 --- a/brc +++ b/brc @@ -1338,7 +1338,7 @@ tailf() { else tail -F "$@" fi - } +} ta() { bn ta "$@" @@ -2930,14 +2930,27 @@ slr() { } -# ssh solo -# -# WARNING: If you are trying to use -i, remember that keys added to -# agent previously will still be tried. Use ssh-add -D to remove all -# keys from the agent. +# ssh solo, without multiplexing. Good for debugging / testing. sss() { ssh -oControlMaster=no -oControlPath=/ "$@" } + +# ssh that respects -i as the only key to use. Good for debugging. +# +# Without ControlMaster/ControlPath, it would reuse an existing ssh +# connection. +# +# Without IdentityAgent, it would send keys in the ssh -agent (could +# also be fixed by ssh-add -D to delete them. +# +# Without -F, we'd get identities specified in our ssh config. +# +# Without AddKeysToAgent=no, we'd get keys added to the agent we might +# not want, and without the ask setting. +sshi() { + ssh -oControlMaster=no -oControlPath=/ -oAddKeysToAgent=no -F none -oIdentityAgent=none "$@" +} + # kill off old shared socket then ssh ssk() { m ssh -O exit "$@" || [[ $? == 255 ]] @@ -3637,6 +3650,8 @@ dsh() { command dsh -c "$@" } + + # cat or bat with color if we have it v() { if type -t batcat >/dev/null; then diff --git a/brc2 b/brc2 index 3236dbc..eab5d4a 100644 --- a/brc2 +++ b/brc2 @@ -82,11 +82,16 @@ export WCDHOME=/a case $EUID in 0) # shellcheck disable=SC2034 # used in brc - SL_SSH_ARGS="-F $HOME/.ssh/confighome" + SL_SSH_ARGS="-F /root/.ssh/confighome" + dsh() { + command dsh -o -F/root/.ssh/confighome -c "$@" + } ;; esac + + # * include files # generated instead of dynamic for the benefit of shellcheck @@ -2950,9 +2955,9 @@ EOF for ip in "${!ip_to_hosts[@]}"; do echo "$ip${ip_to_hosts[$ip]}" done | s cedit -e hosts-file-up /etc/hosts - for host in ${hosts[@]}; do - echo $host - done >/p/c/subdir_files/.dsh/group/btrbk + + printf "root@%s\n" ${hosts[@]} >/p/c/subdir_files/.dsh/group/btrbkroot + printf "%s\n" ${hosts[@]} >/p/c/subdir_files/.dsh/group/btrbk ### end focus on hosts file update ### @@ -4906,7 +4911,11 @@ opensslcertinfo() { # dsh on btrbk hosts dsb() { - : + dsh -g btrbkroot "$@" +} +# like dsb, but normal user. +dsu() { + dsh -g btrbk "$@" } # dsh a file and run it diff --git a/btrbk-run b/btrbk-run index 7769e64..c8aa989 100644 --- a/btrbk-run +++ b/btrbk-run @@ -500,7 +500,7 @@ else wait_factor=$(( pingms / 20 )) if (( wait_factor == 0 )); then wait_factor=1 - fi + fi else wait_factor=10 fi @@ -919,21 +919,27 @@ else done fi -bzip2 $log_path -# todo, we get hostnames earlier, reuse that. + +## run extra commands on targets if [[ $ret == 0 ]]; then for tg in ${targets[@]}; do h=$(ssh $tg hostname) if [[ $h == kd && $HOSTNAME == x3 && $HOSTNAME == "$MAIL_HOST" ]]; then d ssh root@$tg 'btrbk-spread-wrap &>/dev/null