add Angular (eg2) install steps
[sitka/sitka-tools.git] / deployment / install-eg.sh
index b867618..d4ad0a6 100755 (executable)
 #!/bin/bash
 # IMPORTANT! This script assumes you have already installed OpenSRF.
 
-HOSTNAME="nonprod-28"
-DEFAULT_USER="sitkastaff"
-HOMEDIR="/home/${DEFAULT_USER}"
-#EGRELEASE="Evergreen-ILS-2.8.beta"
-#BUILDDIR="${HOMEDIR}/${EGRELEASE}"
-BUILDDIR="${HOMEDIR}/evergreen"
+HOSTNAME="nonprod"
+DEFAULT_USER="opensrf"
+INSTALL_USER="opensrf"
+BUILDDIR="/home/${INSTALL_USER}/evergreen"
 INSTALLDIR="/srv/openils"
-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"
-SITKACONF_BRANCH="eg28"
+BRANCH="user/jeffdavis/eg317-tpac"
+STAMP_ID="rel_3_1_7"
+ALT_STAMP_IDS="3_1_7"
+VERSION="3.1.7.sitka.1"
+SITKACONF="/home/${DEFAULT_USER}/sysadmin"
+SITKACONF_BRANCH="master"
 SITKATOOLS="/root/sitka-tools"
 
+THISHOST=`hostname -s`
+
 suwrap() {
   su -s /bin/bash -c "source ~/.bashrc ; $1" $2
 }
 
+while getopts ":pecWbtu" opt ; do
+  case $opt in
+    p ) PROD="prod";;
+    e ) EDI="edi";;
+    c ) CRONTAB="crontab";;
+    W ) SKIPWEBCLIENT="skipwebclient";;
+    b ) USEBUNDLE="usebundle";;
+    t ) TARBALL="tarball";;
+    u ) UPDATEONLY="updateonly";;
+  esac
+done
+shift $(($OPTIND - 1))
+
+if [[ -n "$PROD" ]] ; then
+  echo 'this is a production install'
+  [ "$HOSTNAME" == "nonprod" ] && HOSTNAME="prod"
+else
+  echo 'this is NOT a production install'
+fi
+
 # as DEFAULT_USER
 
 # grab Sitka config files
 if [ ! -d "${SITKACONF}" ]
 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}
+  suwrap "cd /home/${DEFAULT_USER} && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" ${DEFAULT_USER} || { echo "Could not get config files; exiting." ; exit 1; }
 fi
-suwrap "cd ${SITKACONF} && git fetch origin && git checkout ${SITKACONF_BRANCH} && git pull" ${DEFAULT_USER}
+suwrap "cd ${SITKACONF} && git fetch origin && git checkout ${SITKACONF_BRANCH} && git pull" ${DEFAULT_USER} || { echo "Could not checkout ${SITKACONF_BRANCH} config files; exiting." ; exit 1; }
 
-# checkout EG source
-if [ ! -d "${BUILDDIR}" ]
-then
-  suwrap "cd ${HOMEDIR} && git clone git://git.sitka.bclibraries.ca/sitka/evergreen evergreen" ${DEFAULT_USER}
+if [[ -n "$TARBALL" ]] ; then
+  EGRELEASE="Evergreen-ILS-${VERSION}"
+  EGRELEASETGZ="${EGRELEASE}.tar.gz"
+  [ ${VERSION} == "3.1.0" ] && EGRELEASETGZ="Evergreen-ILS-3.1.0a.tar.gz"
+  BUILDDIR="/home/${INSTALL_USER}/${EGRELEASE}"
+  BRANCH="$VERSION"
+  echo "installing packaged upstream release ${EGRELEASE}"
+  # download and unpack EG release
+  rm -rf ${BUILDDIR}
+  if [ ! -f "/home/${INSTALL_USER}/${EGRELEASETGZ}" ] ; then
+    suwrap "cd /home/${INSTALL_USER} && wget http://open-ils.org/downloads/${EGRELEASETGZ}" ${INSTALL_USER} || { echo "Could not download EG release tarball ${EGRELEASETGZ}" ; exit 1; }
+  fi
+  suwrap "cd /home/${INSTALL_USER} && tar xzf ${EGRELEASETGZ}" ${INSTALL_USER}
+else
+  # checkout EG source
+  if [ ! -d "${BUILDDIR}" ]
+  then
+    suwrap "cd /home/${INSTALL_USER} && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka/evergreen evergreen" ${INSTALL_USER}
+  fi
+  suwrap "cd ${BUILDDIR} && git fetch origin && git checkout ${BRANCH} && git pull" ${INSTALL_USER}
 fi
