EG install scripts: nonprod-28 -> nonprod
[sitka/sitka-tools.git] / deployment / install-eg.sh
index b867618..984fd05 100755 (executable)
@@ -1,25 +1,39 @@
 #!/bin/bash
 # IMPORTANT! This script assumes you have already installed OpenSRF.
 
-HOSTNAME="nonprod-28"
+HOSTNAME="nonprod"
 DEFAULT_USER="sitkastaff"
 HOMEDIR="/home/${DEFAULT_USER}"
 #EGRELEASE="Evergreen-ILS-2.8.beta"
 #BUILDDIR="${HOMEDIR}/${EGRELEASE}"
 BUILDDIR="${HOMEDIR}/evergreen"
 INSTALLDIR="/srv/openils"
-BRANCH="upgrade/eg28/phase3-tpac"
+BRANCH="production/sitka_2_8_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"
-SITKACONF_BRANCH="eg28"
+SITKACONF_BRANCH="master"
 SITKATOOLS="/root/sitka-tools"
 
 suwrap() {
   su -s /bin/bash -c "source ~/.bashrc ; $1" $2
 }
 
+while getopts ":p" opt ; do
+  case $opt in
+    p ) PROD="prod";;
+    e ) EDI="edi";;
+  esac
+done
+shift $(($OPTIND - 1))
+
+if [[ -n "$PROD" ]] ; then
+  echo 'this is a production install'
+else
+  echo 'this is NOT a production install'
+fi
+
 # as DEFAULT_USER
 
 # grab Sitka config files
@@ -48,7 +62,7 @@ cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-trusty
  
 # as 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 "PATH=${INSTALLDIR}/bin:\$PATH cd ${BUILDDIR} && PATH=${INSTALLDIR}/bin:\$PATH ./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 LOCALE=fr-CA install && make LOCALE=en-CA install" ${DEFAULT_USER}
  
@@ -75,9 +89,11 @@ done
 chown -R opensrf:opensrf /var/lock/apache2
 
 # set up log rotation
-if [ ! -f "/etc/logrotate.d/evergreen" ]
-then
-  cp ${SITKACONF}/files/etc/logrotate.d/evergreen/${HOSTNAME} /etc/logrotate.d/evergreen
+if [[ ! -n "$PROD" ]] ; then
+  if [ ! -f "/etc/logrotate.d/evergreen" ]
+  then
+    cp ${SITKACONF}/files/etc/logrotate.d/evergreen/${HOSTNAME} /etc/logrotate.d/evergreen
+  fi
 fi
  
 # 0. osrf conf stuff 
@@ -135,20 +151,39 @@ cd ${INSTALLDIR}/var/web/xul/server/locale/en-CA && mv multiclass_search_help.ht
  
 # 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'
+if [[ ! -d "${INSTALLDIR}/var/web/deletepatron" ]] ; then
+  NEW_DELETEPATRON_INSTALL="true"
+  cd ${INSTALLDIR}/var/web && git clone https://github.com/twirlip/deletepatron.git
+fi
+cd ${INSTALLDIR}/var/web/deletepatron && git checkout eg22
+if [[ -n "$NEW_DELETEPATRON_INSTALL" ]] ; then
+  find ${INSTALLDIR}/var/web/deletepatron -name "*.pm" | xargs sed -i -e 's|/openils|/srv/openils|g'
+fi
 apt-get install -y libcgi-session-perl libhtml-template-perl
 
-# 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
+# 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.5 EDI (optional)
+if [[ -n "$EDI" ]] ; then
+  cp -r ${BUILDDIR}/Open-ILS/src/edi_translator ${INSTALLDIR}/var/edi
+  cd ${INSTALLDIR}/var/edi && ./install.sh
+  cp ${BUILDDIR}/Open-ILS/src/support-scripts/edi_pusher.pl ${INSTALLDIR}/bin
+  cp ${BUILDDIR}/Open-ILS/src/support-scripts/edi_fetcher.pl ${INSTALLDIR}/bin
+  cp ${SYSADMIN}/files/${INSTALLDIR}/bin/edi_per_account_fetcher.sh ${INSTALLDIR}/bin/edi_per_account_fetcher.sh
+fi
 
 # 8. setup start page
 if [ ! -d "${INSTALLDIR}/var/web/news" ]
 then
   mkdir ${INSTALLDIR}/var/web/news
 fi
