3 # Author: Joe Atzberger, Equinox Software, Inc.
4 # License: GPL v2 or greater.
6 # Based on initial version by Bill Erickson.
9 echo -en "###########\nUpdating source directory:" `pwd` "\n";
10 if [ -d "./.git" ]; then
11 if [ -d "./.git/svn/trunk" ]; then
13 # git svn rebase origin || die_msg "git svn rebase origin failed";
16 # git rebase origin || die_msg "git rebase origin failed";
19 echo "Remember to run svn update as needed";
20 # svn update || die_msg "svn update failed";
27 CLEAN = ${OPT_CLEAN:-no}
28 FULL = ${OPT_FULL:-no}
29 VERBOSE = ${OPT_VERBOSE:-no}
32 OpenSRF repo : ${OSRF:-Missing}
33 OpenILS repo : ${ILS:-Missing}
34 OpenILS install: ${INSTALL:-Missing}
35 XUL install: ${XUL:-Missing}
42 usage: $0 [-e /eg_trunk] [-i /openils_dir] [-s /srf_trunk] [-[cfbvt]]
45 -e specify Evergreen (OpenILS) source repository (default pwd)
46 -i specify Evergreen installed directory (default /openils)
47 -s specify OpenSRF source repository (default ~/OpenSRF/trunk)
49 All parameters are optional, but you will probably need to use -e and -i.
52 -c clean: run make clean before make
53 -f full: make both packages, do OpenSRF make install (usually not required)
54 -t test: gives feedback but does not run anything
57 The purpose of this script is to consolidate a lot of the annoying
58 and error-prone tasks associated with an upgrade for a developer.
63 * Assumes opensrf has OpenILS and OpenSRF repositories as svn or git-svn
64 checkouts and both have been configured (as in ./configure)
70 echo -e "ERROR: ${1:-Unknown}\n" >&2;
75 # ----------------------------------
76 # Prespond to command-line options
77 # ----------------------------------
78 while getopts "cfhtvb:e:i:s:" flag; do
80 "b") OPT_BASEDIR="$OPTARG";; # HIDDEN (undocumented) option.
81 "e") OPT_EGDIR="$OPTARG" ;;
82 "i") OPT_INSTALL="$OPTARG";;
83 "s") OPT_OSRFDIR="$OPTARG";;
88 "h"|*) usage && exit;;
92 # ----------------------------------
93 # DEFAULTS (w/ optional overrides)
94 # ----------------------------------
95 INSTALL=${OPT_INSTALL:-/openils};
96 BASE=~ # default to $HOME (~ doesn't like :- syntax for whatever reason)
97 [ -z "$OPT_BASEDIR" ] || BASE="$OPT_BASEDIR";
99 OSRF=${OPT_OSRFDIR:-$BASE/OpenSRF/trunk};
100 ILS=${OPT_EGDIR:-$(pwd)};
101 XUL="$INSTALL/var/web/xul";
102 JSDIR="$INSTALL/lib/javascript"; # only used for FULL install
104 # ----------------------------------
105 # TEST and SANITY CHECK
106 # ----------------------------------
107 [ ! -d "$ILS" ] && die_msg "Evergreen Source Directory '$ILS' does not exist!";
108 [ ! -d "$INSTALL" ] && die_msg "Evergreen Install Directory '$INSTALL' does not exist!";
109 [ ! -d "$XUL" ] && die_msg "Evergreen XUL Client Directory '$XUL' does not exist!";
110 [ ! -d "$OSRF" ] && die_msg "OpenSRF Source Directory '$OSRF' does not exist!";
111 which sudo >/dev/null || die_msg "sudo not installed (or in PATH)";
113 [ -d "${ILS}/.svn" ] || [ -d "${ILS}/.git" ] || [ -d ${ILS}/.bzr ] || die_msg "Evergreen Source Directory '$ILS' is not a SVN, bzr or git repo";
115 if [ ! -z "$OPT_TEST" ] ; then
120 # ----------------------------------
122 # ----------------------------------
123 if [ -n "$OPT_FULL" ]; then
124 echo; echo; echo '*** Performing FULL installation ***' ; echo; echo;
126 if [ -z "$OPT_VERBOSE" ] ; then
127 echo "Running with some make output suppressed. To see all output, run $0 with -v (verbose)";
128 echo "This may take a few minutes... ";
129 exec 3>&1 # Save current STDOUT to FD3
130 exec 1>/dev/null # redirect (not close) STDOUT
133 echo -e "Password prompts are triggered by sudo (as this user)\nStopping Apache.";
134 set -x; # echo commands to screen
137 sudo /etc/init.d/apache2 stop;
138 $INSTALL/bin/osrf_ctl.sh -l -a stop_all;
140 # OpenSRF perl directory is not shared. update the drone
141 # ssh 10.5.0.202 "./update_osrf_perl.sh";
143 cd $OSRF; svn_or_git;
146 if [ -n "$OPT_CLEAN" ]; then
147 cd $OSRF && make clean;
148 cd $ILS && make clean;
151 if [ -n "$OPT_FULL" ]; then
154 cd $OSRF && sudo make install;
155 if [ -d "$JSDIR" ]; then
156 echo "Copying OpenSRF javascript files into $JSDIR";
157 cp ./src/javascript/* $JSDIR;
160 sudo chown -R opensrf:opensrf $INSTALL
162 BIDDATE=$(date +"%Y-%m-%dT%H:%M:%S");
163 BID=${STAFF_CLIENT_BUILD_ID:-$BIDDATE}; # or "current"
165 rm -f "$XUL/current" || rm -rf "$XUL/current"; # removing the old link/build
166 cd $ILS && sudo make install STAFF_CLIENT_STAMP_ID=$BID STAFF_CLIENT_BUILD_ID=$BID;
167 sudo chown -R opensrf:opensrf $INSTALL
169 [ -d "$XUL/$BID" ] || die_msg "New build directory $XUL/$BID was not created. sudo make install failed?";
171 if [ -z "$OPT_VERBOSE" ] ; then
172 exec 1>&3 # Restore STDOUT
175 cd $XUL || die_msg "Could not cd to $XUL";
177 rm -f $XUL/current-client-build.zip;
178 cp -r "$ILS/Open-ILS/xul/staff_client/build" ./
179 zip -rq current-client-build.zip build;
180 echo -n "BUILD_ID: ";
181 cat ./build/BUILD_ID;
182 echo -n "STAMP_ID: ";
183 cat ./build/STAMP_ID;
184 echo -n " VERSION: ";
188 echo "build ID is '$BID'";
190 if [ "$BID" != "$BIDDDATE" ] ; then
191 mv $BID $BIDDATE; # Move the non-timestamp directory to timestamp-based spot
192 ln -s $BIDDATE $BID; # link back to it
195 rm -f current; # removing the link to the old build
196 ln -s $BIDDATE current; # linking "current" to the new build
199 ln -s current/server server;
202 sudo chown -R opensrf:opensrf $OSRF $ILS
203 $INSTALL/bin/osrf_ctl.sh -l -a start_all
205 cd $INSTALL/bin; ./autogen.sh ../conf/opensrf_core.xml;
206 sudo /etc/init.d/apache2 start;
208 echo $'done\a' # \a = Bell character for beep