EG install scripts: more tweaks
[sitka/sitka-tools.git] / deployment / install-eg.sh
CommitLineData
0155bbac
JD
1#!/bin/bash
2# IMPORTANT! This script assumes you have already installed OpenSRF.
3
71f85432 4HOSTNAME="nonprod-28"
0155bbac
JD
5DEFAULT_USER="sitkastaff"
6HOMEDIR="/home/${DEFAULT_USER}"
ae9cb412
JD
7#EGRELEASE="Evergreen-ILS-2.8.beta"
8#BUILDDIR="${HOMEDIR}/${EGRELEASE}"
9BUILDDIR="${HOMEDIR}/evergreen"
0155bbac 10INSTALLDIR="/srv/openils"
4115cc36 11BRANCH="upgrade/eg28/phase3-tpac"
df5285f4
JD
12STAMP_ID="rel_2_8_1"
13ALT_STAMP_IDS="2_8_1 rel_2_8_beta 2_8_beta rel_2_8_0 2_8_0"
4115cc36 14VERSION="2.8.1.sitka.0"
0155bbac 15SITKACONF="${HOMEDIR}/sysadmin"
902a19b7 16SITKACONF_BRANCH="eg28"
341cf34e 17SITKATOOLS="/root/sitka-tools"
0155bbac 18
e724d7db 19suwrap() {
e2ad4781 20 su -s /bin/bash -c "source ~/.bashrc ; $1" $2
e724d7db
JD
21}
22
0155bbac
JD
23# as DEFAULT_USER
24
25# grab Sitka config files
26if [ ! -d "${SITKACONF}" ]
27then
28 # this will fail unless DEFAULT_USER has read access to the repo
e724d7db 29 suwrap "cd ${HOMEDIR} && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" ${DEFAULT_USER}
0155bbac 30fi
902a19b7 31suwrap "cd ${SITKACONF} && git fetch origin && git checkout ${SITKACONF_BRANCH} && git pull" ${DEFAULT_USER}
0155bbac
JD
32
33# checkout EG source
ae9cb412
JD
34if [ ! -d "${BUILDDIR}" ]
35then
36 suwrap "cd ${HOMEDIR} && git clone git://git.sitka.bclibraries.ca/sitka/evergreen evergreen" ${DEFAULT_USER}
37fi
38suwrap "cd ${BUILDDIR} && git fetch origin && git checkout ${BRANCH} && git pull" ${DEFAULT_USER}
71f85432
JD
39
40# download and unpack EG release
ae9cb412
JD
41#rm -rf ${BUILDDIR}
42#suwrap "cd ${HOMEDIR} && wget http://open-ils.org/downloads/${EGRELEASE}.tar.gz && tar xzf ${EGRELEASE}.tar.gz" ${DEFAULT_USER}
0155bbac
JD
43
44# as root
71f85432 45cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-trusty
4115cc36 46#cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-trusty-developer # required for web client
0155bbac
JD
47# by default, CPAN needs some manual input at this point; you can just accept all defaults
48
49# as DEFAULT_USER
ae9cb412 50suwrap "cd ${BUILDDIR} && autoreconf -i" ${DEFAULT_USER} # not required for release versions
fd31984b 51suwrap "cd ${BUILDDIR} && ./configure -C --prefix=${INSTALLDIR} --sysconfdir=${INSTALLDIR}/conf --with-opensrf-headers=${INSTALLDIR}/include/ --with-opensrf-libs=${INSTALLDIR}/lib/" ${DEFAULT_USER}
e724d7db 52suwrap "cd ${BUILDDIR} && make" ${DEFAULT_USER}
691245a2 53suwrap "cd ${BUILDDIR}/build/i18n && make LOCALE=fr-CA install && make LOCALE=en-CA install" ${DEFAULT_USER}
0155bbac
JD
54
55# as root
4115cc36 56cd ${BUILDDIR} && make STAFF_CLIENT_VERSION=${VERSION} STAFF_CLIENT_STAMP_ID=${STAMP_ID} install
ae9cb412 57mv ${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/
0155bbac
JD
58chown -R opensrf:opensrf ${INSTALLDIR}
59
60# Apache stuff (as root):
661d99f4 61APACHEFILES="/etc/apache2/eg_vhost.conf /etc/apache2/eg_startup /etc/apache2/sites-available/eg.conf /etc/apache2/envvars"
0155bbac
JD
62for APACHEFILE in ${APACHEFILES}
63do
bd41f68d 64 mv ${APACHEFILE} ${APACHEFILE}.bak
0155bbac
JD
65 cp ${SITKACONF}/files/${APACHEFILE}/${HOSTNAME} ${APACHEFILE}
66done
ae9cb412
JD
67#a2dissite 000-default
68#a2ensite eg.conf
69#if [ ! -d "/etc/apache2/ssl" ]
70#then
71# mkdir /etc/apache2/ssl
72# cd /etc/apache2/ssl && openssl req -new -x509 -days 365 -nodes -out server.crt -keyout server.key
73#fi
71f85432
JD
74# ensure opensrf can run Apache
75chown -R opensrf:opensrf /var/lock/apache2
7d30f3bf 76
26b3ea66 77# set up log rotation
abcafeff 78if [ ! -f "/etc/logrotate.d/evergreen" ]
26b3ea66
JD
79then
80 cp ${SITKACONF}/files/etc/logrotate.d/evergreen/${HOSTNAME} /etc/logrotate.d/evergreen
81fi
0155bbac 82
0155bbac
JD
83# 0. osrf conf stuff
84# FIXME: ensure osrf conf files point at a real, distinct db!
85OSRFCONFFILES="${INSTALLDIR}/conf/opensrf.xml ${INSTALLDIR}/conf/opensrf_core.xml"
86for OSRFCONFFILE in ${OSRFCONFFILES}
87do
51a4755a 88 mv ${OSRFCONFFILE} ${OSRFCONFFILE}.bak
0155bbac
JD
89 cp ${SITKACONF}/files/${OSRFCONFFILE}/${HOSTNAME} ${OSRFCONFFILE}
90done
661d99f4 91if [ ! -f "/home/opensrf/.srfsh.xml" ]
9d46f12d 92then
661d99f4 93 cp ${SITKACONF}/files/home/opensrf/.srfsh.xml/${HOSTNAME} /home/opensrf/.srfsh.xml
9d46f12d
JD
94fi
95
0155bbac 96# 1. install dojo
abcafeff 97if [ ! -f "/home/opensrf/dojo-release-1.3.3.tar.gz" ]
51a4755a
JD
98then
99 cd /home/opensrf && wget http://download.dojotoolkit.org/release-1.3.3/dojo-release-1.3.3.tar.gz
100fi
0155bbac
JD
101tar -C ${INSTALLDIR}/var/web/js -xzf /home/opensrf/dojo-release-1.3.3.tar.gz
102cp -r ${INSTALLDIR}/var/web/js/dojo-release-1.3.3/* ${INSTALLDIR}/var/web/js/dojo/.
103
104# 2. set up staff client
9d46f12d 105cd ${INSTALLDIR}/var/web/xul && rm server && rm current
0155bbac 106cd ${INSTALLDIR}/var/web/xul && ln -s ${STAMP_ID} current && ln -s current/server server
03b5e41f
JD
107for ALT_STAMP_ID in ${ALT_STAMP_IDS}
108do
109 cd ${INSTALLDIR}/var/web/xul && ln -s current ${ALT_STAMP_ID}
110done
0155bbac 111
9d46f12d 112# 3. install circ scripts and opac skins - DEPRECATED
71f85432 113
96b76bbb
JD
114# 4a. avoid 404s
115touch ${INSTALLDIR}/var/web/css/skin/default/register_custom.css
116touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/patron_custom.properties
117touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/common_custom.properties
118touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/offline_custom.properties
119touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/auth_custom.properties
120touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/cat_custom.properties
121touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/circ_custom.properties
122touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/patron_custom.properties
123touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/common_custom.properties
124touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/offline_custom.properties
125touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/auth_custom.properties
126touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/cat_custom.properties
127touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/circ_custom.properties
128touch ${INSTALLDIR}/var/web/xul/server/skin/custom.js
129
130# 4b. workaround for LP#1461683
131cd ${INSTALLDIR}/var/web/xul/server/locale/en-CA && mv multiclass_search_help.html multiclass_search_help.html.orig && ln -s ../en-US/multiclass_search_help.html
71f85432
JD
132
133# 5. locale hack - XXX deprecated?
134#cd ${INSTALLDIR}/var/web/opac/locale && cp -fdr en-US en-US-bak && cp -fdr en-CA en-US
0155bbac
JD
135
136# 6. deletepatron
137# ensure apache conf contains deletepatron config (location should be ${INSTALLDIR}/var/web/deletepatron)
ae9cb412
JD
138#cd ${INSTALLDIR}/var/web && git clone https://github.com/twirlip/deletepatron.git
139#cd ${INSTALLDIR}/var/web/deletepatron && git checkout eg22 && find . -name "*.pm" | xargs sed -i -e 's|/openils|/srv/openils|g'
140apt-get install -y libcgi-session-perl libhtml-template-perl
0155bbac 141
71f85432
JD
142# 7. support scripts - XXX deprecated?
143#cp ${BUILDDIR}/Open-ILS/src/support-scripts/generate_circ_notices.pl ${INSTALLDIR}/bin
144#cp ${BUILDDIR}/Open-ILS/src/support-scripts/oils_header.pl ${INSTALLDIR}/bin
0155bbac 145
c05e3516
JD
146# 8. setup start page
147if [ ! -d "${INSTALLDIR}/var/web/news" ]
148then
149 mkdir ${INSTALLDIR}/var/web/news
150fi
151NEWSFILES="index.html style.css"
152for NEWSFILE in ${NEWSFILES}
153do
154 if [ -f "${SITKACONF}/files/${INSTALLDIR}/var/web/news/${NEWSFILE}/${HOSTNAME}" ]
155 then
156 cp ${SITKACONF}/files/${INSTALLDIR}/var/web/news/${NEWSFILE}/${HOSTNAME} ${INSTALLDIR}/var/web/news/${NEWSFILE}
157 fi
158done
159
341cf34e
JD
160# 8.5 offline patron list
161if [ ! -d "${INSTALLDIR}/var/data/offline/blocked" ] ; then mkdir -p ${INSTALLDIR}/var/data/offline/blocked ; fi
162if [ ! -e "${INSTALLDIR}/var/web/standalone/list.txt" ] ; then ln -s ${INSTALLDIR}/var/data/offline/blocked/patron-block-list.txt list.txt ; fi
163if [ ! -e "${INSTALLDIR}/bin/update-offline-blocked-list.sh" ] ; then cp ${SITKATOOLS}/maintenance/update-offline-blocked-list.sh ${INSTALLDIR}/bin/update-offline-blocked-list.sh ; fi
164
661d99f4
JD
165cp ${SITACONF}/files${INSTALLDIR}/var/data/zips.txt/${HOSTNAME} ${INSTALLDIR}/var/data/zips.txt
166
c05e3516 167# 9. make sure opensrf owns all the stuff we just did
0155bbac 168chown -R opensrf:opensrf ${INSTALLDIR}
d4e88b8a 169chown -R opensrf:opensrf /home/opensrf
0155bbac 170
d4e88b8a 171# 10. staff client stuff
ae9cb412 172apt-get install -y nsis unzip
089f11fb
JD
173
174# 11. integrity checker prereqs
ae9cb412 175apt-get install -y libconfig-simple-perl libgit-repository-perl libdate-manip-perl
ee1de43f
JD
176
177# 12. paper overdue prereqs
ae9cb412 178apt-get install -y python-reportlab python-reportlab-accel