add switch-host2
authorIan Kelling <ian@iankelling.org>
Thu, 1 Sep 2022 16:37:47 +0000 (12:37 -0400)
committerIan Kelling <ian@iankelling.org>
Thu, 1 Sep 2022 16:37:47 +0000 (12:37 -0400)
brc2
switch-host2 [new symlink]
switch-mail-host

diff --git a/brc2 b/brc2
index 4877c3f25e0af35708135e86e5ee72b64d7bd73a..b97d0670ea568d2fa9022321c3072bd3da578637 100644 (file)
--- a/brc2
+++ b/brc2
@@ -504,7 +504,7 @@ srun() {
   fg &>/dev/null ||:
 }
 
-sm() {
+sm() { # switch mail host
   local tmp keyhash
   c /
   # run latest
@@ -517,6 +517,19 @@ sm() {
   s jrun switch-mail-host "$@"
   return $ret
 }
+sh2() { # switch host2
+  local tmp keyhash
+  c /
+  # run latest
+  keyhash=$(s ssh-keygen -lf /root/.ssh/home  | awk '{print $2}')
+  tmp=$(s ssh-add -l | awk '$2 == "'$keyhash'"')
+  if [[ ! $tmp ]]; then
+    s ssh-add /root/.ssh/home
+  fi
+  install-my-scripts
+  s jrun switch-host2 "$@"
+  return $ret
+}
 
 # shellcheck disable=SC2120
 lipush() {
diff --git a/switch-host2 b/switch-host2
new file mode 120000 (symlink)
index 0000000..a9df53c
--- /dev/null
@@ -0,0 +1 @@
+switch-mail-host
\ No newline at end of file
index fd3d032cce84c34bec53d82b90f430f5bb0a0308..09bd739abd4c294946ac96426cb79367446282ae 100644 (file)
@@ -4,7 +4,7 @@ source /usr/local/lib/err
 
 usage() {
   cat <<EOF
-Usage: ${0##*/} [OPTIONS] push|pull HOST
+Usage: switch-mail-host|switch-host2 [OPTIONS] push|pull HOST
 
 Turn off mail receiving on OLD_HOST, run btrbk to move mail to NEW_HOST,
 turn on mail receiving on NEW_HOST.  Assumes we want to move all