-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-trusty
-#cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-trusty-developer # required for web client
+cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-xenial
+if [[ ! -n "$TARBALL" ]] ; then
+  cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-xenial-developer # required for web client
+fi
 # 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} # 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 LOCALE=fr-CA install && make LOCALE=en-CA install" ${DEFAULT_USER}
+# web client
+if [[ ! -n "$TARBALL" && ! -n "$SKIPWEBCLIENT" ]] ; then
+  if [[ -n "$USEBUNDLE" ]] ; then
+    # use bundled web client dependencies from upstream
+    if [ ! -d "/home/${INSTALL_USER}/web-client-deps" ] ; then
+      suwrap "cd /home/${INSTALL_USER} && git clone git://git.sitka.bclibraries.ca/sitka/web-client-deps web-client-deps" ${INSTALL_USER}
+    fi
+    suwrap "cd /home/${INSTALL_USER}/web-client-deps && git checkout ${STAMP_ID}" ${INSTALL_USER}
+    if [ -d "${BUILDDIR}/Open-ILS/web/js/ui/default/staff/build" ] ; then rm -rf ${BUILDDIR}/Open-ILS/web/js/ui/default/staff/build ; fi
+    suwrap "cp -r /home/${INSTALL_USER}/web-client-deps/build ${BUILDDIR}/Open-ILS/web/js/ui/default/staff/build" ${INSTALL_USER}
+  else
+    # install dependencies
+    cd ${BUILDDIR}/Open-ILS/web/js/ui/default/staff/
+    suwrap "npm install" ${INSTALL_USER}
+    suwrap "npm run build-prod && npm run test" ${INSTALL_USER} || { echo 'Could not install files for AngularJS staff client' ; exit 1; }
+    cd ${BUILDDIR}/Open-ILS/src/eg2/
+    suwrap "npm install" ${INSTALL_USER}
+    suwrap "ng build --prod && npm run test" ${INSTALL_USER} || { echo 'Could not install files for Angular staff client' ; exit 1; }
+  fi
+fi
+
+# as INSTALL_USER
+[ ! -n "$TARBALL" ] && suwrap "cd ${BUILDDIR} && autoreconf -i" ${INSTALL_USER} # not required for release versions
+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/" ${INSTALL_USER}
+suwrap "cd ${BUILDDIR} && make" ${INSTALL_USER}
+suwrap "cd ${BUILDDIR}/build/i18n && make LOCALE=fr-CA install && make LOCALE=en-CA install" ${INSTALL_USER}
  
 # as root
 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}
  
+# setup start page
+if [ ! -d "${INSTALLDIR}/var/web/news" ]
+then
+  mkdir ${INSTALLDIR}/var/web/news
+fi
+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}" ]
+  then
+    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
+else
+  # nonprod server, auto-update splash page with install info
+  TODAY=`date +'%A %d %B %Y'`
+  sed -i "s|__THISHOST__|${THISHOST}|g" ${INSTALLDIR}/var/web/news/index.html
+  sed -i "s|__TODAY__|${TODAY}|g" ${INSTALLDIR}/var/web/news/index.html
+  sed -i "s|__VERSION__|${VERSION}|g" ${INSTALLDIR}/var/web/news/index.html
+  sed -i "s|__BRANCH__|${BRANCH}|g" ${INSTALLDIR}/var/web/news/index.html
+fi
+
+# setup/update test server banner
+if [[ ! -n "$PROD" ]] ; then
+  SITECONFIGS="/etc/apache2/sites-available/test-server.conf"
+  for SITECONFIG in ${SITECONFIGS} ; do
+    cp ${SITKACONF}/files/${SITECONFIG}/${HOSTNAME} ${SITECONFIG}
+    sed -i "s|__NONPROD__|${THISHOST}|g" ${SITECONFIG}
+    sed -i "s|__VERSION__|${VERSION}|g" ${SITECONFIG}
+  done
+  a2ensite test-server.conf
+fi
+
+# if we are just updating an existing EG install, we're all done!
+if [[ -n "$UPDATEONLY" ]] ; then
+    exit 0
+fi
+
+if [[ ! -n "$SKIPWEBCLIENT" ]] ; then
+    apt-get install -y nginx
+fi
+
 # Apache stuff (as root):
