EG install scripts: production branches
[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"
fae89064 11BRANCH="production/sitka_2_8_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"
fae89064 16SITKACONF_BRANCH="master"
341cf34e 17SITKATOOLS="/root/sitka-tools"
0155bbac 18
e724d7db 19suwrap() {
e2ad4781 20 su -s /bin/bash -c "source ~/.bashrc ; $1" $2
e724d7db
JD
21}
22
24057702
JD
23while getopts ":p" opt ; do
24 case $opt in
25 p ) PROD="prod";;
f3b555fc 26 e ) EDI="edi";;
24057702
JD
27 esac
28done
29shift $(($OPTIND - 1))
30
31if [[ -n "$PROD" ]] ; then
32 echo 'this is a production install'
33else
34 echo 'this is NOT a production install'
35fi
36
0155bbac
JD
37# as DEFAULT_USER
38
39# grab Sitka config files
40if [ ! -d "${SITKACONF}" ]
41then
42 # this will fail unless DEFAULT_USER has read access to the repo
e724d7db 43 suwrap "cd ${HOMEDIR} && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" ${DEFAULT_USER}
0155bbac 44fi
902a19b7 45suwrap "cd ${SITKACONF} && git fetch origin && git checkout ${SITKACONF_BRANCH} && git pull" ${DEFAULT_USER}
0155bbac
JD
46
47# checkout EG source
ae9cb412
JD
48if [ ! -d "${BUILDDIR}" ]
49then
50 suwrap "cd ${HOMEDIR} && git clone git://git.sitka.bclibraries.ca/sitka/evergreen evergreen" ${DEFAULT_USER}
51fi
52suwrap "cd ${BUILDDIR} && git fetch origin && git checkout ${BRANCH} && git pull" ${DEFAULT_USER}
71f85432
JD
53
54# download and unpack EG release
ae9cb412
JD
55#rm -rf ${BUILDDIR}
56#suwrap "cd ${HOMEDIR} && wget http://open-ils.org/downloads/${EGRELEASE}.tar.gz && tar xzf ${EGRELEASE}.tar.gz" ${DEFAULT_USER}
0155bbac
JD
57
58# as root
71f85432 59cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-trusty
4115cc36 60#cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-trusty-developer # required for web client
0155bbac
JD
61# by default, CPAN needs some manual input at this point; you can just accept all defaults
62
63# as DEFAULT_USER
ae9cb412 64suwrap "cd ${BUILDDIR} && autoreconf -i" ${DEFAULT_USER} # not required for release versions
fd31984b 65suwrap "cd ${BUILDDIR} && ./configure -C --prefix=${INSTALLDIR} --sysconfdir=${INSTALLDIR}/conf --with-opensrf-headers=${INSTALLDIR}/include/ --with-opensrf-libs=${INSTALLDIR}/lib/" ${DEFAULT_USER}
e724d7db 66suwrap "cd ${BUILDDIR} && make" ${DEFAULT_USER}
691245a2 67suwrap "cd ${BUILDDIR}/build/i18n && make LOCALE=fr-CA install && make LOCALE=en-CA install" ${DEFAULT_USER}
0155bbac
JD
68
69# as root
4115cc36 70cd ${BUILDDIR} && make STAFF_CLIENT_VERSION=${VERSION} STAFF_CLIENT_STAMP_ID=${STAMP_ID} install
ae9cb412 71mv ${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
72chown -R opensrf:opensrf ${INSTALLDIR}
73
74# Apache stuff (as root):
661d99f4 75APACHEFILES="/etc/apache2/eg_vhost.conf /etc/apache2/eg_startup /etc/apache2/sites-available/eg.conf /etc/apache2/envvars"
0155bbac
JD
76for APACHEFILE in ${APACHEFILES}
77do
bd41f68d 78 mv ${APACHEFILE} ${APACHEFILE}.bak
0155bbac
JD
79 cp ${SITKACONF}/files/${APACHEFILE}/${HOSTNAME} ${APACHEFILE}
80done
ae9cb412
JD
81#a2dissite 000-default
82#a2ensite eg.conf
83#if [ ! -d "/etc/apache2/ssl" ]
84#then
85# mkdir /etc/apache2/ssl
86# cd /etc/apache2/ssl && openssl req -new -x509 -days 365 -nodes -out server.crt -keyout server.key
87#fi
71f85432
JD
88# ensure opensrf can run Apache
89chown -R opensrf:opensrf /var/lock/apache2
7d30f3bf 90
26b3ea66 91# set up log rotation
702f0bd2
JD
92if [[ ! -n "$PROD" ]] ; then
93 if [ ! -f "/etc/logrotate.d/evergreen" ]
94 then
95 cp ${SITKACONF}/files/etc/logrotate.d/evergreen/${HOSTNAME} /etc/logrotate.d/evergreen
96 fi
26b3ea66 97fi
0155bbac 98
0155bbac
JD
99# 0. osrf conf stuff
100# FIXME: ensure osrf conf files point at a real, distinct db!
101OSRFCONFFILES="${INSTALLDIR}/conf/opensrf.xml ${INSTALLDIR}/conf/opensrf_core.xml"
102for OSRFCONFFILE in ${OSRFCONFFILES}
103do
51a4755a 104 mv ${OSRFCONFFILE} ${OSRFCONFFILE}.bak
0155bbac
JD
105 cp ${SITKACONF}/files/${OSRFCONFFILE}/${HOSTNAME} ${OSRFCONFFILE}
106done
661d99f4 107if [ ! -f "/home/opensrf/.srfsh.xml" ]
9d46f12d 108then
661d99f4 109 cp ${SITKACONF}/files/home/opensrf/.srfsh.xml/${HOSTNAME} /home/opensrf/.srfsh.xml
9d46f12d
JD
110fi
111
0155bbac 112# 1. install dojo
abcafeff 113if [ ! -f "/home/opensrf/dojo-release-1.3.3.tar.gz" ]
51a4755a
JD
114then
115 cd /home/opensrf && wget http://download.dojotoolkit.org/release-1.3.3/dojo-release-1.3.3.tar.gz
116fi
0155bbac
JD
117tar -C ${INSTALLDIR}/var/web/js -xzf /home/opensrf/dojo-release-1.3.3.tar.gz
118cp -r ${INSTALLDIR}/var/web/js/dojo-release-1.3.3/* ${INSTALLDIR}/var/web/js/dojo/.
119
120# 2. set up staff client
9d46f12d 121cd ${INSTALLDIR}/var/web/xul && rm server && rm current
0155bbac 122cd ${INSTALLDIR}/var/web/xul && ln -s ${STAMP_ID} current && ln -s current/server server
03b5e41f
JD
123for ALT_STAMP_ID in ${ALT_STAMP_IDS}
124do
125 cd ${INSTALLDIR}/var/web/xul && ln -s current ${ALT_STAMP_ID}
126done
0155bbac 127
9d46f12d 128# 3. install circ scripts and opac skins - DEPRECATED
71f85432 129
96b76bbb
JD
130# 4a. avoid 404s
131touch ${INSTALLDIR}/var/web/css/skin/default/register_custom.css
132touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/patron_custom.properties
133touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/common_custom.properties
134touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/offline_custom.properties
135touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/auth_custom.properties
136touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/cat_custom.properties
137touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/circ_custom.properties
138touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/patron_custom.properties
139touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/common_custom.properties
140touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/offline_custom.properties
141touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/auth_custom.properties
142touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/cat_custom.properties
143touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/circ_custom.properties
144touch ${INSTALLDIR}/var/web/xul/server/skin/custom.js
145
146# 4b. workaround for LP#1461683
147cd ${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
148
149# 5. locale hack - XXX deprecated?
150#cd ${INSTALLDIR}/var/web/opac/locale && cp -fdr en-US en-US-bak && cp -fdr en-CA en-US
0155bbac
JD
151
152# 6. deletepatron
153# ensure apache conf contains deletepatron config (location should be ${INSTALLDIR}/var/web/deletepatron)
437b75c1
JD
154if [[ ! -d "${INSTALLDIR}/var/web/deletepatron" ]] ; then
155 NEW_DELETEPATRON_INSTALL="true"
156 cd ${INSTALLDIR}/var/web && git clone https://github.com/twirlip/deletepatron.git
157fi
158cd ${INSTALLDIR}/var/web/deletepatron && git checkout eg22
159if [[ -n "$NEW_DELETEPATRON_INSTALL" ]] ; then
160 find ${INSTALLDIR}/var/web/deletepatron -name "*.pm" | xargs sed -i -e 's|/openils|/srv/openils|g'
161fi
ae9cb412 162apt-get install -y libcgi-session-perl libhtml-template-perl
0155bbac 163
f3b555fc
JD
164# 7. support scripts
165cp ${BUILDDIR}/Open-ILS/src/support-scripts/generate_circ_notices.pl ${INSTALLDIR}/bin
166
167# 7.5 EDI (optional)
168if [[ -n "$EDI" ]] ; then
169 cp -r ${BUILDDIR}/Open-ILS/src/edi_translator ${INSTALLDIR}/var/edi
170 cd ${INSTALLDIR}/var/edi && ./install.sh
171 cp ${BUILDDIR}/Open-ILS/src/support-scripts/edi_pusher.pl ${INSTALLDIR}/bin
172 cp ${BUILDDIR}/Open-ILS/src/support-scripts/edi_fetcher.pl ${INSTALLDIR}/bin
173 cp ${SYSADMIN}/files/${INSTALLDIR}/bin/edi_per_account_fetcher.sh ${INSTALLDIR}/bin/edi_per_account_fetcher.sh
174fi
0155bbac 175
c05e3516
JD
176# 8. setup start page
177if [ ! -d "${INSTALLDIR}/var/web/news" ]
178then
179 mkdir ${INSTALLDIR}/var/web/news
180fi
24057702
JD
181if [ ! -d "${INSTALLDIR}/var/web/news/media" ]
182then
183 mkdir ${INSTALLDIR}/var/web/news/media
184fi
185NEWSFILES="index.html style.css media/logo.png media/book.png media/policy.png media/dash.png media/delete.png"
c05e3516
JD
186for NEWSFILE in ${NEWSFILES}
187do
188 if [ -f "${SITKACONF}/files/${INSTALLDIR}/var/web/news/${NEWSFILE}/${HOSTNAME}" ]
189 then
190 cp ${SITKACONF}/files/${INSTALLDIR}/var/web/news/${NEWSFILE}/${HOSTNAME} ${INSTALLDIR}/var/web/news/${NEWSFILE}
191 fi
192done
24057702
JD
193if [[ -n "$PROD" ]] ; then
194 if [ ! -e "${INSTALLDIR}/var/web/news/wikipull.pl" ] ; then cp ${SITKACONF}/files/${INSTALLDIR}/var/web/news/wikipull.pl/${HOSTNAME} ${INSTALLDIR}/var/web/news/wikipull.pl ; fi
195 if [ ! -e "/etc/cron.d/news" ] ; then cp ${SITKACONF}/files/etc/cron.d/news/${HOSTNAME} /etc/cron.d/news ; fi
196fi
c05e3516 197
341cf34e 198# 8.5 offline patron list
24057702
JD
199if [ ! -d "${INSTALLDIR}/var/data/offline/blocked" ] ; then
200 # TODO: handle prod - an NFS share should exist
201 if [[ ! -n "$PROD" ]] ; then
202 mkdir -p ${INSTALLDIR}/var/data/offline/blocked
203 fi
204fi
437b75c1 205if [ ! -e "${INSTALLDIR}/var/web/standalone/list.txt" ] ; then ln -sf ${INSTALLDIR}/var/data/offline/blocked/patron-block-list.txt ${INSTALLDIR}/var/web/standalone/list.txt ; fi
341cf34e
JD
206if [ ! -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
207
f37d71da 208cp ${SITKACONF}/files${INSTALLDIR}/var/data/zips.txt/${HOSTNAME} ${INSTALLDIR}/var/data/zips.txt
661d99f4 209
02bd66d5
JD
210cp -r ${SITKATOOLS}/overdrive-eg-opac/build/* ${INSTALLDIR}/var/web/js/ui/default/opac
211ODAPI_LIBS="bc mb"
212for ODAPI_LIB in ${ODAPI_LIBS} ; do
d8761dca 213 cp ${SITKACONF}/files/${INSTALLDIR}/var/web/js/ui/default/opac/${ODAPI_LIB}/od_config.js ${INSTALLDIR}/var/web/js/ui/default/opac/${ODAPI_LIB}/od_config.js
02bd66d5
JD
214done
215
c05e3516 216# 9. make sure opensrf owns all the stuff we just did
0155bbac 217chown -R opensrf:opensrf ${INSTALLDIR}
d4e88b8a 218chown -R opensrf:opensrf /home/opensrf
7f126d3b
JD
219SKINDIRS="${INSTALLDIR}/var/skins ${INSTALLDIR}/var/web/css/skin"
220for SKINDIR in ${SKINDIRS} ; do
221 if [[ ! -d "${SKINDIR}" ]] ; then mkdir ${SKINDIR} ; fi
222 chmod 777 ${SKINDIR}
223 chown -R sitkastaff:sitkastaff ${SKINDIR}
224done
0155bbac 225
d4e88b8a 226# 10. staff client stuff
ae9cb412 227apt-get install -y nsis unzip
089f11fb
JD
228
229# 11. integrity checker prereqs
ae9cb412 230apt-get install -y libconfig-simple-perl libgit-repository-perl libdate-manip-perl
ee1de43f
JD
231
232# 12. paper overdue prereqs
ae9cb412 233apt-get install -y python-reportlab python-reportlab-accel