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