-APACHEFILES="/etc/apache2/eg_vhost.conf /etc/apache2/eg_startup /etc/apache2/sites-available/eg.conf /etc/apache2/envvars"
+APACHEFILES="/etc/apache2/mods-available/mpm_prefork.conf"
 for APACHEFILE in ${APACHEFILES}
 do
-  mv ${APACHEFILE} ${APACHEFILE}.bak
+  [[ -e "${APACHEFILE}" ]] && mv ${APACHEFILE} ${APACHEFILE}.`date +%Y-%m-%d-%H%M%S`
   cp ${SITKACONF}/files/${APACHEFILE}/${HOSTNAME} ${APACHEFILE}
 done
-#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
+cp ${BUILDDIR}/Open-ILS/examples/apache/eg_startup /etc/apache2/eg_startup
+sed -i 's/export APACHE_RUN_USER=www-data/export APACHE_RUN_USER=opensrf/' /etc/apache2/envvars
+if [ ! -d "/etc/apache2/includes" ] ; then
+  mkdir /etc/apache2/includes
+fi
+a2dismod mpm_event
+a2enmod mpm_prefork
+a2enmod headers
 # ensure opensrf can run Apache
 chown -R opensrf:opensrf /var/lock/apache2
 
+# More Apache stuff for non-production sites
+if [[ ! -n "$PROD" ]] ; then
+  a2dissite 000-default
+  if [ ! -d "/etc/apache2/ssl/libraries.coop/star.catalogue.libraries.coop" ]
+  then
+    mkdir -p /etc/apache2/ssl/libraries.coop/star.catalogue.libraries.coop
+    cp ${SITKACONF}/files/etc/ssl/apache2/star.catalogue.libraries.coop/star.catalogue.libraries.coop.crt /etc/apache2/ssl/libraries.coop/star.catalogue.libraries.coop/star_catalogue_libraries_coop.crt
+    cp ${SITKACONF}/files/etc/ssl/apache2/star.catalogue.libraries.coop/star.catalogue.libraries.coop.key /etc/apache2/ssl/libraries.coop/star.catalogue.libraries.coop/star_catalogue_libraries_coop.key
+    cp ${SITKACONF}/files/etc/ssl/apache2/star.catalogue.libraries.coop/star.catalogue.libraries.coop.ca /etc/apache2/ssl/libraries.coop/star.catalogue.libraries.coop/star_catalogue_libraries_coop.ca
+  fi
+fi
+
+# websockets config
+if [[ ! -n "$SKIPWEBCLIENT" ]] ; then
+    cp -b ${SITKACONF}/files/etc/nginx/sites-available/osrf-ws-http-proxy/${HOSTNAME} /etc/nginx/sites-available/osrf-ws-http-proxy
+    ln -s /etc/nginx/sites-available/osrf-ws-http-proxy /etc/nginx/sites-enabled/osrf-ws-http-proxy
+    rm /etc/nginx/sites-enabled/default
+    cp -b ${SITKACONF}/files/etc/apache2/ports.conf/${HOSTNAME} /etc/apache2/ports.conf
+    WSJSFILES="opensrf_ws.js opensrf_ws_shared.js"
+    for WSJSFILE in ${WSJSFILES} ; do
+        # NOTE: this should be unnecessary if we installed OpenSRF with ./configure --with-websockets-port=443
+        sed -i 's/var WEBSOCKET_PORT_SSL = 7682;/var WEBSOCKET_PORT_SSL = 443;/g' ${INSTALLDIR}/lib/javascript/$WSJSFILE
+    done
+fi
+
+# install default crontab, if specified
+if [[ -c "$CRONTAB" ]]; then
+  if [ ! -f "/etc/cron.d/evergreen-dailies" ] ; then
+    cp ${SITKACONF}/files/etc/cron.d/evergreen-dailies/${HOSTNAME} /etc/cron.d/evergreen-dailies
+  fi
+fi
+
+# LDAP config
+if ! `diff ${SITKACONF}/files/etc/ldap/ldap.conf/${HOSTNAME} /etc/ldap/ldap.conf >/dev/null` ; then
+    cp -b --suffix=.`date +%Y-%m-%d-%H%M%S` ${SITKACONF}/files/etc/ldap/ldap.conf/${HOSTNAME} /etc/ldap/ldap.conf
+fi
+
 # 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
