eg-brick-manager / eg-updater -g attach prompt
authorBill Erickson <berickxx@gmail.com>
Thu, 21 May 2015 16:35:21 +0000 (12:35 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
-g for both scripts now causes execution to pause before attaching a
server by prompting the user to continue or exit.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/admin-scripts/eg-brick-manager.sh
KCLS/admin-scripts/eg-updater.sh

index 0ef0801..d73647f 100755 (executable)
@@ -8,6 +8,7 @@ EG_UPDATER_OPS=""
 ACTION=""
 LIST_SERVERS=""
 PROMPT=""
+PROMPT_ATTACH=""
 
 PRODUCTION_BRICKS=( 
     prod-brick01 
@@ -88,6 +89,11 @@ function usage {
             -p
                 Prompt to continue or exit between each server
 
+            -g 
+                Prompt to continue or exit before attaching a server.
+                This is useful for testing a server before putting it
+                back into rotation.
+
 USAGE
     exit
 }
@@ -131,18 +137,23 @@ function inspect_args {
         fi
     fi
 
+    if [ -n "$PROMPT_ATTACH" ]; then
+        EG_UPDATER_OPS="$EG_UPDATER_OPS -g"
+    fi
+
     if  [ -z "$LIST_SERVERS" -a -z "$EG_UPDATER_OPS" ]; then
         usage;
     fi
 }
 
-while getopts "c:e:a:s:lp" opt; do
+while getopts "c:e:a:s:lpg" opt; do
     case $opt in
         c) CLUSTER="$OPTARG";;
         e) EG_UPDATER_OPS="$OPTARG";;
         a) ACTION="$OPTARG";;
         l) LIST_SERVERS="1";;
         p) PROMPT="1";;
+        g) PROMPT_ATTACH="1";;
         s) SERVER="$OPTARG";;
         h|*) usage;
     esac
@@ -156,6 +167,13 @@ if [ -n "$LIST_SERVERS" ]; then
 
 else
 
+    echo "Server(s): ${SERVERS[*]}"
+    echo "Action:    eg-updater.sh $EG_UPDATER_OPS"
+    echo ""
+    echo "Enter to continue; Control-c to exit"
+    echo ""
+    read X
+
     last_index=$((( ${#SERVERS[@]} - 1 )))
 
     for index in "${!SERVERS[@]}"; do
index 74a33fe..1c2b233 100755 (executable)
@@ -41,6 +41,7 @@ STOP_ONLY=""
 START_ONLY=""
 ATTACH_ONLY=""
 DETACH_ONLY=""
+CONFIRM_ATTACH=""
 
 # if the script exits early, SUCCESS will be left as 0, 
 # which is our sign to warn the user.
@@ -106,6 +107,10 @@ function usage {
                 useful if there is no desire to manually test the brick
                 after the update.  The default is to leave detached.
 
+            -g 
+                Prompt to continue before attaching.  This is useful for
+                testing a server before putting it back into rotation.
+
             -n
                 Do not stop/start Apache.  This is useful for non-brick
                 servers, like SIP, etc. servers.
@@ -526,12 +531,13 @@ function start_services {
 
 trap on_exit EXIT;
 
-while getopts "t:b:r:s:i:f:panwchxoklmuv" opt; do
+while getopts "t:b:r:s:i:f:pagnwchxoklmuv" opt; do
     case $opt in
         a) REATTACH="YES";;
         b) GIT_BRANCH="$OPTARG";;
         c) REBUILD="YES";;
         f) START_SLEEP="$OPTARG";;
+        g) CONFIRM_ATTACH="YES";;
         i) CLIENT_SERIES_ID="$OPTARG";;
         k) STAFF_CLIENT_ONLY="YES";;
         l) STOP_ONLY="YES";;
@@ -630,10 +636,15 @@ elif [ -z "$ATTACH_ONLY" ]; then
 fi
 
 if [ -f $PING_FILE- -a -z "$STOP_ONLY" ]; then # we detached
-    if [ -n "$REATTACH" ]; then
+    if [ -n "$REATTACH" -o -n "$CONFIRM_ATTACH" ]; then
         if [ -z "$ATTACH_ONLY" ]; then
-            announce "Sleeping $START_SLEEP seconds before attach"
-            sleep $START_SLEEP;
+            if [ -n "$CONFIRM_ATTACH" ]; then
+                announce "Press 'Enter' to attach server.  Control-c to exit."
+                read X
+            else 
+                announce "Sleeping $START_SLEEP seconds before attach"
+                sleep $START_SLEEP;
+            fi
         fi
         announce "Attaching brick"
         $OSRF mv $PING_FILE- $PING_FILE