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 a configured (as in ./configure) both ILS and
64 OpenSRF as svn or git-svn checkouts
69 echo -e "ERROR: ${1:-Unknown}\n" >&2;
74 # ----------------------------------
75 # Prespond to command-line options
76 # ----------------------------------
77 while getopts "cfhtvb:e:i:s:" flag; do
79 "b") OPT_BASEDIR="$OPTARG";; # HIDDEN (undocumented) option.
80 "e") OPT_EGDIR="$OPTARG" ;;
81 "i") OPT_INSTALL="$OPTARG";;
82 "s") OPT_OSRFDIR="$OPTARG";;
87 "h"|*) usage && exit;;
91 # ----------------------------------
92 # DEFAULTS (w/ optional overrides)
93 # ----------------------------------
94 INSTALL=${OPT_INSTALL:-/openils};
95 BASE=~ # default to $HOME (~ doesn't like :- syntax for whatever reason)
96 [ -z "$OPT_BASEDIR" ] || BASE="$OPT_BASEDIR";
98 OSRF=${OPT_OSRFDIR:-$BASE/OpenSRF/trunk};
99 ILS=${OPT_EGDIR:-$(pwd)};
100 XUL="$INSTALL/var/web/xul";
102 # ----------------------------------
103 # TEST and SANITY CHECK
104 # ----------------------------------
105 [ ! -d "$ILS" ] && die_msg "Evergreen Source Directory '$ILS' does not exist!";
106 [ ! -d "$INSTALL" ] && die_msg "Evergreen Install Directory '$INSTALL' does not exist!";
107 [ ! -d "$XUL" ] && die_msg "Evergreen XUL Client Directory '$XUL' does not exist!";
108 [ ! -d "$OSRF" ] && die_msg "OpenSRF Source Directory '$OSRF' does not exist!";
109 which sudo >/dev/null || die_msg "sudo not installed (or in PATH)";
111 [ -d "${ILS}/.svn" ] || [ -d "${ILS}/.git" ] || [ -d ${ILS}/.bzr ] || die_msg "Evergreen Source Directory '$ILS' is not a SVN, bzr or git repo";
113 if [ ! -z "$OPT_TEST" ] ; then
118 # ----------------------------------
120 # ----------------------------------
121 if [ -n "$OPT_FULL" ]; then
122 echo; echo; echo '*** Performing FULL installation ***' ; echo; echo;
124 if [ -z "$OPT_VERBOSE" ] ; then
125 echo "Running with some make output suppressed. To see all output, run $0 with -v (verbose)";
126 echo "This may take a few minutes... ";
127 exec 3>&1 # Save current STDOUT to FD3
128 exec 1>/dev/null # redirect (not close) STDOUT
131 echo -e "Password prompts are triggered by sudo (as this user)\nStopping Apache.";
132 set -x; # echo commands to screen
135 sudo /etc/init.d/apache2 stop;
136 $INSTALL/bin/osrf_ctl.sh -l -a stop_all;
138 # OpenSRF perl directory is not shared. update the drone
139 # ssh 10.5.0.202 "./update_osrf_perl.sh";
141 cd $OSRF; svn_or_git;
144 if [ -n "$OPT_CLEAN" ]; then
145 cd $OSRF && make clean;
146 cd $ILS && make clean;
149 if [ -n "$OPT_FULL" ]; then
152 cd $OSRF && sudo make install;
154 sudo chown -R opensrf:opensrf $INSTALL
156 BID=$(date +"%Y-%m-%dT%H:%M:%S"); # or "current"
157 cd $ILS && sudo make install STAFF_CLIENT_BUILD_ID=$BID;
158 sudo chown -R opensrf:opensrf $INSTALL
160 [ -d "$XUL/$BID" ] || die_msg "New build directory $XUL/$BID was not created. sudo make install failed?"
162 if [ -z "$OPT_VERBOSE" ] ; then
163 exec 1>&3 # Restore STDOUT
166 cd $XUL || die_msg "Could not cd to $XUL";
168 rm -f $XUL/current-client-build.zip;
169 cp -r "$ILS/Open-ILS/xul/staff_client/build" ./
170 zip -rq current-client-build.zip build;
175 rm -f current; # removing the link to the old build
176 ln -s $BID current; # linking "current" to the new build
177 ln -s current/server server;
180 sudo chown -R opensrf:opensrf $OSRF $ILS
181 $INSTALL/bin/osrf_ctl.sh -l -a start_all
183 cd $INSTALL/bin; ./autogen.sh ../conf/opensrf_core.xml;
184 sudo /etc/init.d/apache2 start;
186 echo $'done\a' # \a = Bell character for beep