EG install scripts: nonprod-28 -> nonprod
[sitka/sitka-tools.git] / deployment / install-osrf.sh
index 1daac3a..f19384a 100755 (executable)
@@ -1,10 +1,12 @@
 #!/bin/bash
-OSRF="opensrf-2.1.2"
-INSTALLDIR="/srv/openils"
-HOSTNAME="nonprod"
 DEFAULT_USER="sitkastaff"
 HOMEDIR="/home/${DEFAULT_USER}"
+BUILDDIR="${HOMEDIR}/opensrf"
+INSTALLDIR="/srv/openils"
+BRANCH="rel_2_4"
+HOSTNAME="nonprod"
 SITKACONF="${HOMEDIR}/sysadmin"
+SITKACONF_BRANCH="master"
 
 # test for ejabberd passwords
 if [ -z "$PRIVATE_ROUTER_PASSWD" -o -z "$PRIVATE_OPENSRF_PASSWD" -o -z "$PUBLIC_ROUTER_PASSWD" -o -z "$PUBLIC_OPENSRF_PASSWD" ]
@@ -21,26 +23,43 @@ apt-get install git-core build-essential translate-toolkit python-polib bsdmainu
 if [ ! -d "${SITKACONF}" ]
 then
   # this will fail unless DEFAULT_USER has read access to the repo
-  su -l -c "cd ${HOMEDIR} && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" ${DEFAULT_USER}
+  su -c "cd ${HOMEDIR} && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" ${DEFAULT_USER}
 fi
-su -l -c "cd ${HOMEDIR}/sysadmin && git pull" ${DEFAULT_USER}
-su -l -c "cd ${HOMEDIR} && wget http://open-ils.org/downloads/${OSRF}.tar.gz && tar xzf ${OSRF}.tar.gz" ${DEFAULT_USER}
+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}
+fi
+su -c "cd ${BUILDDIR} && git fetch origin && git checkout ${BRANCH} && git pull" ${DEFAULT_USER}
  
 # as root
+echo "need a placeholder apache2.conf, installing from config repo..."
+if [ -f '/etc/apache2/apache2.conf' ]
+then
+  mv /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak
+fi
+cp ${SITKACONF}/files/etc/apache2/apache2.conf/${HOSTNAME} /etc/apache2/apache2.conf
+
+# as root
 echo "Installing OpenSRF prerequisites for Ubuntu..."
-cd ${HOMEDIR}/${OSRF} && make -f src/extras/Makefile.install ubuntu-precise
+cd ${BUILDDIR} && make -f src/extras/Makefile.install ubuntu-trusty
  
 # as DEFAULT_USER
 echo "Configuring and building OpenSRF..."
-su -l -c "cd ${HOMEDIR}/${OSRF} && autoreconf -i" ${DEFAULT_USER}
-su -l -c "cd ${HOMEDIR}/${OSRF} && ./configure --prefix=${INSTALLDIR} --sysconfdir=${INSTALLDIR}/conf" ${DEFAULT_USER}
-su -l -c "cd ${HOMEDIR}/${OSRF} && make" ${DEFAULT_USER}
+su -c "cd ${BUILDDIR} && autoreconf -i" ${DEFAULT_USER}
+su -c "cd ${BUILDDIR} && ./configure --prefix=${INSTALLDIR} --sysconfdir=${INSTALLDIR}/conf" ${DEFAULT_USER}
+su -c "cd ${BUILDDIR} && make" ${DEFAULT_USER}
  
 # as root
 echo "Installing OpenSRF..."
-cd ${HOMEDIR}/${OSRF} && make install
+cd ${BUILDDIR} && make install
 useradd -m -s /bin/bash opensrf
-echo "export PATH=\$PATH:${INSTALLDIR}/bin" >> /home/opensrf/.bashrc
+PATHFILES="/etc/profile /root/.bashrc /home/${DEFAULT_USER}/.bashrc /home/opensrf/.bashrc"
+for PATHFILE in ${PATHFILES} ; do
+  if [[ ! -e "${PATHFILE}" || ! `egrep "PATH=.*${INSTALLDIR}/bin" "${PATHFILE}"` ]] ; then 
+    echo "export PATH=${INSTALLDIR}/bin:\$PATH" >> ${PATHFILE}
+  fi
+done
+chown ${DEFAULT_USER}:${DEFAULT_USER} /home/${DEFAULT_USER}/.bashrc
 chown -R opensrf:opensrf ${INSTALLDIR}
  
 # as root, add the following two lines to /etc/hosts:
@@ -67,3 +86,18 @@ chmod 640 /etc/ejabberd/ejabberd.cfg
   ejabberdctl register opensrf public.localhost ${PUBLIC_OPENSRF_PASSWD}
 
 echo "OpenSRF is installed!"
+
+# websockets install (REQUIRED for web client)
+# XXX a valid SSL cert is required!
+#rm -r /tmp/apache-websocket
+#cd /tmp && git clone https://github.com/disconnect/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
+#cp ${SITKACONF}/files/etc/apache2-websockets/envvars/${HOSTNAME} /etc/apache2-websockets/envvars
+
+#/etc/init.d/apache2-websockets start
+
+#echo "websockets is installed!"
+