Update install scripts for EG 2.4.0 and OpenSRF 2.2.0
[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
4HOSTNAME="nonprod"
5DEFAULT_USER="sitkastaff"
6HOMEDIR="/home/${DEFAULT_USER}"
7BUILDDIR="${HOMEDIR}/evergreen"
8INSTALLDIR="/srv/openils"
d4e88b8a
JD
9BRANCH="user/jeffdavis/sitka-24-beta1"
10VERSION="2.4.0.sitka.0"
11STAMP_ID="2_4_0_sitka_0"
12ALT_STAMP_IDS="rel_2_4_0_sitka_0 2_4_0_sitka_0 rel_2_4_0_sitka_0"
0155bbac
JD
13SITKACONF="${HOMEDIR}/sysadmin"
14DEPLOYDIR="/home/opensrf/deploy"
15OPACSKIN="${DEPLOYDIR}/opacskin"
16OILSPOLICY="${DEPLOYDIR}/oilspolicy"
d4e88b8a 17TPACS="${DEPLOYDIR}/deploykit"
0155bbac
JD
18
19# as DEFAULT_USER
20
21# grab Sitka config files
22if [ ! -d "${SITKACONF}" ]
23then
24 # this will fail unless DEFAULT_USER has read access to the repo
25 su -l -c "cd ${HOMEDIR} && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" ${DEFAULT_USER}
26fi
27su -l -c "cd ${SITKACONF} && git pull" ${DEFAULT_USER}
28
29# checkout EG source
30if [ ! -d "${BUILDDIR}" ]
31then
32 su -l -c "cd ${HOMEDIR} && git clone git://git.sitka.bclibraries.ca/sitka/evergreen evergreen" ${DEFAULT_USER}
33fi
34su -l -c "cd ${BUILDDIR} && git checkout ${BRANCH}" ${DEFAULT_USER}
35
36# as root
37cd ${BUILDDIR} && make -f Open-ILS/src/extras/Makefile.install ubuntu-precise
38# by default, CPAN needs some manual input at this point; you can just accept all defaults
39
40# as DEFAULT_USER
41su -l -c "cd ${BUILDDIR} && autoreconf -i" ${DEFAULT_USER}
d4e88b8a 42su -s /bin/bash -l -c "cd ${BUILDDIR} && ./configure -C --prefix=${INSTALLDIR} --sysconfdir=${INSTALLDIR}/conf --with-opensrf-headers=${INSTALLDIR}/include/ --with-opensrf-libs=${INSTALLDIR}/lib/ --with-dbi=/usr/lib/dbd/" ${DEFAULT_USER}
0155bbac
JD
43su -l -c "cd ${BUILDDIR} && make" ${DEFAULT_USER}
44su -l -c "cd ${BUILDDIR}/build/i18n && make install_all_locales" ${DEFAULT_USER}
45
46# as root
47cd ${BUILDDIR} && make STAFF_CLIENT_STAMP_ID=${STAMP_ID} STAFF_CLIENT_VERSION=${VERSION} install
48chown -R opensrf:opensrf ${INSTALLDIR}
49
50# Apache stuff (as root):
5f2a96f2 51APACHEFILES="/etc/apache2/eg_vhost.conf /etc/apache2/startup.pl /etc/apache2/sites-available/eg.conf /etc/apache2/envvars"
0155bbac
JD
52for APACHEFILE in ${APACHEFILES}
53do
54 cp ${SITKACONF}/files/${APACHEFILE}/${HOSTNAME} ${APACHEFILE}
55done
56a2dissite default
57a2ensite eg.conf
58mkdir /etc/apache2/ssl
59cd /etc/apache2/ssl && openssl req -new -x509 -days 365 -nodes -out server.crt -keyout server.key
60
61# TODO: set up log rotation
62
63# as opensrf
64
65# 0. osrf conf stuff
66# FIXME: ensure osrf conf files point at a real, distinct db!
67OSRFCONFFILES="${INSTALLDIR}/conf/opensrf.xml ${INSTALLDIR}/conf/opensrf_core.xml"
68for OSRFCONFFILE in ${OSRFCONFFILES}
69do
70 cp ${SITKACONF}/files/${OSRFCONFFILE}/${HOSTNAME} ${OSRFCONFFILE}
71done
72cp ${SITKACONF}/files/home/opensrf/.srfsh.xml/${HOSTNAME} ${HOMEDIR}/.srfsh.xml
73
74# 1. install dojo
75cd /home/opensrf && wget http://download.dojotoolkit.org/release-1.3.3/dojo-release-1.3.3.tar.gz
76tar -C ${INSTALLDIR}/var/web/js -xzf /home/opensrf/dojo-release-1.3.3.tar.gz
77cp -r ${INSTALLDIR}/var/web/js/dojo-release-1.3.3/* ${INSTALLDIR}/var/web/js/dojo/.
78
79# 2. set up staff client
80cd ${INSTALLDIR}/var/web/xul && ln -s ${STAMP_ID} current && ln -s current/server server
81for ALT_STAMP_ID in ${ALT_STAMP_IDS}
82do
83 cd ${INSTALLDIR}/var/web/xul && ln -s current ${ALT_STAMP_ID}
84done
85
86# 3. install circ scripts and opac skins
87
88# (a) setup deploy directory
89if [ ! -d "${DEPLOYDIR}" ]
90then
91 mkdir ${DEPLOYDIR}
92fi
93
94# (b) bclibraries skin
95if [ ! -d "${OPACSKIN}" ]
96then
97 cd ${DEPLOYDIR} && git clone git://git.sitka.bclibraries.ca/sitka/opacskin.git
98fi
d64cdadb 99cd ${OPACSKIN} && git checkout -b bclibraries && \
0155bbac 100 cd ${INSTALLDIR}/var/web/opac/skin && mv default orig-default && \
d64cdadb 101 rsync -a --exclude=.git ${OPACSKIN} ${INSTALLDIR}/var/web/opac/skin/bclibraries && \
0155bbac
JD
102 ln -s ${INSTALLDIR}/var/web/opac/skin/bclibraries ${INSTALLDIR}/var/web/opac/skin/default
103
d4e88b8a
JD
104# (c) TPAC stuff
105apt-get install rake erubis ruby-git
106if [ ! -d "${TPACS}" ]; then
107 cd ${DEPLOYDIR} && git clone git://git.sitka.bclibraries.ca/sitka/deploykit.git
108fi
109cd ${TPACS} && git pull
110cd ${TPACS}/deploykit && mv config.yml.sample config.yml
111if [ ! -d "/etc/apache2/includes" ]; then
112 mkdir /etc/apache2/includes
113fi
114if [ ! -d "/srv/openils/var/skins" ]; then
115 mkdir /srv/openils/var/skins
116fi
117# TODO: use rake to build AND deploy properly!
118#cd ${TPACS}/deploykit && rake tpac:all && \
119# for TPACSKIN in `ls -1 ${TPACS}/deploykit/build`; do mkdir -p /srv/openils/var/skins/${TPACSKIN}/opac && \
120# cp -r build/${TPACSKIN}/templates/opac/* /srv/openils/var/skins/${TPACSKIN}/opac/ && \
121# cp ${TPACS}/build/${TPACSKIN}/apache2/${TPACSKIN}.conf /etc/apache2/sites-available/ && \
122# cp ${TPACS}/build/${TPACSKIN}/apache2/${TPACSKIN}.conf-include /etc/apache2/includes/ ; done
123
124# (d) circ scripts
0155bbac
JD
125if [ ! -d "${OILSPOLICY}" ]
126then
127 cd ${DEPLOYDIR} && git clone git://git.sitka.bclibraries.ca/sitka/oilspolicy.git
128fi
129cd ${OILSPOLICY} && git pull && rsync -a --exclude=.git ${OILSPOLICY} ${INSTALLDIR}/var
130
131# 4. avoid 404s
132touch ${INSTALLDIR}/var/web/css/skin/default/register_custom.css
133touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/patron_custom.properties
134touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/common_custom.properties
135touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/offline_custom.properties
136touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/auth_custom.properties
137touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/cat_custom.properties
138touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/circ_custom.properties
139touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/patron_custom.properties
140touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/common_custom.properties
141touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/offline_custom.properties
142touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/auth_custom.properties
143touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/cat_custom.properties
144touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/circ_custom.properties
145touch ${INSTALLDIR}/var/web/xul/server/skin/custom.js
146
147# 5. locale hack
148cd ${INSTALLDIR}/var/web/opac/locale && cp -fdr en-US en-US-bak && cp -fdr en-CA en-US
149
150# 6. deletepatron
151# ensure apache conf contains deletepatron config (location should be ${INSTALLDIR}/var/web/deletepatron)
152cd ${INSTALLDIR}/var/web && git clone https://github.com/twirlip/deletepatron.git
153cd ${INSTALLDIR}/var/web/deletepatron && git checkout eg22 && find . -name *.pm | xargs sed -i -e 's|/openils|/srv/openils|g'
6113c87e 154apt-get install libcgi-session-perl libhtml-template-perl
0155bbac
JD
155
156# 7. support scripts
157cp ${BUILDDIR}/Open-ILS/src/support-scripts/generate_circ_notices.pl ${INSTALLDIR}/bin
158cp ${BUILDDIR}/Open-ILS/src/support-scripts/oils_header.pl ${INSTALLDIR}/bin
159
c05e3516
JD
160# 8. setup start page
161if [ ! -d "${INSTALLDIR}/var/web/news" ]
162then
163 mkdir ${INSTALLDIR}/var/web/news
164fi
165NEWSFILES="index.html style.css"
166for NEWSFILE in ${NEWSFILES}
167do
168 if [ -f "${SITKACONF}/files/${INSTALLDIR}/var/web/news/${NEWSFILE}/${HOSTNAME}" ]
169 then
170 cp ${SITKACONF}/files/${INSTALLDIR}/var/web/news/${NEWSFILE}/${HOSTNAME} ${INSTALLDIR}/var/web/news/${NEWSFILE}
171 fi
172done
173
174# 9. make sure opensrf owns all the stuff we just did
0155bbac 175chown -R opensrf:opensrf ${INSTALLDIR}
d4e88b8a
JD
176chown -R opensrf:opensrf /home/opensrf
177chown -R opensrf:opensrf /var/lock/apache2
0155bbac 178
d4e88b8a
JD
179# 10. staff client stuff
180apt-get install nsis unzip