install-eg.sh: allow variance in production vs non-production installs
[sitka/sitka-tools.git] / deployment / install-eg.sh
index 152df94..480df17 100755 (executable)
@@ -8,7 +8,7 @@ HOMEDIR="/home/${DEFAULT_USER}"
 #BUILDDIR="${HOMEDIR}/${EGRELEASE}"
 BUILDDIR="${HOMEDIR}/evergreen"
 INSTALLDIR="/srv/openils"
-BRANCH="upgrade/eg28/phase3-tpac"
+BRANCH="upgrade/eg28/final-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"
@@ -17,9 +17,22 @@ SITKACONF_BRANCH="eg28"
 SITKATOOLS="/root/sitka-tools"
 
 suwrap() {
-  su -s /bin/bash -l -c "source ~/.bashrc ; $1" $2
+  su -s /bin/bash -c "source ~/.bashrc ; $1" $2
 }
 
+while getopts ":p" opt ; do
+  case $opt in
+    p ) PROD="prod";;
+  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
@@ -58,7 +71,7 @@ mv ${INSTALLDIR}/var/web/reports/fm_IDL.xml ${INSTALLDIR}/var/web/reports/fm_IDL
 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"
+APACHEFILES="/etc/apache2/eg_vhost.conf /etc/apache2/eg_startup /etc/apache2/sites-available/eg.conf /etc/apache2/envvars"
 for APACHEFILE in ${APACHEFILES}
 do
   mv ${APACHEFILE} ${APACHEFILE}.bak
@@ -88,9 +101,9 @@ do
   mv ${OSRFCONFFILE} ${OSRFCONFFILE}.bak
   cp ${SITKACONF}/files/${OSRFCONFFILE}/${HOSTNAME} ${OSRFCONFFILE}
 done
-if [ ! -f "${HOMEDIR}/.srfsh.xml" ]
+if [ ! -f "/home/opensrf/.srfsh.xml" ]
 then
-  cp ${SITKACONF}/files/home/opensrf/.srfsh.xml/${HOSTNAME} ${HOMEDIR}/.srfsh.xml
+  cp ${SITKACONF}/files/home/opensrf/.srfsh.xml/${HOSTNAME} /home/opensrf/.srfsh.xml
 fi 
 
 # 1. install dojo
@@ -148,7 +161,11 @@ 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,12 +173,23 @@ 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 -s ${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 ${SITKACONF}/files${INSTALLDIR}/var/data/zips.txt/${HOSTNAME} ${INSTALLDIR}/var/data/zips.txt
+
 # 9. make sure opensrf owns all the stuff we just did
 chown -R opensrf:opensrf ${INSTALLDIR}
 chown -R opensrf:opensrf /home/opensrf