EG install scripts: specify git branch for sysadmin.git
[sitka/sitka-tools.git] / deployment / install-eg.sh
index e6cb38d..152df94 100755 (executable)
@@ -1,20 +1,20 @@
 #!/bin/bash
 # IMPORTANT! This script assumes you have already installed OpenSRF.
 
-HOSTNAME="nonprod-24"
+HOSTNAME="nonprod-28"
 DEFAULT_USER="sitkastaff"
 HOMEDIR="/home/${DEFAULT_USER}"
+#EGRELEASE="Evergreen-ILS-2.8.beta"
+#BUILDDIR="${HOMEDIR}/${EGRELEASE}"
 BUILDDIR="${HOMEDIR}/evergreen"
 INSTALLDIR="/srv/openils"
-BRANCH="user/jeffdavis/sitka-24-beta1"
-VERSION="2.4.0.sitka.0"
-STAMP_ID="2_4_0_sitka_0"
-ALT_STAMP_IDS="rel_2_4_0_sitka_0 2_4_0_sitka_0 rel_2_4_0_sitka_0"
+BRANCH="upgrade/eg28/phase3-tpac"
+STAMP_ID="rel_2_8_1"
+ALT_STAMP_IDS="2_8_1 rel_2_8_beta 2_8_beta rel_2_8_0 2_8_0"
+VERSION="2.8.1.sitka.0"
 SITKACONF="${HOMEDIR}/sysadmin"
