install-eg.sh: install Sitka's version of 2.6.1 from git
[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
bd41f68d 4HOSTNAME="nonprod-26"
0155bbac
JD
5DEFAULT_USER="sitkastaff"
6HOMEDIR="/home/${DEFAULT_USER}"
03b5e41f 7BUILDDIR="${HOMEDIR}/evergreen"
0155bbac 8INSTALLDIR="/srv/openils"
bd41f68d
JD
9BRANCH="upgrade/eg26/beta1-tpac"
10VERSION="2.6.0.sitka.0"
11STAMP_ID="2_6_0_sitka_0"
12ALT_STAMP_IDS="rel_2_6_0_sitka_0"
0155bbac 13SITKACONF="${HOMEDIR}/sysadmin"
0155bbac 14
e724d7db
JD
15suwrap() {
16 su -s /bin/bash -l -c "source ~/.bashrc ; $1" $2
17}
18
0155bbac
JD
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
e724d7db 25 suwrap "cd ${HOMEDIR} && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" ${DEFAULT_USER}
0155bbac 26fi
e724d7db 27suwrap "cd ${SITKACONF} && git pull" ${DEFAULT_USER}
0155bbac
JD
28
29# checkout EG source
30if [ ! -d "${BUILDDIR}" ]
31then
03b5e41f 32 suwrap "cd ${HOMEDIR} && git clone git://git.sitka.bclibraries.ca/sitka/evergreen evergreen" ${DEFAULT_USER}
0155bbac 33fi
03b5e41f 34suwrap "cd ${BUILDDIR} && git fetch origin && git checkout ${BRANCH} && git pull" ${DEFAULT_USER}
0155bbac
JD
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
e724d7db
JD
41suwrap "cd ${BUILDDIR} && autoreconf -i" ${DEFAULT_USER}
42suwrap "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}
43suwrap "cd ${BUILDDIR} && make" ${DEFAULT_USER}
691245a2 44suwrap "cd ${BUILDDIR}/build/i18n && make LOCALE=fr-CA install && make LOCALE=en-CA install" ${DEFAULT_USER}
0155bbac
JD
45
46# as root
03b5e41f 47cd ${BUILDDIR} && make STAFF_CLIENT_STAMP_ID=${STAMP_ID} STAFF_CLIENT_VERSION=${VERSION} install
0155bbac
JD
48chown -R opensrf:opensrf ${INSTALLDIR}
49
50# Apache stuff (as root):
9d46f12d 51APACHEFILES="/etc/apache2/eg_vhost.conf /etc/apache2/eg_startup /etc/apache2/sites-available/eg.conf"
0155bbac
JD
52for APACHEFILE in ${APACHEFILES}
53do
bd41f68d 54 mv ${APACHEFILE} ${APACHEFILE}.bak
0155bbac
JD
55 cp ${SITKACONF}/files/${APACHEFILE}/${HOSTNAME} ${APACHEFILE}
56done
57a2dissite default
9d46f12d 58a2ensite eg.conf
51a4755a
JD
59if [ ! -d "/etc/apache2/ssl" ]
60then
61 mkdir /etc/apache2/ssl
62 cd /etc/apache2/ssl && openssl req -new -x509 -days 365 -nodes -out server.crt -keyout server.key
63fi
7d30f3bf 64
26b3ea66 65# set up log rotation
abcafeff 66if [ ! -f "/etc/logrotate.d/evergreen" ]
26b3ea66
JD
67then
68 cp ${SITKACONF}/files/etc/logrotate.d/evergreen/${HOSTNAME} /etc/logrotate.d/evergreen
69fi
0155bbac 70
0155bbac
JD
71# 0. osrf conf stuff
72# FIXME: ensure osrf conf files point at a real, distinct db!
73OSRFCONFFILES="${INSTALLDIR}/conf/opensrf.xml ${INSTALLDIR}/conf/opensrf_core.xml"
74for OSRFCONFFILE in ${OSRFCONFFILES}
75do
51a4755a 76 mv ${OSRFCONFFILE} ${OSRFCONFFILE}.bak
0155bbac
JD
77 cp ${SITKACONF}/files/${OSRFCONFFILE}/${HOSTNAME} ${OSRFCONFFILE}
78done
abcafeff 79if [ ! -f "${HOMEDIR}/.srfsh.xml" ]
9d46f12d
JD
80then
81 cp ${SITKACONF}/files/home/opensrf/.srfsh.xml/${HOSTNAME} ${HOMEDIR}/.srfsh.xml
82fi
83
0155bbac 84# 1. install dojo
abcafeff 85if [ ! -f "/home/opensrf/dojo-release-1.3.3.tar.gz" ]
51a4755a
JD
86then
87 cd /home/opensrf && wget http://download.dojotoolkit.org/release-1.3.3/dojo-release-1.3.3.tar.gz
88fi
0155bbac
JD
89tar -C ${INSTALLDIR}/var/web/js -xzf /home/opensrf/dojo-release-1.3.3.tar.gz
90cp -r ${INSTALLDIR}/var/web/js/dojo-release-1.3.3/* ${INSTALLDIR}/var/web/js/dojo/.
91
92# 2. set up staff client
9d46f12d 93cd ${INSTALLDIR}/var/web/xul && rm server && rm current
0155bbac 94cd ${INSTALLDIR}/var/web/xul && ln -s ${STAMP_ID} current && ln -s current/server server
03b5e41f
JD
95for ALT_STAMP_ID in ${ALT_STAMP_IDS}
96do
97 cd ${INSTALLDIR}/var/web/xul && ln -s current ${ALT_STAMP_ID}
98done
0155bbac 99
9d46f12d 100# 3. install circ scripts and opac skins - DEPRECATED
0155bbac
JD
101
102# 4. avoid 404s
103touch ${INSTALLDIR}/var/web/css/skin/default/register_custom.css
104touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/patron_custom.properties
105touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/common_custom.properties
106touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/offline_custom.properties
107touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/auth_custom.properties
108touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/cat_custom.properties
109touch ${INSTALLDIR}/var/web/xul/server/locale/en-CA/circ_custom.properties
110touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/patron_custom.properties
111touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/common_custom.properties
112touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/offline_custom.properties
113touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/auth_custom.properties
114touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/cat_custom.properties
115touch ${INSTALLDIR}/var/web/xul/server/locale/en-US/circ_custom.properties
116touch ${INSTALLDIR}/var/web/xul/server/skin/custom.js
117
118# 5. locale hack
119cd ${INSTALLDIR}/var/web/opac/locale && cp -fdr en-US en-US-bak && cp -fdr en-CA en-US
120
121# 6. deletepatron
122# ensure apache conf contains deletepatron config (location should be ${INSTALLDIR}/var/web/deletepatron)
123cd ${INSTALLDIR}/var/web && git clone https://github.com/twirlip/deletepatron.git
6f81dddf 124cd ${INSTALLDIR}/var/web/deletepatron && git checkout eg22 && find . -name "*.pm" | xargs sed -i -e 's|/openils|/srv/openils|g'
6113c87e 125apt-get install libcgi-session-perl libhtml-template-perl
0155bbac
JD
126
127# 7. support scripts
128cp ${BUILDDIR}/Open-ILS/src/support-scripts/generate_circ_notices.pl ${INSTALLDIR}/bin
129cp ${BUILDDIR}/Open-ILS/src/support-scripts/oils_header.pl ${INSTALLDIR}/bin
130
c05e3516
JD
131# 8. setup start page
132if [ ! -d "${INSTALLDIR}/var/web/news" ]
133then
134 mkdir ${INSTALLDIR}/var/web/news
135fi
136NEWSFILES="index.html style.css"
137for NEWSFILE in ${NEWSFILES}
138do
139 if [ -f "${SITKACONF}/files/${INSTALLDIR}/var/web/news/${NEWSFILE}/${HOSTNAME}" ]
140 then
141 cp ${SITKACONF}/files/${INSTALLDIR}/var/web/news/${NEWSFILE}/${HOSTNAME} ${INSTALLDIR}/var/web/news/${NEWSFILE}
142 fi
143done
144
145# 9. make sure opensrf owns all the stuff we just did
0155bbac 146chown -R opensrf:opensrf ${INSTALLDIR}
d4e88b8a
JD
147chown -R opensrf:opensrf /home/opensrf
148chown -R opensrf:opensrf /var/lock/apache2
0155bbac 149
d4e88b8a
JD
150# 10. staff client stuff
151apt-get install nsis unzip
089f11fb
JD
152
153# 11. integrity checker prereqs
154apt-get install libconfig-simple-perl libgit-repository-perl libdate-manip-perl