+
+# remote logging (prod only)
+if [[ -n "$PROD" ]] ; then
+  apt-get install syslog-ng
+  cp ${SITKACONF}/files/etc/syslog-ng/syslog-ng.conf/${HOSTNAME} /etc/syslog-ng/syslog-ng.conf
+  cp ${SITKACONF}/files/etc/syslog-ng/conf.d/sitka.conf/${HOSTNAME} /etc/syslog-ng/conf.d/sitka.conf
+  systemctl restart syslog-ng.service
+  cp ${SITKACONF}/files/usr/local/bin/eg-stats-collector-remote-log.pl /usr/local/bin/eg-stats-collector-remote-log.pl
+  cp ${SITKACONF}/files/usr/local/bin/eg-stats-keepalive.sh /usr/local/bin/eg-stats-keepalive.sh
+  cp ${SITKACONF}/files/etc/cron.d/eg-stats-keepalive/${HOSTNAME} /etc/cron.d/eg-stats-keepalive
+fi
+
+# action trigger filters (prod only)
+if [[ -n "$PROD" ]] ; then
+  if [ -f "${INSTALLDIR}/conf/action_trigger_filters.json" ] ; then
+    mv ${INSTALLDIR}/conf/action_trigger_filters.json ${INSTALLDIR}/conf/action_trigger_filters.json.`date +%Y-%m-%d-%H%M%S`
+  fi
+  cp ${SITKACONF}/files/${INSTALLDIR}/conf/action_trigger_filters.json/${HOSTNAME} ${INSTALLDIR}/conf/action_trigger_filters.json
 fi
  
 # 0. osrf conf stuff 
@@ -85,12 +246,18 @@ fi
 OSRFCONFFILES="${INSTALLDIR}/conf/opensrf.xml ${INSTALLDIR}/conf/opensrf_core.xml"
 for OSRFCONFFILE in ${OSRFCONFFILES}
 do
-  mv ${OSRFCONFFILE} ${OSRFCONFFILE}.bak
-  cp ${SITKACONF}/files/${OSRFCONFFILE}/${HOSTNAME} ${OSRFCONFFILE}
+  mv ${OSRFCONFFILE} ${OSRFCONFFILE}.`date +%Y-%m-%d-%H%M%S`
+  if [[ -n "$PROD" && -f "${SITKACONF}/files/${OSRFCONFFILE}/${HOSTNAME}-314" ]] ; then
+    cp ${SITKACONF}/files/${OSRFCONFFILE}/${HOSTNAME}-314 ${OSRFCONFFILE}
+  else
+    cp ${SITKACONF}/files/${OSRFCONFFILE}/${HOSTNAME} ${OSRFCONFFILE}
+  fi
+  sed -i "s|__HOSTNAME__|${THISHOST}|g" ${OSRFCONFFILE}
 done
 if [ ! -f "/home/opensrf/.srfsh.xml" ]
 then
   cp ${SITKACONF}/files/home/opensrf/.srfsh.xml/${HOSTNAME} /home/opensrf/.srfsh.xml
