3 # Author: Joe Atzberger, Equinox Software, Inc.
4 # License: GPL v2 or greater.
6 # Based on initial version by Bill Erickson.
8 function fetch_changes {
9 echo -en "###########\nUpdating source directory:" `pwd` "\n";
10 if [ -d "./.git" ]; then
12 # git rebase origin || die_msg "git rebase origin failed";
14 echo "You don't appear to be using Git yet, please fix that"
22 CLEAN = ${OPT_CLEAN:-no}
23 FULL = ${OPT_FULL:-no}
24 VERBOSE = ${OPT_VERBOSE:-no}
27 OpenSRF repo : ${OSRF:-Missing}
28 OpenILS repo : ${ILS:-Missing}
29 OpenILS install: ${INSTALL:-Missing}
30 XUL install: ${XUL:-Missing}
37 usage: $0 [-e /eg_trunk] [-i /openils_dir] [-s /srf_trunk] [-[cfbvt]]
40 -e specify Evergreen (OpenILS) source repository (default pwd)
41 -i specify Evergreen installed directory (default /openils)
42 -s specify OpenSRF source repository (default ~/OpenSRF/trunk)
44 All parameters are optional, but you will probably need to use -e and -i.
47 -c clean: run make clean before make
48 -f full: make both packages, do OpenSRF make install (usually not required)
49 -t test: gives feedback but does not run anything
52 The purpose of this script is to consolidate a lot of the annoying
53 and error-prone tasks associated with an upgrade for a developer.
58 * Assumes opensrf has OpenILS and OpenSRF repositories as Git
59 checkouts and both have been configured (as in ./configure)
65 echo -e "ERROR: ${1:-Unknown}\n" >&2;
70 # ----------------------------------
71 # Prespond to command-line options
72 # ----------------------------------
73 while getopts "cfhtvb:e:i:s:" flag; do
75 "b") OPT_BASEDIR="$OPTARG";; # HIDDEN (undocumented) option.
76 "e") OPT_EGDIR="$OPTARG" ;;
77 "i") OPT_INSTALL="$OPTARG";;
78 "s") OPT_OSRFDIR="$OPTARG";;
83 "h"|*) usage && exit;;
87 # ----------------------------------
88 # DEFAULTS (w/ optional overrides)
89 # ----------------------------------
90 INSTALL=${OPT_INSTALL:-/openils};
91 BASE=~ # default to $HOME (~ doesn't like :- syntax for whatever reason)
92 [ -z "$OPT_BASEDIR" ] || BASE="$OPT_BASEDIR";
94 OSRF=${OPT_OSRFDIR:-$BASE/OpenSRF/trunk};
95 ILS=${OPT_EGDIR:-$(pwd)};
96 XUL="$INSTALL/var/web/xul";
97 JSDIR="$INSTALL/lib/javascript"; # only used for FULL install
99 # ----------------------------------
100 # TEST and SANITY CHECK
101 # ----------------------------------
102 [ ! -d "$ILS" ] && die_msg "Evergreen Source Directory '$ILS' does not exist!";
103 [ ! -d "$INSTALL" ] && die_msg "Evergreen Install Directory '$INSTALL' does not exist!";
104 [ ! -d "$XUL" ] && die_msg "Evergreen XUL Client Directory '$XUL' does not exist!";
105 [ ! -d "$OSRF" ] && die_msg "OpenSRF Source Directory '$OSRF' does not exist!";
106 which sudo >/dev/null || die_msg "sudo not installed (or in PATH)";
108 [ -d "${ILS}/.git" ] || [ -d ${ILS}/.bzr ] || die_msg "Evergreen Source Directory '$ILS' is not a SVN, bzr or git repo";
110 if [ ! -z "$OPT_TEST" ] ; then
115 # ----------------------------------
117 # ----------------------------------
118 if [ -n "$OPT_FULL" ]; then
119 echo; echo; echo '*** Performing FULL installation ***' ; echo; echo;
121 if [ -z "$OPT_VERBOSE" ] ; then
122 echo "Running with some make output suppressed. To see all output, run $0 with -v (verbose)";
123 echo "This may take a few minutes... ";
124 exec 3>&1 # Save current STDOUT to FD3
125 exec 1>/dev/null # redirect (not close) STDOUT
128 echo -e "Password prompts are triggered by sudo (as this user)\nStopping Apache.";
129 set -x; # echo commands to screen
132 sudo /etc/init.d/apache2 stop;
133 $INSTALL/bin/osrf_control --localhost --stop-all;
135 # OpenSRF perl directory is not shared. update the drone
136 # ssh 10.5.0.202 "./update_osrf_perl.sh";
138 cd $OSRF; fetch_changes;
139 cd $ILS; fetch_changes;
141 if [ -n "$OPT_CLEAN" ]; then
142 cd $OSRF && make clean;
143 cd $ILS && make clean;
146 if [ -n "$OPT_FULL" ]; then
149 cd $OSRF && sudo make install;
150 if [ -d "$JSDIR" ]; then
151 echo "Copying OpenSRF javascript files into $JSDIR";
152 cp ./src/javascript/* $JSDIR;
155 sudo chown -R opensrf:opensrf $INSTALL
157 BIDDATE=$(date +"%Y-%m-%dT%H:%M:%S");
158 BID=${STAFF_CLIENT_BUILD_ID:-$BIDDATE}; # or "current"
160 rm -f "$XUL/current" || rm -rf "$XUL/current"; # removing the old link/build
161 cd $ILS && sudo make install STAFF_CLIENT_STAMP_ID=$BID STAFF_CLIENT_BUILD_ID=$BID;
162 sudo chown -R opensrf:opensrf $INSTALL
164 [ -d "$XUL/$BID" ] || die_msg "New build directory $XUL/$BID was not created. sudo make install failed?";
166 if [ -z "$OPT_VERBOSE" ] ; then
167 exec 1>&3 # Restore STDOUT
170 cd $XUL || die_msg "Could not cd to $XUL";
172 rm -f $XUL/current-client-build.zip;
173 cp -r "$ILS/Open-ILS/xul/staff_client/build" ./
174 zip -rq current-client-build.zip build;
175 echo -n "BUILD_ID: ";
176 cat ./build/BUILD_ID;
177 echo -n "STAMP_ID: ";
178 cat ./build/STAMP_ID;
179 echo -n " VERSION: ";
183 echo "build ID is '$BID'";
185 if [ "$BID" != "$BIDDDATE" ] ; then
186 mv $BID $BIDDATE; # Move the non-timestamp directory to timestamp-based spot
187 ln -s $BIDDATE $BID; # link back to it
190 rm -f current; # removing the link to the old build
191 ln -s $BIDDATE current; # linking "current" to the new build
194 ln -s current/server server;
197 sudo chown -R opensrf:opensrf $OSRF $ILS
198 $INSTALL/bin/osrf_control --localhost --start-all
200 cd $INSTALL/bin; ./autogen.sh ../conf/opensrf_core.xml;
201 sudo /etc/init.d/apache2 start;
203 echo $'done\a' # \a = Bell character for beep