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