+  sed -i "s|__HOSTNAME__|${THISHOST}|g" /home/opensrf/.srfsh.xml
 fi 
 
 # 1. install dojo
@@ -100,6 +267,11 @@ then
 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/.
+# FIXME stock dojo is probably superfluous when we use the following Evergreen-specific tarball...
+if [ ! -f "/home/opensrf/dojo.tgz" ] ; then
+  cd /home/opensrf && wget http://evergreen-ils.org/downloads/dojo.tgz
+fi
+tar -C ${INSTALLDIR}/var/web/js/dojo/ -zxf /home/opensrf/dojo.tgz
  
 # 2. set up staff client
 cd ${INSTALLDIR}/var/web/xul && rm server && rm current
@@ -135,38 +307,67 @@ 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
+cp ${BUILDDIR}/Open-ILS/src/support-scripts/badge_score_generator.pl ${INSTALLDIR}/bin
 
-# 8. setup start page
-if [ ! -d "${INSTALLDIR}/var/web/news" ]
-then
-  mkdir ${INSTALLDIR}/var/web/news
+# 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
+  # add local modifications to openils-mapper rubygem (eww, yuck, barf)
+  cp -b ${SYSADMIN}/files/var/lib/gems/2.3.0/gems/openils-mapper-0.9.9/lib/openils/mapper.rb /var/lib/gems/2.3.0/gems/openils-mapper-0.9.9/lib/openils/mapper.rb
+  cp -b ${SYSADMIN}/files/var/lib/gems/2.3.0/gems/openils-mapper-0.9.9/lib/edi/mapper.rb /var/lib/gems/2.3.0/gems/openils-mapper-0.9.9/lib/edi/mapper.rb
 fi
-NEWSFILES="index.html style.css"
-for NEWSFILE in ${NEWSFILES}
-do
-  if [ -f "${SITKACONF}/files/${INSTALLDIR}/var/web/news/${NEWSFILE}/${HOSTNAME}" ]
-  then
-    cp ${SITKACONF}/files/${INSTALLDIR}/var/web/news/${NEWSFILE}/${HOSTNAME} ${INSTALLDIR}/var/web/news/${NEWSFILE}
-  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 [ ! -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 -b --suffix=.`date +%Y-%m-%d-%H%M%S` ${SITKACONF}/files${INSTALLDIR}/var/web/robots.txt/${HOSTNAME} ${INSTALLDIR}/var/web/robots.txt
 
 # 9. make sure opensrf owns all the stuff we just did
-chown -R opensrf:opensrf ${INSTALLDIR}
+echo 'managing file permissions...'
+if [[ ! -n "$PROD" ]] ; then
+  chown -R opensrf:opensrf ${INSTALLDIR} 2>/dev/null
+else
+  for file in `ls -1 ${INSTALLDIR} | grep -v var` ; do chown -R opensrf:opensrf ${INSTALLDIR}/$file ; done
+  chown opensrf:opensrf ${INSTALLDIR}/var
+  for file in `ls -1 ${INSTALLDIR}/var | egrep -v '(data|tmp|web)'` ; do chown -R opensrf:opensrf ${INSTALLDIR}/var/$file ; done
+  chown opensrf:opensrf ${INSTALLDIR}/var/data ${INSTALLDIR}/var/web
+  for file in `ls -1 ${INSTALLDIR}/var/data | grep -v offline` ; do chown -R opensrf:opensrf ${INSTALLDIR}/var/data/$file ; done
+  for file in `ls -1 ${INSTALLDIR}/var/web | grep -v reporter` ; do chown -R opensrf:opensrf ${INSTALLDIR}/var/web/$file ; done
+fi
 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 ${DEFAULT_USER}:${DEFAULT_USER} ${SKINDIR}
+done
+chown -R ${DEFAULT_USER}:${DEFAULT_USER} ${INSTALLDIR}/conf/kpac ${INSTALLDIR}/var/web/images/kpac
 
 # 10. staff client stuff
 apt-get install -y nsis unzip
@@ -175,4 +376,7 @@ 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
+
+echo 'Evergreen is installed!'
+