From 5bd321b00b6312d08c9a8ce025f609e0e28f8baa Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 23 Nov 2009 20:38:40 +0000 Subject: [PATCH] Update script patch from Joe Atzberger. === The purpose of this script is to consolidate a lot of the annoying and error-prone tasks associated with an upgrade for a developer, including make, make install, the xulrunner client built and autogen. Considerations: * Run as user "opensrf" * opensrf needs sudo (again, targeting developers, not production) for apache stop/start, chown and make install * Assumes opensrf has two SVN (or git-svn) repos: OpenILS and OpenSRF * Both repos should be already configured (as in ./configure) Detailed usage notes available via -h option. Both repo directories and the install directory can be specified on the command line. Try it with -t (test mode) to see feedback without making any changes. === TODO. Add option to use brick_ctl.sh instead of osrf_ctl.sh for service start/stop git-svn-id: svn://svn.open-ils.org/ILS/trunk@15015 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- build/tools/update.sh | 169 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100755 build/tools/update.sh diff --git a/build/tools/update.sh b/build/tools/update.sh new file mode 100755 index 0000000000..55b28a1636 --- /dev/null +++ b/build/tools/update.sh @@ -0,0 +1,169 @@ +#!/bin/bash +# +# Author: Joe Atzberger, Equinox Software, Inc. +# License: GPL v2 or greater. +# +# Based on initial version by Bill Erickson. + +function svn_or_git { + echo -en "###########\nUpdating source directory: "; + pwd; + if [ -d "./.git" ]; then + git svn fetch; + git svn rebase origin; + else + svn update; + fi +} + +function feedback { +cat <&2; + usage; + exit 1; +} + +# ---------------------------------- +# Prespond to command-line options +# ---------------------------------- +while getopts "cfhtvb:e:i:s:" flag; do + case $flag in + "b") OPT_BASEDIR="$OPTARG";; # HIDDEN (undocumented) option. + "e") OPT_EGDIR="$OPTARG" ;; + "i") OPT_INSTALL="$OPTARG";; + "s") OPT_OSRFDIR="$OPTARG";; + "c") OPT_CLEAN=1 ;; + "f") OPT_FULL=1 ;; + "t") OPT_TEST=1 ;; + "v") OPT_VERBOSE=1;; + "h"|*) usage && exit;; + esac; +done + +# ---------------------------------- +# DEFAULTS (w/ optional overrides) +# ---------------------------------- +INSTALL=${OPT_INSTALL:-/openils}; +BASE=~ # default to $HOME (~ doesn't like :- syntax for whatever reason) +[ -z "$OPT_BASEDIR" ] || BASE="$OPT_BASEDIR"; + +OSRF=${OPT_OSRFDIR:-$BASE/OpenSRF/trunk}; +ILS=${OPT_EGDIR:-$BASE/ILS/trunk}; +XUL="$INSTALL/var/web/xul"; + +# ---------------------------------- +# TEST and SANITY CHECK +# ---------------------------------- +[ ! -d "$ILS" ] && die_msg "Evergreen Source Directory '$ILS' does not exist!"; +[ ! -d "$INSTALL" ] && die_msg "Evergreen Install Directory '$INSTALL' does not exist!"; +[ ! -d "$XUL" ] && die_msg "Evergreen XUL Client Directory '$XUL' does not exist!"; +[ ! -d "$OSRF" ] && die_msg "OpenSRF Source Directory '$OSRF' does not exist!"; +which sudo >/dev/null || die_msg "sudo not installed (or in PATH)"; + +if [ ! -z "$OPT_TEST" ] ; then + feedback; + exit; +fi + +# ---------------------------------- +# MAIN +# ---------------------------------- +if [ -z "$OPT_VERBOSE" ] ; then + echo "Running with some make output suppressed. To see all output, run $0 with -v (verbose)"; + echo "This may take a few minutes... "; + exec 3>&1 # Save current STDOUT to FD3 + exec 1>/dev/null # redirect (not close) STDOUT +else + feedback; + echo -e "Password prompts are triggered by sudo (as this user)\nStopping Apache."; + set -x; # echo commands to screen +fi + +sudo /etc/init.d/apache2 stop; +$INSTALL/bin/osrf_ctl.sh -l -a stop_all; + +# OpenSRF perl directory is not shared. update the drone +# ssh 10.5.0.202 "./update_osrf_perl.sh"; + +cd $OSRF; svn_or_git; +cd $ILS; svn_or_git; + +if [ -n "$OPT_CLEAN" ]; then + cd $OSRF && make clean; + cd $ILS && make clean; +fi + +if [ -z "$OPT_FULL" ]; then + cd $OSRF && make; + cd $ILS && make; + cd $OSRF && sudo make install; +fi +sudo chown -R opensrf:opensrf $INSTALL + +BID=$(date +"%Y-%m-%dT%H:%M:%S"); # or "current" +cd $ILS && sudo make install STAFF_CLIENT_BUILD_ID=$BID; +sudo chown -R opensrf:opensrf $INSTALL + +if [ -z "$OPT_VERBOSE" ] ; then + exec 1>&3 # Restore STDOUT +fi + +cd $XUL || die_msg "Could not cd to $XUL"; +pwd; +rm -f ./current-client-build.zip; +cp -r "$ILS/Open-ILS/xul/staff_client/build" ./ +zip -rq current-client-build.zip build; +rm -rf ./build; +rm -f current; # removing the link to the old build +ln -s $BID current; # linking "current" to the new build +ln -s current/server server; + +sudo chown -R opensrf:opensrf $OSRF $ILS +$INSTALL/bin/osrf_ctl.sh -l -a start_all +sleep 2; +cd $INSTALL/bin; ./autogen.sh ../conf/opensrf_core.xml; +sudo /etc/init.d/apache2 start; + -- 2.43.2