-DEPLOYDIR="/home/opensrf/deploy"
-OPACSKIN="${DEPLOYDIR}/opacskin"
-OILSPOLICY="${DEPLOYDIR}/oilspolicy"
-TPACS="${DEPLOYDIR}/deploykit"
+SITKACONF_BRANCH="eg28"
+SITKATOOLS="/root/sitka-tools"
 
 suwrap() {
   su -s /bin/bash -l -c "source ~/.bashrc ; $1" $2
@@ -28,113 +28,90 @@ then
   # this will fail unless DEFAULT_USER has read access to the repo
   suwrap "cd ${HOMEDIR} && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" ${DEFAULT_USER}
 fi
-suwrap "cd ${SITKACONF} && git pull" ${DEFAULT_USER}
+suwrap "cd ${SITKACONF} && git fetch origin && git checkout ${SITKACONF_BRANCH} && git pull" ${DEFAULT_USER}
 
 # checkout EG source
 if [ ! -d "${BUILDDIR}" ]
 then
   suwrap "cd ${HOMEDIR} && git clone git://git.sitka.bclibraries.ca/sitka/evergreen evergreen" ${DEFAULT_USER}
 fi
-suwrap "cd ${BUILDDIR} && git checkout ${BRANCH}" ${DEFAULT_USER}
+suwrap "cd ${BUILDDIR} && git fetch origin && git checkout ${BRANCH} && git pull" ${DEFAULT_USER}
+
+# download and unpack EG release
+#rm -rf ${BUILDDIR}
+#suwrap "cd ${HOMEDIR} && wget http://open-ils.org/downloads/${EGRELEASE}.tar.gz && tar xzf ${EGRELEASE}.tar.gz" ${DEFAULT_USER}
  
 # as root
-cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-precise
+cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-trusty
+#cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-trusty-developer # required for web client
 # by default, CPAN needs some manual input at this point; you can just accept all defaults
  
 # as 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} && autoreconf -i" ${DEFAULT_USER} # not required for release versions
+suwrap "cd ${BUILDDIR} && ./configure -C --prefix=${INSTALLDIR} --sysconfdir=${INSTALLDIR}/conf --with-opensrf-headers=${INSTALLDIR}/include/ --with-opensrf-libs=${INSTALLDIR}/lib/" ${DEFAULT_USER}
 suwrap "cd ${BUILDDIR} && make" ${DEFAULT_USER}
-suwrap "cd ${BUILDDIR}/build/i18n && make install_all_locales" ${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
+cd ${BUILDDIR} && make STAFF_CLIENT_VERSION=${VERSION} STAFF_CLIENT_STAMP_ID=${STAMP_ID} install
+mv ${INSTALLDIR}/var/web/reports/fm_IDL.xml ${INSTALLDIR}/var/web/reports/fm_IDL.xml.orig && cp ${INSTALLDIR}/conf/fm_IDL.xml ${INSTALLDIR}/var/web/reports/
 chown -R opensrf:opensrf ${INSTALLDIR}
  
 # Apache stuff (as root):
 APACHEFILES="/etc/apache2/eg_vhost.conf /etc/apache2/eg_startup /etc/apache2/sites-available/eg.conf"
 for APACHEFILE in ${APACHEFILES}
 do
+  mv ${APACHEFILE} ${APACHEFILE}.bak
   cp ${SITKACONF}/files/${APACHEFILE}/${HOSTNAME} ${APACHEFILE}
 done
-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
+#a2dissite 000-default
+#a2ensite eg.conf
+#if [ ! -d "/etc/apache2/ssl" ]
+#then
+#  mkdir /etc/apache2/ssl
+#  cd /etc/apache2/ssl && openssl req -new -x509 -days 365 -nodes -out server.crt -keyout server.key
+#fi
+# ensure opensrf can run Apache
+chown -R opensrf:opensrf /var/lock/apache2
 
-# setup offline circ
-cd ${BUILDDIR} && perl Open-ILS/src/support-scripts/eg_db_config --create-offline
-# TODO: set up log rotation
+# set up log rotation
+if [ ! -f "/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}
+  mv ${OSRFCONFFILE} ${OSRFCONFFILE}.bak
   cp ${SITKACONF}/files/${OSRFCONFFILE}/${HOSTNAME} ${OSRFCONFFILE}
 done
-cp ${SITKACONF}/files/home/opensrf/.srfsh.xml/${HOSTNAME} ${HOMEDIR}/.srfsh.xml
+if [ ! -f "${HOMEDIR}/.srfsh.xml" ]
+then
+  cp ${SITKACONF}/files/home/opensrf/.srfsh.xml/${HOSTNAME} ${HOMEDIR}/.srfsh.xml
+fi 
+
 # 1. install dojo
-cd /home/opensrf && wget http://download.dojotoolkit.org/release-1.3.3/dojo-release-1.3.3.tar.gz
+if [ ! -f "/home/opensrf/dojo-release-1.3.3.tar.gz" ]
+then
+  cd /home/opensrf && wget http://download.dojotoolkit.org/release-1.3.3/dojo-release-1.3.3.tar.gz
+fi
 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
+# 3. install circ scripts and opac skins - DEPRECATED
 
-# (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
-
-# (c) TPAC stuff
-apt-get install rake erubis ruby-git
-if [ ! -d "${TPACS}" ]; then
-  cd ${DEPLOYDIR} && git clone git://git.sitka.bclibraries.ca/sitka/deploykit.git
-fi
-cd ${TPACS} && git pull
-cd ${TPACS}/deploykit && mv config.yml.sample config.yml
-if [ ! -d "/etc/apache2/includes" ]; then
-  mkdir /etc/apache2/includes
-fi
-if [ ! -d "/srv/openils/var/skins" ]; then
-  mkdir /srv/openils/var/skins
-fi
-# TODO: use rake to build AND deploy properly!
-#cd ${TPACS}/deploykit && rake tpac:all && \
-#  for TPACSKIN in `ls -1 ${TPACS}/deploykit/build`; do mkdir -p /srv/openils/var/skins/${TPACSKIN}/opac && \
-#    cp -r build/${TPACSKIN}/templates/opac/* /srv/openils/var/skins/${TPACSKIN}/opac/ && \
-#    cp ${TPACS}/build/${TPACSKIN}/apache2/${TPACSKIN}.conf /etc/apache2/sites-available/ && \
-#    cp ${TPACS}/build/${TPACSKIN}/apache2/${TPACSKIN}.conf-include /etc/apache2/includes/ ; done
-
-# (d) 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
-# 4. avoid 404s
+# 4a. avoid 404s
 touch ${INSTALLDIR}/var/web/css/skin/default/register_custom.css
 touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/patron_custom.properties
 touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/common_custom.properties
@@ -150,18 +127,21 @@ touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/cat_custom.properties
 touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/circ_custom.properties
 touch ${INSTALLDIR}/var/web/xul/server/skin/custom.js
 
-# 5. locale hack
-cd ${INSTALLDIR}/var/web/opac/locale && cp -fdr en-US en-US-bak && cp -fdr en-CA en-US
+# 4b. workaround for LP#1461683
+cd ${INSTALLDIR}/var/web/xul/server/locale/en-CA && mv multiclass_search_help.html multiclass_search_help.html.orig && ln -s ../en-US/multiclass_search_help.html
+
+# 5. locale hack - XXX deprecated?
+#cd ${INSTALLDIR}/var/web/opac/locale && cp -fdr en-US en-US-bak && cp -fdr en-CA en-US
  
 # 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'
-apt-get install libcgi-session-perl libhtml-template-perl
+#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'
+apt-get install -y libcgi-session-perl libhtml-template-perl
 
-# 7. support scripts
-cp ${BUILDDIR}/Open-ILS/src/support-scripts/generate_circ_notices.pl ${INSTALLDIR}/bin
-cp ${BUILDDIR}/Open-ILS/src/support-scripts/oils_header.pl ${INSTALLDIR}/bin
+# 7. support scripts - XXX deprecated?
+#cp ${BUILDDIR}/Open-ILS/src/support-scripts/generate_circ_notices.pl ${INSTALLDIR}/bin
+#cp ${BUILDDIR}/Open-ILS/src/support-scripts/oils_header.pl ${INSTALLDIR}/bin
 
 # 8. setup start page
 if [ ! -d "${INSTALLDIR}/var/web/news" ]
@@ -177,10 +157,20 @@ do
   fi
 done
 
+# 8.5 offline patron list
+if [ ! -d "${INSTALLDIR}/var/data/offline/blocked" ] ; then mkdir -p ${INSTALLDIR}/var/data/offline/blocked ; fi
+if [ ! -e "${INSTALLDIR}/var/web/standalone/list.txt" ] ; then ln -s ${INSTALLDIR}/var/data/offline/blocked/patron-block-list.txt list.txt ; fi
+if [ ! -e "${INSTALLDIR}/bin/update-offline-blocked-list.sh" ] ; then cp ${SITKATOOLS}/maintenance/update-offline-blocked-list.sh ${INSTALLDIR}/bin/update-offline-blocked-list.sh ; fi
+
 # 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
+apt-get install -y nsis unzip
+
+# 11. integrity checker prereqs
+apt-get install -y libconfig-simple-perl libgit-repository-perl libdate-manip-perl
+
+# 12. paper overdue prereqs
+apt-get install -y python-reportlab python-reportlab-accel