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