From e586abf78efc42cee99425e183301ea0124d4814 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 20 Mar 2015 13:53:26 -0400 Subject: [PATCH] eg-updater standalone staff build; auto-detach * Adds a new -k flag for building a staff client without any other code deployments or restarts. Git checkout flags, if specified, are honored. * Removes the -d (no detach) option. The script now automatically detaches if it finds a ping.txt file. Otherwise, it skips the detach step. Signed-off-by: Bill Erickson --- KCLS/admin-scripts/eg-updater.sh | 85 ++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/KCLS/admin-scripts/eg-updater.sh b/KCLS/admin-scripts/eg-updater.sh index 260280550f..4dbc79ad34 100755 --- a/KCLS/admin-scripts/eg-updater.sh +++ b/KCLS/admin-scripts/eg-updater.sh @@ -20,6 +20,7 @@ OWNER=$(stat -c %U $EVERGREEN_BASE); BUILDER="" OSRF="" GIT="git" +DETACH_NEEDED="YES" # command line arguments @@ -29,13 +30,13 @@ GIT_PULL="" CLIENT_BUILD_ID="" CLIENT_SERIES_ID="" GIT_REMOTE="kcls" -SKIP_DETACH="" REATTACH="" SKIP_APACHE="" WEB_ONLY="" REBUILD="" BUILD_XUL="" RESTART_ONLY="" +STAFF_CLIENT_ONLY="" # if the script exits early, SUCCESS will be left as 0, # which is our sign to warn the user. @@ -53,14 +54,14 @@ function usage { $0 -t kcls-2.4.001 Check out and update the git branch 'dev/berick/abc-123-foobar', - then deploy with a staff client build ID of 'test-123'. + then deploy with a staff client build ID of 'rel_2_4_1' - $0 -b dev/berick/abc-123-foobar -s test-123 + $0 -b dev/berick/abc-123-foobar -s rel_2_4_1 - Pull changes to the currently checked out branch, avoid - detaching the brick, then copy only the web files into place. + Pull changes to the currently checked out branch, then + copy only the web files into place. - $0 -d -w -p + $0 -w -p Options: @@ -96,16 +97,10 @@ function usage { -r Defaults to "kcls". - -d - Do NOT detach the server as one normally does for a brick. - This is useful for development servers. The default is - to always detach. - -a Automatically reattach the brick after the update. This is useful if there is no desire to manually test the brick after the update. The default is to leave detached. - This is ignored if -d is specified. -n Do not stop/start Apache. This is useful for non-brick @@ -125,7 +120,12 @@ function usage { -x Build a XUL client and place it in the published "builds" - directory. + directory. This happens alongside a build/install/restart. + See -k for staff client building only. + + -k Build a XUL client without performing any other installation + or restart actions. Flags -p, -t, -b are honored if + specified. -f Service startup sleep time in seconds. Defaults to @@ -170,6 +170,17 @@ function set_builder { function inspect_params { + # no need to detach the brick when not restarting services + if [ -n "$STAFF_CLIENT_ONLY" -o -n "$WEB_ONLY" ]; then + DETACH_NEEDED="" + fi + + if [ -n "$RESTART_ONLY" ]; then + # restart trumps all other variables. + # avoid warning about other variable issues + return + fi + if [ -z "$CLIENT_BUILD_ID" -a -n "$GIT_TAG" ]; then # default to using the git tag if no client build ID is provided CLIENT_BUILD_ID="$GIT_TAG"; @@ -300,6 +311,8 @@ function publish_staff_client_build { } function build_staff_client { + announce "Building staff client installer" + cd $XUL_DIR/builds/ if [ ! -r "xulrunner-$XULRUNNER_VERSION.en-US.win32.zip" ]; then $OSRF wget "http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/$XULRUNNER_VERSION/runtimes/xulrunner-$XULRUNNER_VERSION.en-US.win32.zip" @@ -408,10 +421,8 @@ function recover_opensrf_file_ownership { set -e } - -function deploy_code { - - announce "Building and installing Evergreen" +function build_code { + announce "Building Evergreen" # the separate incantations for $BUILDER / $OSRF are required # becuase it's an error to preceded setting a variable with @@ -434,6 +445,11 @@ function deploy_code { make clean all > /dev/null fi fi +} + + +function deploy_code { + announce "Installing Evergreen" # Put client server files under the build-id specific directory # so we can track each build individually. A symlink from the @@ -478,7 +494,7 @@ function start_services { trap on_exit EXIT; -while getopts "t:b:r:s:i:f:pdanwchxo" opt; do +while getopts "t:b:r:s:i:f:panwchxok" opt; do case $opt in t) GIT_TAG="$OPTARG";; b) GIT_BRANCH="$OPTARG";; @@ -487,42 +503,44 @@ while getopts "t:b:r:s:i:f:pdanwchxo" opt; do i) CLIENT_SERIES_ID="$OPTARG";; f) START_SLEEP="$OPTARG";; p) GIT_PULL="YES";; - d) SKIP_DETACH="YES";; a) REATTACH="YES";; n) SKIP_APACHE="YES";; w) WEB_ONLY="YES";; c) REBUILD="YES";; x) BUILD_XUL="YES";; o) RESTART_ONLY="YES";; + k) STAFF_CLIENT_ONLY="YES";; h|*) usage; esac done; set_builder; -if [ -z "$RESTART_ONLY" ]; then - # restart trumps all other commands. - inspect_params; -fi +inspect_params; -if [ -z "$SKIP_DETACH" ]; then +if [ -n "$DETACH_NEEDED" ]; then if [ ! -f $PING_FILE ]; then - announce "Detach requested, but no ping file exists at $PING_FILE" - announce "Try -d to skip the brick detach step." - exit; - fi; + announce "No ping file found. Skipping detach." - announce "Detaching brick and sleeping $DETACH_SLEEP seconds" - $OSRF mv $PING_FILE $PING_FILE- - sleep $DETACH_SLEEP + else + announce "Detaching brick and sleeping $DETACH_SLEEP seconds" + $OSRF mv $PING_FILE $PING_FILE- + sleep $DETACH_SLEEP + fi fi; cd $EVERGREEN_BASE; if [ -n "$WEB_ONLY" ]; then # web-only updates don't require restarts. - fetch_code + fetch_code # no-op if no code options are specified deploy_web + +elif [ -n "$STAFF_CLIENT_ONLY" ]; then + fetch_code # no-op if no code options are specified + build_code + build_staff_client + else if [ -z "$SKIP_APACHE" ]; then @@ -543,6 +561,7 @@ else else fetch_code; + build_code; deploy_code; start_services; @@ -556,7 +575,7 @@ else fi; fi -if [ -z "$SKIP_DETACH" ]; then +if [ -f $PING_FILE- ]; then # we detached if [ -n "$REATTACH" ]; then announce "Reattaching brick after $START_SLEEP seconds" sleep $START_SLEEP; -- 2.11.0