Better handling of non-prod Apache config; smarter regex for matching template values
[sitka/sitka-tools.git] / deployment / install-eg.sh
index 938c1de..7a47db2 100755 (executable)
@@ -16,6 +16,8 @@ SITKACONF="${HOMEDIR}/sysadmin"
 SITKACONF_BRANCH="master"
 SITKATOOLS="/root/sitka-tools"
 
+THISHOST=`hostname -s`
+
 suwrap() {
   su -s /bin/bash -c "source ~/.bashrc ; $1" $2
 }
@@ -72,14 +74,12 @@ 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 /etc/apache2/envvars"
+APACHEFILES="/etc/apache2/eg_vhost.conf /etc/apache2/eg_startup /etc/apache2/envvars"
 for APACHEFILE in ${APACHEFILES}
 do
   mv ${APACHEFILE} ${APACHEFILE}.bak
   cp ${SITKACONF}/files/${APACHEFILE}/${HOSTNAME} ${APACHEFILE}
 done
-#a2dissite 000-default
-#a2ensite eg.conf
 #if [ ! -d "/etc/apache2/ssl" ]
 #then
 #  mkdir /etc/apache2/ssl
@@ -88,6 +88,17 @@ done
 # ensure opensrf can run Apache
 chown -R opensrf:opensrf /var/lock/apache2
 
+# More Apache stuff for non-production sites (we manage this with Puppet on prod)
+if [[ ! -n "$PROD" ]] ; then
+  SITECONFIGS="/etc/apache2/includes/498-ssl-star.catalogue.libraries.coop-include /etc/apache2/includes/499-rewrites.conf-include /etc/apache2/sites-available/eg.conf /etc/apache2/sites-available/499-star.catalogue.libraries.coop.conf"
+  for SITECONFIG in ${SITECONFIGS} ; do
+    mv ${SITECONFIG} ${SITECONFIG}.bak
+    cp ${SITKACONF}/files/${SITECONFIG}/${HOSTNAME} ${SITECONFIG}
+    sed -i "s|__NONPROD__|${THISHOST}|g" ${SITECONFIG}
+  done
+  a2ensite eg.conf
+fi
+
 # set up log rotation
 if [[ ! -n "$PROD" ]] ; then
   if [ ! -f "/etc/logrotate.d/evergreen" ]
@@ -201,12 +212,11 @@ if [[ -n "$PROD" ]] ; then
   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
-  THISHOST=`hostname -s`
   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
+  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
 
 # 8.5 offline patron list