mostly fixes for new error handling
[distro-setup] / switch-mail-host
index a0c590d0ae8b3287715584cda9eaf26119eb8c15..8f0912f7246e1e9fd62af985c8365215f999bda1 100755 (executable)
@@ -24,7 +24,7 @@ EOF
 
 restore_new_btrbk=false
 restore_old_btrbk=false
-cleanup() {
+errcatch-cleanup() {
   if $restore_new_btrbk; then
     e WARNING: due to failure, btrbk.timer may need manual restoration:
     e $new_shell sudo systemctl start btrbk.timer
@@ -100,12 +100,10 @@ new_hostname=$($new_shell hostname)
 
 if $new_shell systemctl is-active btrbk.timer; then
   m $new_shell sudo systemctl stop btrbk.timer
-  _errcatch_cleanup=cleanup
   restore_new_btrbk=true
 fi
 if $old_shell systemctl is-active btrbk.timer; then
   m $old_shell sudo systemctl stop btrbk.timer
-  _errcatch_cleanup=cleanup
   restore_old_btrbk=true
 fi
 
@@ -150,13 +148,19 @@ EOF
 # ipv6 i think.
 
 
+if ! m btrbk-run -v $bbk_args $mp_args; then
+  ret=$?
+  err "failed initial btrbk"
+  exit $ret
+fi
+
 
 m $old_shell /a/exe/primary-setup $new_hostname
 
-if ! m btrbk-run -v $bbk_args $mp_args; then
+if ! m btrbk-run -v $bbk_args -m /o; then
   ret=$?
   bang="$(printf "$(tput setaf 5)█$(tput sgr0)%.0s" 1 2 3 4 5 6 7)"
-  e $bang failed btrbk. restoring old host as primary
+  e $bang failed btrbk of /o. restoring old host as primary
   m $old_shell /a/exe/primary-setup localhost
   exit $ret
 fi