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