Per LP#1739803, warn about extra build step when deploying web client JS
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Fri, 23 Feb 2018 00:12:48 +0000 (16:12 -0800)
committerJeff Davis <jdavis@sitka.bclibraries.ca>
Fri, 23 Feb 2018 00:14:04 +0000 (16:14 -0800)
deployment/deployfile.sh
deployment/update-osrf-eg.sh [new file with mode: 0644]

index 28f7b1a..d919f08 100755 (executable)
@@ -16,12 +16,13 @@ OPTIONS:
   -u    Username to use when logging into remote server; if not provided, defaults to current user
   -b    Backup flag (optional); creates a backup instead of overwriting file on remote server
   -P    Auto add all production machines to host list
+  -x    Do not warn when extra build steps are required
   -h    Print this message and exit
   -v    Verbose output - echo parameters to stdout
 EOF
 }
 
-while getopts ":f:p:u:bdPvh" opt
+while getopts ":f:p:u:bdPxvh" opt
 do
   case $opt in
     f ) FILE=$OPTARG;;
@@ -30,6 +31,7 @@ do
     u ) USER=$OPTARG;;
     b ) BACKUP="-b --suffix=.`date +%Y%m%d%H%M`";;
     P ) PROD="P";;
+    x ) SKIP_BUILD_CHECK="x";;
     v ) VERBOSE="v";;
     h ) usage && exit 0;;
   esac
@@ -42,6 +44,16 @@ then
   exit 1
 fi
 
+if [[ -z "$SKIP_BUILD_CHECK" ]] ; then
+  if [[ $FILE = *Open-ILS/web/js/ui/default/staff* ]] ; then
+    echo "It looks like you are trying to deploy Evergreen web client JS."
+    echo "In EG 3.1+ and master, you must build JS before copying into place."
+    echo "After making changes, run 'npm run build' before deploying."
+    echo "(Re-run this script with the -x flag to skip this warning.)"
+    exit 1
+  fi
+fi
+
 # attempt to determine the remote destination path automatically
 if [[ -n "$AUTOPATH" ]] && [[ -z "$DEST" ]]
 then
diff --git a/deployment/update-osrf-eg.sh b/deployment/update-osrf-eg.sh
new file mode 100644 (file)
index 0000000..23c3f60
--- /dev/null
@@ -0,0 +1,104 @@
+#!/bin/bash
+HOSTNAME="nonprod"
+DEFAULT_USER="sitkastaff"
+INSTALL_USER="opensrf"
+#EGRELEASE="Evergreen-ILS-2.12.beta"
+#BUILDDIR="/home/${INSTALL_USER}/${EGRELEASE}"
+BUILDDIR="/home/${INSTALL_USER}/evergreen"
+INSTALLDIR="/srv/openils"
+BRANCH="production/sitka_2_12_tpac"
+STAMP_ID="rel_2_12_1"
+ALT_STAMP_IDS="2_12_1 rel_2_12_0 2_12_0 rel_2_12_beta 2_12_beta"
+VERSION="2.12.1.sitka.0"
+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
+}
+
+# as DEFAULT_USER
+if [ ! -d "/home/sitkastaff/sysadmin" ]
+then
+  # this will fail unless DEFAULT_USER has read access to the repo
+  su -c "cd /home/sitkastaff && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" sitkastaff
+fi
+su -c "cd /home/sitkastaff/sysadmin && git fetch origin && git checkout master && git pull" sitkastaff
+if [ ! -d "home/sitkastaff/opensrf/.git" ] ; then
+  su -c "cd /home/sitkastaff && git clone git://git.evergreen-ils.org/OpenSRF.git opensrf" sitkastaff
+fi
+su -c "cd home/sitkastaff/opensrf && git fetch origin && git checkout rel_2_5 && git pull" sitkastaff
+# as root
+echo "Installing OpenSRF prerequisites for Ubuntu..."
+cd home/sitkastaff/opensrf && make -f src/extras/Makefile.install ubuntu-trusty
+# as DEFAULT_USER
+echo "Configuring and building OpenSRF..."
+su -c "cd home/sitkastaff/opensrf && autoreconf -i" sitkastaff
+su -c "cd home/sitkastaff/opensrf && ./configure --prefix=/srv/openils --sysconfdir=/srv/openils/conf --with-websockets-port=443" sitkastaff
+su -c "cd home/sitkastaff/opensrf && make" sitkastaff
+# as root
+echo "Installing OpenSRF..."
+cd home/sitkastaff/opensrf && make install
+# as root
+echo "ldconfig stuff..."
+echo "/srv/openils/lib" > /etc/ld.so.conf.d/opensrf.conf
+ldconfig
+#!/bin/bash
+# IMPORTANT! This script assumes you have already installed OpenSRF.
+
+THISHOST=`hostname -s`
+
+# checkout EG source
+if [ ! -d "${BUILDDIR}" ]
+then
+  suwrap "cd /home/${INSTALL_USER} && git clone git://git.sitka.bclibraries.ca/sitka/evergreen evergreen" ${INSTALL_USER}
+fi
+suwrap "cd ${BUILDDIR} && git fetch origin && git checkout ${BRANCH} && git pull" ${INSTALL_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
+# by default, CPAN needs some manual input at this point; you can just accept all defaults
+# web client
+if [[ -n "$WEBCLIENT" ]] ; then
+  cd ${BUILDDIR}/Open-ILS/web/js/ui/default/staff/
+  suwrap "npm install" ${INSTALL_USER}
+  suwrap "bower install" ${INSTALL_USER}
+  suwrap "grunt all" ${INSTALL_USER} || { echo 'Could not install files for web-based staff client' ; exit 1; }
+fi
+
+# as INSTALL_USER
+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
+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/
+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
+
+echo 'managing file permissions...'
+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
+chown -R opensrf:opensrf /home/opensrf
+
+echo 'Evergreen is installed!'
+