install-osrf.sh: testing fix for LP#1774703
[sitka/sitka-tools.git] / deployment / install-osrf.sh
index 16ee489..988eeb3 100755 (executable)
@@ -1,19 +1,20 @@
 #!/bin/bash
-DEFAULT_USER="sitkastaff"
+DEFAULT_USER="opensrf"
 HOMEDIR="/home/${DEFAULT_USER}"
 BUILDDIR="${HOMEDIR}/opensrf"
 INSTALLDIR="/srv/openils"
-BRANCH="rel_2_5"
+#BRANCH="rel_3_0"
+BRANCH="user/berick/lp1774703-websocket-thread-lock"
 HOSTNAME="nonprod"
 SITKACONF="${HOMEDIR}/sysadmin"
 SITKACONF_BRANCH="master"
 
 THISHOST=`hostname -s`
 
-while getopts ":pwj" opt ; do
+while getopts ":pWj" opt ; do
   case $opt in
     p ) PROD="prod";;
-    w ) WEBSOCKETS="websockets";;
+    W ) SKIP_WEBSOCKETS="websockets";;
     j ) SKIP_EJABBERD_REG="skip_ejabberd_reg";;
   esac
 done
@@ -29,8 +30,10 @@ then
 fi
 
 # always use a proxy for websockets traffic
-if [[ -n "$WEBSOCKETS" ]] ; then
+if [[ ! -n "$SKIP_WEBSOCKETS" ]] ; then
     WSPORT="--with-websockets-port=443"
+    # load-balanced installs require mod_rpaf - see LP#1684970
+    apt-get install libapache2-mod-rpaf
 else
     WSPORT=""
 fi
@@ -53,7 +56,7 @@ then
 fi
 su -c "cd ${HOMEDIR}/sysadmin && git fetch origin && git checkout ${SITKACONF_BRANCH} && git pull" ${DEFAULT_USER}
 if [ ! -d "${BUILDDIR}/.git" ] ; then
-  su -c "cd ${HOMEDIR} && git clone git://git.evergreen-ils.org/OpenSRF.git opensrf" ${DEFAULT_USER}
+  su -c "cd ${HOMEDIR} && git clone git://git.evergreen-ils.org/working/OpenSRF.git opensrf" ${DEFAULT_USER}
 fi
 su -c "cd ${BUILDDIR} && git fetch origin && git checkout ${BRANCH} && git pull" ${DEFAULT_USER}
  
@@ -87,7 +90,9 @@ for PATHFILE in ${PATHFILES} ; do
   fi
 done
 chown ${DEFAULT_USER}:${DEFAULT_USER} /home/${DEFAULT_USER}/.bashrc
-chown -R opensrf:opensrf ${INSTALLDIR}
+if [[ ! -n "$PROD" ]] ; then
+  chown -R opensrf:opensrf ${INSTALLDIR}
+fi
  
 # as root, add the following two lines to /etc/hosts:
 #127.0.1.2     public.localhost        public
@@ -126,14 +131,16 @@ echo "OpenSRF is installed!"
 
 # websockets install (REQUIRED for web client)
 # XXX a valid SSL cert is required!
-if [[ -n "$WEBSOCKETS" ]] ; then
+if [[ ! -n "$SKIP_WEBSOCKETS" ]] ; then
   rm -r /tmp/apache-websocket
-  cd /tmp && git clone https://github.com/disconnect/apache-websocket
+  rm -r /etc/apache2-websockets /etc/init.d/apache2-websockets /usr/local/sbin/*-websockets /var/log/apache2-websockets/ /etc/logrotate.d/apache2-websockets
+  #cd /tmp && git clone https://github.com/disconnect/apache-websocket
+  cd /tmp && git clone https://github.com/jchampio/apache-websocket
   cd apache-websocket && apxs2 -i -a -c mod_websocket.c
   sh /usr/share/doc/apache2/examples/setup-instance websockets
   a2dismod websocket
   cp ${SITKACONF}/files/etc/apache2-websockets/apache2.conf/${HOSTNAME} /etc/apache2-websockets/apache2.conf
-  sed -i "s|__HOSTNAME__|${THISHOST}|g" /etc/apache2-websockets/apache2.conf
+  sed -i "s|__THISHOST__|${THISHOST}|g" /etc/apache2-websockets/apache2.conf
   cp ${SITKACONF}/files/etc/apache2-websockets/envvars/${HOSTNAME} /etc/apache2-websockets/envvars
 
   #/etc/init.d/apache2-websockets start