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