Check that deployed EG code matches the code in git.
[sitka/sitka-tools.git] / deployment / install-eg.sh
index 5f9433b..e26ba09 100755 (executable)
@@ -1,19 +1,20 @@
 #!/bin/bash
 # IMPORTANT! This script assumes you have already installed OpenSRF.
 
-HOSTNAME="nonprod"
+HOSTNAME="nonprod-24"
 DEFAULT_USER="sitkastaff"
 HOMEDIR="/home/${DEFAULT_USER}"
 BUILDDIR="${HOMEDIR}/evergreen"
 INSTALLDIR="/srv/openils"
-BRANCH="production/sitka_2_2"
-VERSION="2.2.5.sitka.0"
-STAMP_ID="2_2_5_sitka_0"
-ALT_STAMP_IDS="rel_2_2_5_sitka_0 2_2_5_sitka_0 rel_2_2_5_sitka_0"
+BRANCH="production/sitka_2_4"
+VERSION="2.4.0.sitka.0"
+STAMP_ID="2_4_0_sitka_0"
+ALT_STAMP_IDS="rel_2_4_0_sitka_0 rel_2_4_0_sitka_0"
 SITKACONF="${HOMEDIR}/sysadmin"
-DEPLOYDIR="/home/opensrf/deploy"
-OPACSKIN="${DEPLOYDIR}/opacskin"
-OILSPOLICY="${DEPLOYDIR}/oilspolicy"
+
+suwrap() {
+  su -s /bin/bash -l -c "source ~/.bashrc ; $1" $2
+}
 
 # as DEFAULT_USER
 
@@ -21,33 +22,33 @@ OILSPOLICY="${DEPLOYDIR}/oilspolicy"
 if [ ! -d "${SITKACONF}" ]
 then
   # this will fail unless DEFAULT_USER has read access to the repo
-  su -l -c "cd ${HOMEDIR} && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" ${DEFAULT_USER}
+  suwrap "cd ${HOMEDIR} && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" ${DEFAULT_USER}
 fi
-su -l -c "cd ${SITKACONF} && git pull" ${DEFAULT_USER}
+suwrap "cd ${SITKACONF} && git pull" ${DEFAULT_USER}
 
 # checkout EG source
 if [ ! -d "${BUILDDIR}" ]
 then
-  su -l -c "cd ${HOMEDIR} && git clone git://git.sitka.bclibraries.ca/sitka/evergreen evergreen" ${DEFAULT_USER}
+  suwrap "cd ${HOMEDIR} && git clone git://git.sitka.bclibraries.ca/sitka/evergreen evergreen" ${DEFAULT_USER}
 fi
-su -l -c "cd ${BUILDDIR} && git checkout ${BRANCH}" ${DEFAULT_USER}
+suwrap "cd ${BUILDDIR} && git checkout ${BRANCH}" ${DEFAULT_USER}
  
 # as root
 cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-precise
 # by default, CPAN needs some manual input at this point; you can just accept all defaults
  
 # as DEFAULT_USER
-su -l -c "cd ${BUILDDIR} && autoreconf -i" ${DEFAULT_USER}
-su -l -c "cd ${BUILDDIR} && ./configure -C --prefix='${INSTALLDIR}' --sysconfdir='\${prefix}/conf' --with-opensrf-headers=${INSTALLDIR}/include/ --with-opensrf-libs=${INSTALLDIR}/lib/ --with-dbi=/usr/lib/dbd/" ${DEFAULT_USER}
-su -l -c "cd ${BUILDDIR} && make" ${DEFAULT_USER}
-su -l -c "cd ${BUILDDIR}/build/i18n && make install_all_locales" ${DEFAULT_USER}
+suwrap "cd ${BUILDDIR} && autoreconf -i" ${DEFAULT_USER}
+suwrap "cd ${BUILDDIR} && ./configure -C --prefix=${INSTALLDIR} --sysconfdir=${INSTALLDIR}/conf --with-opensrf-headers=${INSTALLDIR}/include/ --with-opensrf-libs=${INSTALLDIR}/lib/ --with-dbi=/usr/lib/dbd/" ${DEFAULT_USER}
+suwrap "cd ${BUILDDIR} && make" ${DEFAULT_USER}
+suwrap "cd ${BUILDDIR}/build/i18n && make LOCALE=fr-CA install && make LOCALE=en-CA install" ${DEFAULT_USER}
  
 # as root
 cd ${BUILDDIR} && make STAFF_CLIENT_STAMP_ID=${STAMP_ID} STAFF_CLIENT_VERSION=${VERSION} install
 chown -R opensrf:opensrf ${INSTALLDIR}
  
 # Apache stuff (as root):
-APACHEFILES="/etc/apache2/eg_vhost.conf /etc/apache2/startup.pl /etc/apache2/sites-available/eg.conf /etc/apache2/envvars"
+APACHEFILES="/etc/apache2/eg_vhost.conf /etc/apache2/eg_startup /etc/apache2/sites-available/eg.conf"
 for APACHEFILE in ${APACHEFILES}
 do
   cp ${SITKACONF}/files/${APACHEFILE}/${HOSTNAME} ${APACHEFILE}
