From e2fb88c7f8c32cf6442a399844bd2fbd1c912027 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Sat, 30 Mar 2019 14:56:05 -0400 Subject: [PATCH] fix bug when sshing to fqdn etc --- switch-mail-host | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/switch-mail-host b/switch-mail-host index b67203a..9ebd2a7 100755 --- a/switch-mail-host +++ b/switch-mail-host @@ -107,6 +107,8 @@ while $new_shell $btrbk_test || $old_shell $btrbk_test; do sleep 2 done +new_hostname=$($new_shell hostname) + ########### end initial processing, begin actually modifying things ########## restore_new_btrbk=false @@ -121,10 +123,10 @@ if $old_shell systemctl is-active btrbk.timer; then fi -$new_shell bash -s <<'EOF' +$new_shell bash -xs <<'EOF' set -eE -if mountpoint /m; then sudo umount /m; fi -if mountpoint /o; then sudo umount /o; fi +if mountpoint -q /m; then sudo umount /m; fi +if mountpoint -q /o; then sudo umount /o; fi EOF # if new_host is not on home network, make mail.iankelling.org not resolve @@ -132,17 +134,16 @@ EOF if [[ $new_host == $HOSTNAME ]] && ! $at_home; then echo | $wrt_shell cedit mail_host /etc/hosts || [[ $? == 1 ]] # 1 means file changed. else - $wrt_shell bash -s <