else
tail -F "$@"
fi
- }
+}
ta() {
bn ta "$@"
}
-# 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 ]]
command dsh -c "$@"
}
+
+
# cat or bat with color if we have it
v() {
if type -t batcat >/dev/null; then
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
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 ###
# dsh on btrbk hosts
dsb() {
- :
+ dsh -g btrbkroot "$@"
+}
+# like dsb, but normal user.
+dsu() {
+ dsh -g btrbk "$@"
}
# dsh a file and run it
wait_factor=$(( pingms / 20 ))
if (( wait_factor == 0 )); then
wait_factor=1
- fi
+ fi
else
wait_factor=10
fi
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 </dev/null &'
fi
- m rsync --mkpath -a -f"- */" -f"+ *" /var/log/btrbk/ root@$tg:/var/log/btrbk/$HOSTNAME
cmd=/usr/local/bin/mail-backup-clean
ssh root@$tg "if test -x $cmd; then $cmd; fi"
done
- if [[ $source ]]; then
- m rsync --mkpath -a -f"- */" -f"+ *" $source:/var/log/btrbk/ /var/log/btrbk/$source
- fi
+fi
+
+## compress and copy logs in case a machine dies, we still have its logs.
+bzip2 $log_path
+for tg in ${targets[@]}; do
+ # we generated
+ m rsync --mkpath -a -f"- */" -f"+ *" /var/log/btrbk/ root@$tg:/var/log/btrbk/$HOSTNAME
+done
+if [[ $source ]]; then
+ m rsync --mkpath -a -f"- */" -f"+ *" $source:/var/log/btrbk/ /var/log/btrbk/$source
fi
mexit $ret
if (( try_left < timeout )); then
timeout=$try_left
fi
- if timeout $timeout rsync --chown iank:iank -e "ssh -oIdentitiesOnly=yes -F /dev/null -i /root/.ssh/jtuttle" -t --inplace -r 'jtuttle@fencepost.gnu.org:/home/j/jtuttle/Maildir/new/' /m/md/l/testignore/new; then
+ if timeout $timeout rsync --chown iank:iank -e "ssh -oIdentitiesOnly=yes -F none -i /root/.ssh/jtuttle" -t --inplace -r 'jtuttle@fencepost.gnu.org:/home/j/jtuttle/Maildir/new/' /m/md/l/testignore/new; then
did_rsync=true
else
sleep 4