echo "mountpoints: ${mountpoints[*]}"
+uninstalled-file-die() {
+ err "uninstalled file $1. run install-my-scripts or rerun with -f"
+ exit 1
+}
+if ! $force; then
+ install_bin_files=(
+ mount-latest-subvol
+ check-subvol-stale
+ btrbk-run
+ )
+ for f in ${install_bin_files[@]}; do
+ if ! diff -q /a/bin/ds/$f /usr/local/bin/$f; then
+ uninstalled-file-die $f
+ fi
+ done
+ if ! diff -q /a/bin/errhandle/err /usr/local/lib/err; then
+ uninstalled-file-die err
+ fi
+fi
+
# pull_reexec stops us from getting into an infinite loop if there is some
# kind of weird problem
mail_only=false
host2_only=false
force=false
+pull_reexec=false
mp_args="-m /o,/a,/ar,/q,/qd,/qr"
-temp=$(getopt -l force,help aioh "$@") || usage 1
+orig_args=("$@")
+temp=$(getopt -l force,pull-reexec,help aioh "$@") || usage 1
eval set -- "$temp"
while true; do
case $1 in
-a) snapshot_arg=resume ;;
--force) force=true ;;
-i) incremental_arg="-i" ;;
+ # internal option for rerunning under newer old_host when doing pull
+ --pull-reexec) pull_reexec=true;;
-o)
mail_only=true ;;
-h|--help) usage ;;
exit 1
fi
+uninstalled-file-die() {
+ err "uninstalled file $1. run install-my-scripts or rerun with -f"
+ exit 1
+}
+
+if ! $force; then
+ install_bin_files=(
+ mount-latest-subvol
+ check-subvol-stale
+ btrbk-run
+ switch-mail-host
+ )
+ for f in ${install_bin_files[@]}; do
+ if ! diff -q /a/bin/ds/$f /usr/local/bin/$f; then
+ uninstalled-file-die $f
+ fi
+ done
+ if ! diff -q /a/bin/errhandle/err /usr/local/lib/err; then
+ uninstalled-file-die err
+ fi
+fi
+
source /a/bin/bash_unpublished/source-state
direction=$1
new_hostname=$HOSTNAME
bbk_args="-s $old_host"
old_shell="ssh -F $HOME/.ssh/confighome root@$old_host"
- old_shelliank="ssh -F $HOME/.ssh/confighome iank@$old_host"
# tests ssh connection. crafted this to not need to do escape chars
f=/a/bin/bash_unpublished/source-state
if ! old_info=($($old_shell "hostname; sed -n s,.*MAIL_HOST=,,p $f; sed -n s,.*HOST2=,,p $f")); then
old_hostname=${old_info[0]}
MAIL_HOST=${old_info[1]}
HOST2=${old_info[2]}
+
+ if ! $mail_only && ! $pull_reexec ; then
+ tmpf=$(mktemp)
+ m scp -F $HOME/.ssh/confighome root@$old_host:/usr/local/bin/switch-mail-host $tmpf
+ if ! diff -q $tmpf ${BASH_SOURCE[0]}; then
+ e "found different version on old_host=$old_hostname, reexecing"
+ install -T $tmpf /usr/local/bin/switch-mail-host
+ m /usr/local/bin/switch-mail-host --pull-reexec "${orig_args[@]}"
+ mexit 0
+ fi
+ fi
+
;;
*)
err invalid first argument