X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=switch-mail-host;h=11c0f40a382f17906fab4621ed0e9543ac9e6b29;hb=e03e99848bc5fbc7ad527513e0aa4b0fc9c4d6fb;hp=10fcd9f12d82c580e1ee3536c2ac51ed08e9c969;hpb=1059b8ac11f567b9a8eec1e34a7ab6e791721dca;p=distro-setup diff --git a/switch-mail-host b/switch-mail-host old mode 100644 new mode 100755 index 10fcd9f..11c0f40 --- a/switch-mail-host +++ b/switch-mail-host @@ -26,10 +26,10 @@ restore_new_btrbk=false restore_old_btrbk=false cleanup() { if $restore_new_btrbk; then - $new_shell sudo systemctl start btrbk.timer + m $new_shell sudo systemctl start btrbk.timer fi if $restore_old_btrbk; then - $old_shell sudo systemctl start btrbk.timer + m $old_shell sudo systemctl start btrbk.timer fi } _errcatch_cleanup=cleanup # used by sourced err @@ -59,8 +59,8 @@ old_host=$1 new_host=$2 source /a/bin/bash_unpublished/source-state -if [[ $old_host != $MAIL_HOST ]]; then - read -p "warning: \$old_host != \$MAIL_HOST: $old_host != $MAIL_HOST, proceed? y/N " +if [[ $old_host != "$MAIL_HOST" ]]; then + read -r -p "warning: \$old_host != \$MAIL_HOST: $old_host != $MAIL_HOST, proceed? y/N " if [[ $REPLY != [yY] ]]; then exit 1 fi @@ -84,10 +84,7 @@ if [[ ! $new_host || ! $old_host ]]; then exit 1 fi - -source /a/bin/bash_unpublished/source-state - - +e $new_shell hostname new_hostname=$($new_shell hostname) ########### end initial processing, begin actually modifying things ########## @@ -102,11 +99,20 @@ if $old_shell systemctl is-active btrbk.timer; then fi btrbk_test="systemctl is-active btrbk.service" -while [[ $($new_shell $btrbk_test) != inactive ]] || [[ $($old_shell $btrbk_test) != inactive ]]; do - echo "$0: btrbk is running on new or old host. sleeping for 8 seconds" - sleep 6 - echo "$0: testing for btrbk activity in 2 seconds" - sleep 2 +while true; do + for shell in "$new_shell" "$old_shell"; do + e $shell $btrbk_test + status=$($shell $btrbk_test) ||: + case $status in + inactive|failed) : ;; + *) + e "btrbk active on shell:$shell, status:$status, sleeping 8 seconds" + sleep 8 + continue + ;; + esac + done + break done # ensure these are unused before doing anything