From: Bill Erickson Date: Thu, 21 May 2015 15:45:31 +0000 (-0400) Subject: Rename to eg-brick-manager for install X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=acce3a121c5bacfefdb53c098a8e47f38840416a;p=working%2FEvergreen.git Rename to eg-brick-manager for install Move brick-manager.sh to eg-brick-manager.sh to better namespace the executable for installation into /usr/bin, etc. Signed-off-by: Bill Erickson --- diff --git a/KCLS/admin-scripts/brick-manager.sh b/KCLS/admin-scripts/brick-manager.sh deleted file mode 100755 index 0ef08015f5..0000000000 --- a/KCLS/admin-scripts/brick-manager.sh +++ /dev/null @@ -1,179 +0,0 @@ -#!/bin/bash -set -euo pipefail -CLUSTER="" # default to no choice; avoid surprises. -SERVER="" -SERVERS=() -BASE_SCRIPT="cd /home/opensrf/Evergreen && KCLS/admin-scripts/eg-updater.sh -f 20" -EG_UPDATER_OPS="" -ACTION="" -LIST_SERVERS="" -PROMPT="" - -PRODUCTION_BRICKS=( - prod-brick01 - prod-brick02 - prod-brick03 - prod-brick04 - prod-brick05 - prod-brick06 - prod-brick07 -); - -STAGING_BRICKS=( - staging-brick01 - staging-brick02 -); - -TESTING_BRICKS=( - testing-brick01 - testing-brick02 -); - -function announce { - echo "$(date +'%F %T') $(hostname): $1" -} - -function usage { - cat < -a - $0 -c -e - - Runs eg-update.sh on all servers in the requested cluster, - using the parameters provided directly by the -e argument - or those generated by various canned operations. - - Examples: - - Roll all testing bricks and leave detached: - - $0 -c testing -a roll - - Roll all testing bricks and attach: - - $0 -c testing -a roll-attach - - Deploy the 'kcls-2.5.001' git tag to all bricks by - passing arguments via -e: - - $0 -c testing -e "-t kcls-2.5.001 -i kcls-2.5" - - Options: - -c - testing, staging, or production. One of -c or -s must - be provided. - - -s - Direct this script to a specific server. One of -c or -s - must be provided. - - -e - Options passed directly to eg-update.sh. See eg-updater.sh - for full list of supported options. - - -a - Short-cut for commonly used operations. - - Supported actions: - - roll - detach, restart services + apache - roll-attach - detach, restart services + apache, attach - stop - detach, stop services, stop apache - start - start services, start apache - start-attach - start services, start apache, attach. - detach - detach only - attach - attach only - -l - List servers for the requested cluster - - -p - Prompt to continue or exit between each server - -USAGE - exit -} - -function inspect_args { - - if [ -n "$SERVER" ]; then - SERVERS=( $SERVER ) - else - - if [ "$CLUSTER" = 'production' ]; then - SERVERS=( ${PRODUCTION_BRICKS[@]} ); - elif [ "$CLUSTER" = 'staging' ]; then - SERVERS=( ${STAGING_BRICKS[@]} ); - elif [ "$CLUSTER" = 'testing' ]; then - SERVERS=( ${TESTING_BRICKS[@]} ); - elif [ -n "$CLUSTER" ]; then - announce "Cluster '$CLUSTER' not supported." - announce "Supported clusters: testing staging production" - exit; - else - usage - fi - fi - - if [ -n "$ACTION" ]; then - if [ "$ACTION" = "roll" ]; then - EG_UPDATER_OPS="-o" - elif [ "$ACTION" = "roll-attach" ]; then - EG_UPDATER_OPS="-o -a" - elif [ "$ACTION" = "stop" ]; then - EG_UPDATER_OPS="-l" - elif [ "$ACTION" = "start" ]; then - EG_UPDATER_OPS="-m" - elif [ "$ACTION" = "start-attach" ]; then - EG_UPDATER_OPS="-ma" - elif [ "$ACTION" = "detach" ]; then - EG_UPDATER_OPS="-u" - elif [ "$ACTION" = "attach" ]; then - EG_UPDATER_OPS="-v" - fi - fi - - if [ -z "$LIST_SERVERS" -a -z "$EG_UPDATER_OPS" ]; then - usage; - fi -} - -while getopts "c:e:a:s:lp" opt; do - case $opt in - c) CLUSTER="$OPTARG";; - e) EG_UPDATER_OPS="$OPTARG";; - a) ACTION="$OPTARG";; - l) LIST_SERVERS="1";; - p) PROMPT="1";; - s) SERVER="$OPTARG";; - h|*) usage; - esac -done; - -inspect_args; - -if [ -n "$LIST_SERVERS" ]; then - echo "cluster = $CLUSTER" - echo "servers = ${SERVERS[*]}" - -else - - last_index=$((( ${#SERVERS[@]} - 1 ))) - - for index in "${!SERVERS[@]}"; do - - server="${SERVERS[$index]}" - announce "Connecting to $server" - - ssh -t $server "$BASE_SCRIPT $EG_UPDATER_OPS" - - if [ "$index" = "$last_index" ]; then - # avoid prompt on final server - break - - elif [ -n "$PROMPT" ]; then - echo "Completed $server; Enter to continue; Control-c to exit" - read X; - fi - - done -fi - diff --git a/KCLS/admin-scripts/eg-brick-manager.sh b/KCLS/admin-scripts/eg-brick-manager.sh new file mode 100755 index 0000000000..0ef08015f5 --- /dev/null +++ b/KCLS/admin-scripts/eg-brick-manager.sh @@ -0,0 +1,179 @@ +#!/bin/bash +set -euo pipefail +CLUSTER="" # default to no choice; avoid surprises. +SERVER="" +SERVERS=() +BASE_SCRIPT="cd /home/opensrf/Evergreen && KCLS/admin-scripts/eg-updater.sh -f 20" +EG_UPDATER_OPS="" +ACTION="" +LIST_SERVERS="" +PROMPT="" + +PRODUCTION_BRICKS=( + prod-brick01 + prod-brick02 + prod-brick03 + prod-brick04 + prod-brick05 + prod-brick06 + prod-brick07 +); + +STAGING_BRICKS=( + staging-brick01 + staging-brick02 +); + +TESTING_BRICKS=( + testing-brick01 + testing-brick02 +); + +function announce { + echo "$(date +'%F %T') $(hostname): $1" +} + +function usage { + cat < -a + $0 -c -e + + Runs eg-update.sh on all servers in the requested cluster, + using the parameters provided directly by the -e argument + or those generated by various canned operations. + + Examples: + + Roll all testing bricks and leave detached: + + $0 -c testing -a roll + + Roll all testing bricks and attach: + + $0 -c testing -a roll-attach + + Deploy the 'kcls-2.5.001' git tag to all bricks by + passing arguments via -e: + + $0 -c testing -e "-t kcls-2.5.001 -i kcls-2.5" + + Options: + -c + testing, staging, or production. One of -c or -s must + be provided. + + -s + Direct this script to a specific server. One of -c or -s + must be provided. + + -e + Options passed directly to eg-update.sh. See eg-updater.sh + for full list of supported options. + + -a + Short-cut for commonly used operations. + + Supported actions: + + roll - detach, restart services + apache + roll-attach - detach, restart services + apache, attach + stop - detach, stop services, stop apache + start - start services, start apache + start-attach - start services, start apache, attach. + detach - detach only + attach - attach only + -l + List servers for the requested cluster + + -p + Prompt to continue or exit between each server + +USAGE + exit +} + +function inspect_args { + + if [ -n "$SERVER" ]; then + SERVERS=( $SERVER ) + else + + if [ "$CLUSTER" = 'production' ]; then + SERVERS=( ${PRODUCTION_BRICKS[@]} ); + elif [ "$CLUSTER" = 'staging' ]; then + SERVERS=( ${STAGING_BRICKS[@]} ); + elif [ "$CLUSTER" = 'testing' ]; then + SERVERS=( ${TESTING_BRICKS[@]} ); + elif [ -n "$CLUSTER" ]; then + announce "Cluster '$CLUSTER' not supported." + announce "Supported clusters: testing staging production" + exit; + else + usage + fi + fi + + if [ -n "$ACTION" ]; then + if [ "$ACTION" = "roll" ]; then + EG_UPDATER_OPS="-o" + elif [ "$ACTION" = "roll-attach" ]; then + EG_UPDATER_OPS="-o -a" + elif [ "$ACTION" = "stop" ]; then + EG_UPDATER_OPS="-l" + elif [ "$ACTION" = "start" ]; then + EG_UPDATER_OPS="-m" + elif [ "$ACTION" = "start-attach" ]; then + EG_UPDATER_OPS="-ma" + elif [ "$ACTION" = "detach" ]; then + EG_UPDATER_OPS="-u" + elif [ "$ACTION" = "attach" ]; then + EG_UPDATER_OPS="-v" + fi + fi + + if [ -z "$LIST_SERVERS" -a -z "$EG_UPDATER_OPS" ]; then + usage; + fi +} + +while getopts "c:e:a:s:lp" opt; do + case $opt in + c) CLUSTER="$OPTARG";; + e) EG_UPDATER_OPS="$OPTARG";; + a) ACTION="$OPTARG";; + l) LIST_SERVERS="1";; + p) PROMPT="1";; + s) SERVER="$OPTARG";; + h|*) usage; + esac +done; + +inspect_args; + +if [ -n "$LIST_SERVERS" ]; then + echo "cluster = $CLUSTER" + echo "servers = ${SERVERS[*]}" + +else + + last_index=$((( ${#SERVERS[@]} - 1 ))) + + for index in "${!SERVERS[@]}"; do + + server="${SERVERS[$index]}" + announce "Connecting to $server" + + ssh -t $server "$BASE_SCRIPT $EG_UPDATER_OPS" + + if [ "$index" = "$last_index" ]; then + # avoid prompt on final server + break + + elif [ -n "$PROMPT" ]; then + echo "Completed $server; Enter to continue; Control-c to exit" + read X; + fi + + done +fi +