From 8270a99dcb94110262b7b8387c49fab60fed9548 Mon Sep 17 00:00:00 2001 From: yage Date: Sat, 1 Oct 2022 13:50:12 -0600 Subject: [PATCH] reboot option for server update --- bin/update-all-servers | 7 ++++++- setup/git.zsh | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/update-all-servers b/bin/update-all-servers index 553ba9b..fd4022f 100755 --- a/bin/update-all-servers +++ b/bin/update-all-servers @@ -25,6 +25,7 @@ UPDATE_ALL() { UPDATE() { local SERVER_HOST="$1" local COMMAND="${@:2} || $UPDATE_REMINDER" + [[ $2 =~ ^reboot ]] && [[ $SERVER_HOST =~ $LOCAL_HOST ]] && return 0 [[ $SERVER_HOST =~ $LOCAL_HOST ]] || { COMMAND="ssh -t $SERVER_HOST.lan 'source ~/.zshrc >/dev/null 2>&1; $COMMAND'" @@ -34,7 +35,6 @@ UPDATE() { } WAIT_FOR_UPDATES() { - __STATUS 'waiting for updates to complete' while [[ $(tmux list-windows -t $SESSION 2>/dev/null | wc -l) -gt 1 ]] do sleep 1 @@ -58,6 +58,7 @@ CHECK_SESSION && __FAIL 1 'update currently in progress' tmux new -d -s $SESSION "echo 'updating all systems'; echo '(leave this window open)'; while true; do sleep 30; done" +__yN 'after update, do you want to reboot all machines?' && REBOOT=1 || REBOOT=0 __REMINDER __REMINDER 'manual action is required; (in another tab) connect to tmux:' __REMINDER "tmux a -t $SESSION" @@ -83,9 +84,13 @@ UPDATE_ALL '~/.wryn/bin/scwrypts config update' UPDATE_ALL '~/.wryn/bin/scwrypts media push' UPDATE_ALL '~/.wryn/bin/scwrypts media pull' +[[ $REBOOT -eq 1 ]] && UPDATE_ALL 'reboot || sudo reboot' + tmux kill-session -t $SESSION >/dev/null 2>&1 CHECK_SESSION && __WARNING "unable to close tmux session '$SESSION'" __SUCCESS __SUCCESS 'finished system update accross all servers' __SUCCESS + +[[ $REBOOT -eq 1 ]] && { __STATUS 'rebooting host machine'; sleep 3; reboot || sudo reboot; } diff --git a/setup/git.zsh b/setup/git.zsh index 1056e9a..0f8463f 100644 --- a/setup/git.zsh +++ b/setup/git.zsh @@ -8,6 +8,9 @@ SETUP__GIT() { git remote set-url --add --push origin git@github.com:wrynegade/dotwryn.git git remote set-url --add --push origin git@yage.io:wrynegade/dotwryn.git git remote set-url --add --push origin git@bitbucket.org:wrynegade/dotwryn.git + git fetch origin >/dev/null 2>&1 + git branch --set-upstream-to=origin/main main >/dev/null 2>&1 + __STATUS 'updating upstream for zsh/plugins/code-activator' cd $DOTWRYN_PATH/zsh/plugins/code-activator