@@ -56,19 +57,28 @@ a2dissite default
 a2ensite eg.conf
 mkdir /etc/apache2/ssl
 cd /etc/apache2/ssl && openssl req -new -x509 -days 365 -nodes -out server.crt -keyout server.key
-# TODO: set up log rotation
-# as opensrf
+
+# set up log rotation
+if [ ! -d "/etc/logrotate.d/evergreen" ]
+then
+  cp ${SITKACONF}/files/etc/logrotate.d/evergreen/${HOSTNAME} /etc/logrotate.d/evergreen
+fi
  
 # 0. osrf conf stuff 
 # FIXME: ensure osrf conf files point at a real, distinct db!
 OSRFCONFFILES="${INSTALLDIR}/conf/opensrf.xml ${INSTALLDIR}/conf/opensrf_core.xml"
 for OSRFCONFFILE in ${OSRFCONFFILES}
 do
+  rm ${OSRFCONFFILE}
   cp ${SITKACONF}/files/${OSRFCONFFILE}/${HOSTNAME} ${OSRFCONFFILE}
 done
-cp ${SITKACONF}/files/home/opensrf/.srfsh.xml/${HOSTNAME} ${HOMEDIR}/.srfsh.xml
+if [ ! -d "${HOMEDIR}/.srfsh.xml" ]
+then
+  cp ${SITKACONF}/files/home/opensrf/.srfsh.xml/${HOSTNAME} ${HOMEDIR}/.srfsh.xml
+fi 
+
+# setup offline circ
+cd ${BUILDDIR} && perl Open-ILS/src/support-scripts/eg_db_config --create-offline
  
 # 1. install dojo
 cd /home/opensrf && wget http://download.dojotoolkit.org/release-1.3.3/dojo-release-1.3.3.tar.gz
@@ -76,36 +86,14 @@ tar -C ${INSTALLDIR}/var/web/js -xzf /home/opensrf/dojo-release-1.3.3.tar.gz
 cp -r ${INSTALLDIR}/var/web/js/dojo-release-1.3.3/* ${INSTALLDIR}/var/web/js/dojo/.
  
 # 2. set up staff client
+cd ${INSTALLDIR}/var/web/xul && rm server && rm current
 cd ${INSTALLDIR}/var/web/xul && ln -s ${STAMP_ID} current && ln -s current/server server
 for ALT_STAMP_ID in ${ALT_STAMP_IDS}
 do
   cd ${INSTALLDIR}/var/web/xul && ln -s current ${ALT_STAMP_ID}
 done
  
-# 3. install circ scripts and opac skins
-
-# (a) setup deploy directory
-if [ ! -d "${DEPLOYDIR}" ]
-then
-  mkdir ${DEPLOYDIR}
-fi
-
-# (b) bclibraries skin
-if [ ! -d "${OPACSKIN}" ]
-then
-  cd ${DEPLOYDIR} && git clone git://git.sitka.bclibraries.ca/sitka/opacskin.git
-fi
-cd ${OPACSKIN} && git checkout -b bclibraries && \
-  cd ${INSTALLDIR}/var/web/opac/skin && mv default orig-default && \
-  rsync -a --exclude=.git ${OPACSKIN} ${INSTALLDIR}/var/web/opac/skin/bclibraries && \
-  ln -s ${INSTALLDIR}/var/web/opac/skin/bclibraries ${INSTALLDIR}/var/web/opac/skin/default
-
-# (b) circ scripts
-if [ ! -d "${OILSPOLICY}" ]
-then
-  cd ${DEPLOYDIR} && git clone git://git.sitka.bclibraries.ca/sitka/oilspolicy.git
-fi
-cd ${OILSPOLICY} && git pull && rsync -a --exclude=.git ${OILSPOLICY} ${INSTALLDIR}/var
+# 3. install circ scripts and opac skins - DEPRECATED
  
 # 4. avoid 404s
 touch ${INSTALLDIR}/var/web/css/skin/default/register_custom.css
@@ -129,7 +117,7 @@ cd ${INSTALLDIR}/var/web/opac/locale && cp -fdr en-US en-US-bak && cp -fdr en-CA
 # 6. deletepatron
 # ensure apache conf contains deletepatron config (location should be ${INSTALLDIR}/var/web/deletepatron)
 cd ${INSTALLDIR}/var/web && git clone https://github.com/twirlip/deletepatron.git
-cd ${INSTALLDIR}/var/web/deletepatron && git checkout eg22 && find . -name *.pm | xargs sed -i -e 's|/openils|/srv/openils|g'
+cd ${INSTALLDIR}/var/web/deletepatron && git checkout eg22 && find . -name "*.pm" | xargs sed -i -e 's|/openils|/srv/openils|g'
 apt-get install libcgi-session-perl libhtml-template-perl
 
 # 7. support scripts
@@ -152,4 +140,11 @@ done
 
 # 9. make sure opensrf owns all the stuff we just did
 chown -R opensrf:opensrf ${INSTALLDIR}
+chown -R opensrf:opensrf /home/opensrf
+chown -R opensrf:opensrf /var/lock/apache2
+
+# 10. staff client stuff
+apt-get install nsis unzip
 
+# 11. integrity checker prereqs
+apt-get install libconfig-simple-perl libgit-repository-perl libdate-manip-perl