-NEWSFILES="index.html style.css"
+if [ ! -d "${INSTALLDIR}/var/web/news/media" ]
+then
+  mkdir ${INSTALLDIR}/var/web/news/media
+fi
+NEWSFILES="index.html style.css media/logo.png media/book.png media/policy.png media/dash.png media/delete.png"
 for NEWSFILE in ${NEWSFILES}
 do
   if [ -f "${SITKACONF}/files/${INSTALLDIR}/var/web/news/${NEWSFILE}/${HOSTNAME}" ]
@@ -156,17 +191,41 @@ do
     cp ${SITKACONF}/files/${INSTALLDIR}/var/web/news/${NEWSFILE}/${HOSTNAME} ${INSTALLDIR}/var/web/news/${NEWSFILE}
   fi
 done
+if [[ -n "$PROD" ]] ; then
+  if [ ! -e "${INSTALLDIR}/var/web/news/wikipull.pl" ] ; then cp ${SITKACONF}/files/${INSTALLDIR}/var/web/news/wikipull.pl/${HOSTNAME} ${INSTALLDIR}/var/web/news/wikipull.pl ; fi
+  if [ ! -e "/etc/cron.d/news" ] ; then cp ${SITKACONF}/files/etc/cron.d/news/${HOSTNAME} /etc/cron.d/news ; fi
+fi
 
 # 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 [ ! -d "${INSTALLDIR}/var/data/offline/blocked" ] ; then 
+  # TODO: handle prod - an NFS share should exist
+  if [[ ! -n "$PROD" ]] ; then
+    mkdir -p ${INSTALLDIR}/var/data/offline/blocked
+  fi
+fi
+if [ ! -e "${INSTALLDIR}/var/web/standalone/list.txt" ] ; then ln -sf ${INSTALLDIR}/var/data/offline/blocked/patron-block-list.txt ${INSTALLDIR}/var/web/standalone/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
 
-cp ${SITACONF}/files${INSTALLDIR}/var/data/zips.txt/${HOSTNAME} ${INSTALLDIR}/var/data/zips.txt
+cp ${SITKACONF}/files${INSTALLDIR}/var/data/zips.txt/${HOSTNAME} ${INSTALLDIR}/var/data/zips.txt
+
+cp -r ${SITKATOOLS}/overdrive-eg-opac/build/* ${INSTALLDIR}/var/web/js/ui/default/opac
+ODAPI_LIBS="bc mb"
+for ODAPI_LIB in ${ODAPI_LIBS} ; do
+  cp ${SITKACONF}/files/${INSTALLDIR}/var/web/js/ui/default/opac/${ODAPI_LIB}/od_config.js ${INSTALLDIR}/var/web/js/ui/default/opac/${ODAPI_LIB}/od_config.js
+done
+
+# install mobile PAC
+cd ${INSTALLDIR}/var/web/opac/extras && git clone git://git.sitka.bclibraries.ca/sitka/mobile-evergreen-opac.git mobile
 
 # 9. make sure opensrf owns all the stuff we just did
 chown -R opensrf:opensrf ${INSTALLDIR}
 chown -R opensrf:opensrf /home/opensrf
+SKINDIRS="${INSTALLDIR}/var/skins ${INSTALLDIR}/var/web/css/skin"
+for SKINDIR in ${SKINDIRS} ; do
+  if [[ ! -d "${SKINDIR}" ]] ; then mkdir ${SKINDIR} ; fi
+  chmod 777 ${SKINDIR}
+  chown -R sitkastaff:sitkastaff ${SKINDIR}
+done
 
 # 10. staff client stuff
 apt-get install -y nsis unzip
@@ -175,4 +234,4 @@ apt-get install -y nsis unzip
 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
+apt-get install -y python-reportlab python-reportlab-accel unifont