iankelling.org
/
git
/
distro-setup
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8826440
)
fix bug when sshing to fqdn etc
author
Ian Kelling
<iank@fsf.org>
Sat, 30 Mar 2019 18:56:05 +0000
(14:56 -0400)
committer
Ian Kelling
<iank@fsf.org>
Sat, 30 Mar 2019 18:56:05 +0000
(14:56 -0400)
switch-mail-host
patch
|
blob
|
history
diff --git
a/switch-mail-host
b/switch-mail-host
index b67203aabc475608a4768cbcc2204126979ef48b..9ebd2a73cd1e41731e2318eea8cc9369bb9a7375 100755
(executable)
--- 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
sleep 2
done
+new_hostname=$($new_shell hostname)
+
########### end initial processing, begin actually modifying things ##########
restore_new_btrbk=false
########### 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
fi
-$new_shell bash -s <<'EOF'
+$new_shell bash -
x
s <<'EOF'
set -eE
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
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
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 <<EOFOUTER
- if ! cedit mail_host /etc/hosts <<EOF; then
-\$(grep "\b$new_host\b" /etc/hosts | awk '{print \$1}') mail.iankelling.org
+ $wrt_shell bash -xs $new_host <<'EOFOUTER'
+new_host=$1
+cedit mail_host /etc/hosts <<EOF || /etc/init.d/dnsmasq restart
+$(grep "\b$new_hostname\b" /etc/hosts | awk '{print $1}') mail.iankelling.org
EOF
EOF
-/etc/init.d/dnsmasq restart
EOFOUTER
fi
EOFOUTER
fi
-
$old_shell /a/bin/distro-setup/install-my-scripts
$old_shell /a/bin/distro-setup/install-my-scripts
-$old_shell primary-setup $new_host
+$old_shell primary-setup $new_host
name
sudo dd of=/etc/btrbk.conf <<'EOF'
ssh_identity /root/.ssh/home
sudo dd of=/etc/btrbk.conf <<'EOF'
ssh_identity /root/.ssh/home
@@
-198,7
+199,7
@@
EOF
sudo btrbk -l debug --progress run
$new_shell /a/bin/distro-setup/install-my-scripts
$new_shell mount-latest-subvol
sudo btrbk -l debug --progress run
$new_shell /a/bin/distro-setup/install-my-scripts
$new_shell mount-latest-subvol
-$new_shell primary-setup $new_host
+$new_shell primary-setup $new_host
name
if $restore_new_btrbk; then
$new_shell sudo systemctl start btrbk.timer
if $restore_new_btrbk; then
$new_shell sudo systemctl start btrbk.timer