install-osrf.sh: set ejabberd host correctly during registration on prod
[sitka/sitka-tools.git] / deployment / update-osrf-eg.sh
1 #!/bin/bash
2 HOSTNAME="nonprod"
3 DEFAULT_USER="sitkastaff"
4 INSTALL_USER="opensrf"
5 #EGRELEASE="Evergreen-ILS-2.12.beta"
6 #BUILDDIR="/home/${INSTALL_USER}/${EGRELEASE}"
7 BUILDDIR="/home/${INSTALL_USER}/evergreen"
8 INSTALLDIR="/srv/openils"
9 BRANCH="production/sitka_2_12_tpac"
10 STAMP_ID="rel_2_12_1"
11 ALT_STAMP_IDS="2_12_1 rel_2_12_0 2_12_0 rel_2_12_beta 2_12_beta"
12 VERSION="2.12.1.sitka.0"
13 SITKACONF="/home/${DEFAULT_USER}/sysadmin"
14 SITKACONF_BRANCH="master"
15 SITKATOOLS="/root/sitka-tools"
16
17 THISHOST=`hostname -s`
18
19 suwrap() {
20   su -s /bin/bash -c "source ~/.bashrc ; $1" $2
21 }
22
23 # as DEFAULT_USER
24 if [ ! -d "/home/sitkastaff/sysadmin" ]
25 then
26   # this will fail unless DEFAULT_USER has read access to the repo
27   su -c "cd /home/sitkastaff && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" sitkastaff
28 fi
29 su -c "cd /home/sitkastaff/sysadmin && git fetch origin && git checkout master && git pull" sitkastaff
30 if [ ! -d "home/sitkastaff/opensrf/.git" ] ; then
31   su -c "cd /home/sitkastaff && git clone git://git.evergreen-ils.org/OpenSRF.git opensrf" sitkastaff
32 fi
33 su -c "cd home/sitkastaff/opensrf && git fetch origin && git checkout rel_2_5 && git pull" sitkastaff
34  
35 # as root
36 echo "Installing OpenSRF prerequisites for Ubuntu..."
37 cd home/sitkastaff/opensrf && make -f src/extras/Makefile.install ubuntu-trusty
38  
39 # as DEFAULT_USER
40 echo "Configuring and building OpenSRF..."
41 su -c "cd home/sitkastaff/opensrf && autoreconf -i" sitkastaff
42 su -c "cd home/sitkastaff/opensrf && ./configure --prefix=/srv/openils --sysconfdir=/srv/openils/conf --with-websockets-port=443" sitkastaff
43 su -c "cd home/sitkastaff/opensrf && make" sitkastaff
44  
45 # as root
46 echo "Installing OpenSRF..."
47 cd home/sitkastaff/opensrf && make install
48  
49 # as root
50 echo "ldconfig stuff..."
51 echo "/srv/openils/lib" > /etc/ld.so.conf.d/opensrf.conf
52 ldconfig
53  
54 #!/bin/bash
55 # IMPORTANT! This script assumes you have already installed OpenSRF.
56
57 THISHOST=`hostname -s`
58
59 # checkout EG source
60 if [ ! -d "${BUILDDIR}" ]
61 then
62   suwrap "cd /home/${INSTALL_USER} && git clone git://git.sitka.bclibraries.ca/sitka/evergreen evergreen" ${INSTALL_USER}
63 fi
64 suwrap "cd ${BUILDDIR} && git fetch origin && git checkout ${BRANCH} && git pull" ${INSTALL_USER}
65
66 # as root
67 cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-trusty
68 cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-trusty-developer # required for web client
69 # by default, CPAN needs some manual input at this point; you can just accept all defaults
70  
71 # web client
72 if [[ -n "$WEBCLIENT" ]] ; then
73   cd ${BUILDDIR}/Open-ILS/web/js/ui/default/staff/
74   suwrap "npm install" ${INSTALL_USER}
75   suwrap "bower install" ${INSTALL_USER}
76   suwrap "grunt all" ${INSTALL_USER} || { echo 'Could not install files for web-based staff client' ; exit 1; }
77 fi
78
79 # as INSTALL_USER
80 suwrap "cd ${BUILDDIR} && autoreconf -i" ${INSTALL_USER} # not required for release versions
81 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}
82 suwrap "cd ${BUILDDIR} && make" ${INSTALL_USER}
83 suwrap "cd ${BUILDDIR}/build/i18n && make LOCALE=fr-CA install && make LOCALE=en-CA install" ${INSTALL_USER}
84  
85 # as root
86 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/
87  
88 WSJSFILES="opensrf_ws.js opensrf_ws_shared.js"
89 for WSJSFILE in ${WSJSFILES} ; do
90     # NOTE: this should be unnecessary if we installed OpenSRF with ./configure --with-websockets-port=443
91     sed -i 's/var WEBSOCKET_PORT_SSL = 7682;/var WEBSOCKET_PORT_SSL = 443;/g' ${INSTALLDIR}/lib/javascript/$WSJSFILE
92 done
93
94 echo 'managing file permissions...'
95 for file in `ls -1 ${INSTALLDIR} | grep -v var` ; do chown -R opensrf:opensrf ${INSTALLDIR}/$file ; done
96 chown opensrf:opensrf ${INSTALLDIR}/var
97 for file in `ls -1 ${INSTALLDIR}/var | egrep -v '(data|tmp|web)'` ; do chown -R opensrf:opensrf ${INSTALLDIR}/var/$file ; done
98 chown opensrf:opensrf ${INSTALLDIR}/var/data ${INSTALLDIR}/var/web
99 for file in `ls -1 ${INSTALLDIR}/var/data | grep -v offline` ; do chown -R opensrf:opensrf ${INSTALLDIR}/var/data/$file ; done
100 for file in `ls -1 ${INSTALLDIR}/var/web | grep -v reporter` ; do chown -R opensrf:opensrf ${INSTALLDIR}/var/web/$file ; done
101 chown -R opensrf:opensrf /home/opensrf
102
103 echo 'Evergreen is installed!'
104