2 # -----------------------------------------------------------------------
3 # Copyright (C) 2009-2012 Equinox Software Inc.
4 # Bill Erickson <berick@esilibrary.com>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 # -----------------------------------------------------------------------
21 export PATH=/openils/bin:$PATH
22 export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH
24 # -----------------------------------------------------------------------
26 # -----------------------------------------------------------------------
27 # If you change the jabber password, you will need to
28 # edit opensrf_core.xml and srfsh.xml accordingly
29 JABBER_PASSWORD='password'
32 # -----------------------------------------------------------------------
34 # -----------------------------------------------------------------------
35 # Handling passed arguments to the script
36 # -----------------------------------------------------------------------
37 while getopts ayst option
43 s) SAMPLEDATA=--load-all-sample;;
48 # -----------------------------------------------------------------------
49 # force CPAN to load by installing something that should already be installed
56 # CPAN follow pre-reqs?
57 if [ ! "$(echo 'o conf prerequisites_policy' | cpan | grep follow)" ]; then
60 echo "setting cpan prerequisites_policy to follow"
61 echo -e "o conf prerequisites_policy follow\\n o conf commit" | cpan
67 -----------------------------------------------------------------------
68 The install will go faster if CPAN is configured to automatically install
69 prerequisites. You can revert the action later with:
71 echo -e "o conf prerequisites_policy ask\n o conf commit" | cpan
74 echo -n 'Automatically install prereqs? [Y/n] ';
76 [ "$X" == 'n' -o "$X" == "N" ] && break;
77 if [ "$X" == 'y' -o "$X" == 'Y' ]; then
78 echo -e "o conf prerequisites_policy follow\\n o conf commit" | cpan
85 # -----------------------------------------------------------------------
90 # Install some essential tools
92 apt-get -yq dist-upgrade;
93 apt-get -yq install build-essential automake git psmisc ntp rsyslog;
95 if [ $LIVETEST ]; then
96 cpan TAP::Parser::SourceHandler::pgTAP
99 cp $BASE_DIR/evergreen.ld.conf /etc/ld.so.conf.d/
102 # Create opensrf user and set up environment
103 if [ ! "$(grep ^opensrf: /etc/passwd)" ]; then
104 useradd -m -s /bin/bash opensrf
105 echo 'export PATH=/openils/bin:$PATH' >> /home/opensrf/.bashrc
106 echo 'export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH' >> /home/opensrf/.bashrc
109 # XXX for now, fetch the debian-wheezy install target working branches and merge in master
110 # You can override these like so: EVERGREEN_BRANCH='master' ./eg_wheezy_installer.sh
111 OPENSRF_REPO='git://git.evergreen-ils.org/OpenSRF.git'
112 OPENSRF_BRANCH='master'
113 #EVERGREEN_REPO='git://git.evergreen-ils.org/working/Evergreen.git'
114 #EVERGREEN_BRANCH='collab/phasefx/qa-integration'
115 EVERGREEN_REPO='git://git.evergreen-ils.org/Evergreen.git'
116 EVERGREEN_BRANCH='master'
119 git clone --depth 0 --branch $OPENSRF_BRANCH $OPENSRF_REPO OpenSRF;
120 git clone --depth 0 --branch $EVERGREEN_BRANCH $EVERGREEN_REPO Evergreen;
122 rm -rf /home/opensrf/Evergreen /home/opensrf/OpenSRF
123 su - opensrf sh -c "$OSRF_COMMAND";
127 cd /home/opensrf/OpenSRF/
128 echo 'Tip of OpenSRF:' `git log --format=oneline | head -1`
129 cd /home/opensrf/Evergreen/
130 echo 'Tip of Evergreen:' `git log --format=oneline | head -1`
133 mkdir -p /usr/src/evergreen;
134 cd /usr/src/evergreen;
136 echo _.-~= Installing OpenSRF pre-requisites
137 yes | make -f /home/opensrf/OpenSRF/src/extras/Makefile.install debian-wheezy
138 echo Return Value = $?
139 echo End of Installing OpenSRF pre-requisites =~-._
140 echo _.-~= Installing Evergreen pre-requisites
141 yes | make -f /home/opensrf/OpenSRF/src/extras/Makefile.install debian-wheezy
142 echo Return Value = $?
143 echo End of Installing Evergreen pre-requisites =~-._
144 echo _.-~= Installing Evergreen database pre-requisites
145 yes | make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install postgres-server-debian-wheezy
146 echo Return Value = $?
147 echo End of Installing Evergreen database pre-requisites =~-._
149 echo _.-~= Installing OpenSRF pre-requisites
150 make -f /home/opensrf/OpenSRF/src/extras/Makefile.install debian-wheezy
151 echo Return Value = $?
152 echo End of Installing OpenSRF pre-requisites =~-._
153 echo _.-~= Installing Evergreen pre-requisites
154 make -f /home/opensrf/OpenSRF/src/extras/Makefile.install debian-wheezy
155 echo Return Value = $?
156 echo End of Installing Evergreen pre-requisites =~-._
157 echo _.-~= Installing Evergreen database pre-requisites
158 make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install postgres-server-debian-wheezy
159 echo Return Value = $?
160 echo End of Installing Evergreen database pre-requisites =~-._
163 # Configure rsyslog and restart
164 cp /home/opensrf/Evergreen/Open-ILS/examples/evergreen-rsyslog.conf /etc/rsyslog.d/evergreen.conf
165 /etc/init.d/rsyslog restart
168 # Patch Ejabberd and register users
169 if [ ! "$(grep 'public.localhost' /etc/ejabberd/ejabberd.cfg)" ]; then
171 /etc/init.d/ejabberd stop;
172 killall beam epmd; # just in case
173 cp ejabberd.cfg /root/ejabberd.cfg.orig
174 patch -p0 < $BASE_DIR/ejabberd.EG.patch
175 chown ejabberd:ejabberd ejabberd.cfg
176 /etc/init.d/ejabberd start
178 ejabberdctl register router private.localhost $JABBER_PASSWORD
179 ejabberdctl register opensrf private.localhost $JABBER_PASSWORD
180 ejabberdctl register router public.localhost $JABBER_PASSWORD
181 ejabberdctl register opensrf public.localhost $JABBER_PASSWORD
186 # Build and install OpenSRF
188 cd /home/opensrf/OpenSRF;
190 ./configure --prefix=/openils --sysconfdir=/openils/conf;
193 echo _.-~= Building OpenSRF
194 su - opensrf sh -c "$OSRF_COMMAND"
195 echo Return Value = $?
196 echo End of Building OpenSRF =~-._
197 cd /home/opensrf/OpenSRF;
198 echo _.-~= Running OpenSRF build tests
200 echo Return Value = $?
201 echo End of OpenSRF build tests =~-._
204 # Build and install the ILS
206 export PATH=/openils/bin:$PATH
207 cd /home/opensrf/Evergreen;
209 ./configure --prefix=/openils --sysconfdir=/openils/conf;
213 echo _.-~= Building Evergreen
214 su - opensrf sh -c "$OSRF_COMMAND"
215 echo Return Value = $?
216 echo End of Building Evergreen =~-._
217 cd /home/opensrf/Evergreen
218 echo _.-~= Running Evergreen build tests
220 echo Return Value = $?
221 echo End of Evergreen build tests =~-._
225 cp /openils/conf/opensrf.xml.example /openils/conf/opensrf.xml
226 cp /openils/conf/opensrf_core.xml.example /openils/conf/opensrf_core.xml
228 # fetch and install Dojo
230 wget -N "http://download.dojotoolkit.org/release-$DOJO_VERSION/dojo-release-$DOJO_VERSION.tar.gz";
231 tar -zxf dojo-release-$DOJO_VERSION.tar.gz;
232 cp -r dojo-release-$DOJO_VERSION/* /openils/var/web/js/dojo/;
234 # give it all to opensrf
235 chown -R opensrf:opensrf /openils
237 # copy srfsh config into place
238 cp /openils/conf/srfsh.xml.example /home/opensrf/.srfsh.xml;
239 chown opensrf:opensrf /home/opensrf/.srfsh.xml;
242 echo "Using password evergreen for the evergreen database user."
243 echo -e "evergreen\nevergreen\n" | su - postgres sh -c 'createuser -P -s evergreen;'
245 echo -e "\n\nPlease enter a password for the evergreen database user.\n If you do not want to edit configs, use \"evergreen\"\n"
246 su - postgres sh -c 'createuser -P -s evergreen;'
249 # Apply the DB schema
250 cd /home/opensrf/Evergreen
251 perl Open-ILS/src/support-scripts/eg_db_config \
255 --update-config $SAMPLEDATA \
258 --password evergreen \
259 --hostname localhost \
260 --database evergreen \
261 --admin-user $ADMIN_USER \
262 --admin-pass $ADMIN_PASS;
264 if [ $LIVETEST ]; then
266 git clone --depth 0 https://github.com/theory/pgtap.git \
271 su - postgres -c "$PG_CMD"
272 cd /var/lib/postgresql/pgtap \
274 echo 'CREATE EXTENSION pgtap;' | su - postgres -c "psql evergreen"
277 # Copy apache configs into place and create SSL cert
278 cd /home/opensrf/Evergreen/
279 cp Open-ILS/examples/apache/eg.conf /etc/apache2/sites-available/
280 cp Open-ILS/examples/apache/eg_vhost.conf /etc/apache2/
281 cp Open-ILS/examples/apache/eg_startup /etc/apache2/
283 mkdir -p /etc/apache2/ssl;
284 if [ ! -f /etc/apache2/ssl/server.key ] ; then
285 echo -e "\n\nConfiguring a new temporary SSL certificate....\n";
287 yes "" | openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key
289 openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key
292 echo -e "\nkeeping existing ssl/server.key file\n";
298 a2dissite 000-default
301 if [ ! "$(grep 'public.localhost' /etc/hosts)" ]; then
304 echo 'Adding public.localhost and private.localhost to /etc/hosts'
305 echo '127.0.1.2 public.localhost public' >> /etc/hosts
306 echo '127.0.1.3 private.localhost private' >> /etc/hosts
311 * Add these lines to /etc/hosts.
313 127.0.1.2 public.localhost public
314 127.0.1.3 private.localhost private
320 echo "INFO: /etc/hosts already has public.localhost line";
323 if [ $AUTOSTART ]; then
325 if [ $LIVETEST ]; then
326 rm /openils/var/log/*.log
330 export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH \
331 && export PATH=/openils/bin:$PATH \
332 && OSRF_HOSTNAME="dns_hack" /openils/bin/osrf_control --localhost --stop_all && sleep 3 \
333 && OSRF_HOSTNAME="dns_hack" /openils/bin/osrf_control --localhost --start_all && sleep 3 \
334 && /openils/bin/autogen.sh /openils/conf/opensrf_core.xml \
337 echo Starting services...
338 su - opensrf sh -c "$OSRF_COMMAND";
340 echo Modifying APACHE_RUN_USER/APACHE_RUN_GROUP in /etc/apache2/envvars
341 sed -i 's/www-data/opensrf/g' /etc/apache2/envvars
343 echo Making sure /var/lock/apache2 is owned by opensrf
344 chown opensrf:opensrf /var/lock/apache2
346 echo Modifying KeepAliveTimeout in /etc/apache2/apache2.conf
347 sed -i 's/KeepAliveTimeout .*/KeepAliveTimeout 1/' /etc/apache2/apache2.conf
349 echo Restarting Apache
350 /etc/init.d/apache2 restart
352 if [ $LIVETEST ]; then
353 # TODO: Eventually move these tests into a Make target within Evergreen
354 cd /home/opensrf/Evergreen
355 echo _.-~= Running pgTAP tests
356 su - postgres -c 'cd /home/opensrf/Evergreen ; pg_prove -vr -d evergreen Open-ILS/src/sql/Pg/t/ ; echo Return Value = $?'
357 echo End of pgTAP tests =~-._
358 echo _.-~= Running settings-tester.pl
359 echo _.-~= Running pgTAP live tests
360 su - postgres -c 'cd /home/opensrf/Evergreen ; pg_prove -vr -d evergreen Open-ILS/src/sql/Pg/live_t/ ; echo Return Value = $?'
361 echo End of pgTAP live tests =~-._
362 echo _.-~= Running settings-tester.pl
363 su - opensrf sh -c 'export PATH=/openils/bin:$PATH ; cd /home/opensrf/Evergreen/Open-ILS/src/support-scripts/ ; ./settings-tester.pl ; echo Return Value = $?'
364 echo End of settings-tester.pl output =~-._
365 echo _.-~= Running perl live tests
366 su - opensrf sh -c 'export PATH=/openils/bin:$PATH ; cd /home/opensrf/Evergreen/Open-ILS/src/perlmods/ ; make livecheck; echo Return Value = $?'
367 echo End of perl live tests =~-._
368 echo _.-~= Gathering log summary
371 su - opensrf sh -c 'cd /openils/var/log/ ; wc -l *.log'
374 su - opensrf sh -c 'cd /openils/var/log/ ; du -sh *.log'
376 echo 'perl -ne ''if (/^\[.*?\] (.*?) \[/) { print "$1\n"; }'' osrfsys.log | sort | uniq -c | sort -k2:'
377 (cd /openils/var/log/ ; perl -ne 'if (/^\[.*?\] (.*?) \[/) { print "$1\n"; }' osrfsys.log | sort | uniq -c | sort -k2)
379 echo End of log summary =~-._
380 echo _.-~= Gathering system information
385 echo 'select version();' | su - postgres -c 'psql -At'
387 echo '/proc/meminfo:'
390 echo '/proc/cpuinfo:'
398 echo End of system information =~-._
405 echo "request open-ils.cstore open-ils.cstore.direct.actor.user.retrieve 1" | srfsh
415 osrf_control --localhost --start-all && sleep 3;
416 /openils/bin/autogen.sh /openils/conf/opensrf_core.xml;
421 echo "request open-ils.cstore open-ils.cstore.direct.actor.user.retrieve 1" | srfsh
423 * Now finish configuring Apache
425 1. s/www-data/opensrf/g in envvars
426 2. KeepAliveTimeout 1 in apache2.conf