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 # -----------------------------------------------------------------------
19 export PATH=/openils/bin:$PATH
20 export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH
22 # -----------------------------------------------------------------------
24 # -----------------------------------------------------------------------
25 # If you change the jabber password, you will need to
26 # edit opensrf_core.xml and srfsh.xml accordingly
27 JABBER_PASSWORD='password'
30 # -----------------------------------------------------------------------
32 # -----------------------------------------------------------------------
33 # Handling passed arguments to the script
34 # -----------------------------------------------------------------------
35 while getopts ayst option
41 s) SAMPLEDATA=--load-all-sample;;
46 # -----------------------------------------------------------------------
47 # force CPAN to load by installing something that should already be installed
54 # CPAN follow pre-reqs?
55 if [ ! "$(echo 'o conf prerequisites_policy' | cpan | grep follow)" ]; then
58 echo "setting cpan prerequisites_policy to follow"
59 echo -e "o conf prerequisites_policy follow\\n o conf commit" | cpan
65 -----------------------------------------------------------------------
66 The install will go faster if CPAN is configured to automatically install
67 prerequisites. You can revert the action later with:
69 echo -e "o conf prerequisites_policy ask\n o conf commit" | cpan
72 echo -n 'Automatically install prereqs? [Y/n] ';
74 [ "$X" == 'n' -o "$X" == "N" ] && break;
75 if [ "$X" == 'y' -o "$X" == 'Y' ]; then
76 echo -e "o conf prerequisites_policy follow\\n o conf commit" | cpan
83 # -----------------------------------------------------------------------
88 # Install some essential tools
90 apt-get -yq dist-upgrade;
91 apt-get -yq install build-essential automake git psmisc ntp rsyslog;
93 if [ $LIVETEST ]; then
94 cpan TAP::Parser::SourceHandler::pgTAP
97 cp $BASE_DIR/evergreen.ld.conf /etc/ld.so.conf.d/
100 # Create opensrf user and set up environment
101 if [ ! "$(grep ^opensrf: /etc/passwd)" ]; then
102 useradd -m -s /bin/bash opensrf
103 echo 'export PATH=/openils/bin:$PATH' >> /home/opensrf/.bashrc
104 echo 'export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH' >> /home/opensrf/.bashrc
107 # XXX for now, fetch the debian-wheezy install target working branches and merge in master
108 # You can override these like so: EVERGREEN_BRANCH='master' ./eg_wheezy_installer.sh
109 OPENSRF_REPO='git://git.evergreen-ils.org/OpenSRF.git'
110 OPENSRF_BRANCH='master'
111 EVERGREEN_REPO='git://git.evergreen-ils.org/working/Evergreen.git'
112 EVERGREEN_BRANCH='collab/phasefx/per-distro-install-makefiles+livetests'
115 git clone --depth 0 --branch $OPENSRF_BRANCH $OPENSRF_REPO OpenSRF;
116 git clone --depth 0 --branch $EVERGREEN_BRANCH $EVERGREEN_REPO Evergreen;
118 rm -rf /home/opensrf/Evergreen /home/opensrf/OpenSRF
119 su - opensrf sh -c "$OSRF_COMMAND";
122 mkdir -p /usr/src/evergreen;
123 cd /usr/src/evergreen;
125 yes | make -f /home/opensrf/OpenSRF/src/extras/Makefile.install debian-wheezy
126 yes | make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install debian-wheezy postgres-server-debian-wheezy
128 make -f /home/opensrf/OpenSRF/src/extras/Makefile.install debian-wheezy
129 make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install debian-wheezy postgres-server-debian-wheezy
132 # Configure rsyslog and restart
133 cp /home/opensrf/Evergreen/Open-ILS/examples/evergreen-rsyslog.conf /etc/rsyslog.d/evergreen.conf
134 /etc/init.d/rsyslog restart
137 # Patch Ejabberd and register users
138 if [ ! "$(grep 'public.localhost' /etc/ejabberd/ejabberd.cfg)" ]; then
140 /etc/init.d/ejabberd stop;
141 killall beam epmd; # just in case
142 cp ejabberd.cfg /root/ejabberd.cfg.orig
143 patch -p0 < $BASE_DIR/ejabberd.EG.patch
144 chown ejabberd:ejabberd ejabberd.cfg
145 /etc/init.d/ejabberd start
147 ejabberdctl register router private.localhost $JABBER_PASSWORD
148 ejabberdctl register opensrf private.localhost $JABBER_PASSWORD
149 ejabberdctl register router public.localhost $JABBER_PASSWORD
150 ejabberdctl register opensrf public.localhost $JABBER_PASSWORD
155 # Build and install OpenSRF
157 cd /home/opensrf/OpenSRF;
159 ./configure --prefix=/openils --sysconfdir=/openils/conf;
162 su - opensrf sh -c "$OSRF_COMMAND"
163 cd /home/opensrf/OpenSRF;
164 echo _.-~= Running OpenSRF build tests
166 echo Return Value = $?
167 echo End of OpenSRF build tests =~-._
170 # Build and install the ILS
172 export PATH=/openils/bin:$PATH
173 cd /home/opensrf/Evergreen;
175 ./configure --prefix=/openils --sysconfdir=/openils/conf;
179 su - opensrf sh -c "$OSRF_COMMAND"
180 cd /home/opensrf/Evergreen
181 echo _.-~= Running Evergreen build tests
183 echo Return Value = $?
184 echo End of Evergreen build tests =~-._
188 cp /openils/conf/opensrf.xml.example /openils/conf/opensrf.xml
189 cp /openils/conf/opensrf_core.xml.example /openils/conf/opensrf_core.xml
191 # fetch and install Dojo
193 wget -N "http://download.dojotoolkit.org/release-$DOJO_VERSION/dojo-release-$DOJO_VERSION.tar.gz";
194 tar -zxf dojo-release-$DOJO_VERSION.tar.gz;
195 cp -r dojo-release-$DOJO_VERSION/* /openils/var/web/js/dojo/;
197 # give it all to opensrf
198 chown -R opensrf:opensrf /openils
200 # copy srfsh config into place
201 cp /openils/conf/srfsh.xml.example /home/opensrf/.srfsh.xml;
202 chown opensrf:opensrf /home/opensrf/.srfsh.xml;
205 echo "Using password evergreen for the evergreen database user."
206 echo -e "evergreen\nevergreen\n" | su - postgres sh -c 'createuser -P -s evergreen;'
208 echo -e "\n\nPlease enter a password for the evergreen database user.\n If you do not want to edit configs, use \"evergreen\"\n"
209 su - postgres sh -c 'createuser -P -s evergreen;'
212 # Apply the DB schema
213 cd /home/opensrf/Evergreen
214 perl Open-ILS/src/support-scripts/eg_db_config \
218 --update-config $SAMPLEDATA \
221 --password evergreen \
222 --hostname localhost \
223 --database evergreen \
224 --admin-user $ADMIN_USER \
225 --admin-pass $ADMIN_PASS;
227 if [ $LIVETEST ]; then
229 git clone --depth 0 https://github.com/theory/pgtap.git \
234 su - postgres -c "$PG_CMD"
235 cd /var/lib/postgresql/pgtap \
237 echo 'CREATE EXTENSION pgtap;' | su - postgres -c "psql evergreen"
240 # Copy apache configs into place and create SSL cert
241 cp Open-ILS/examples/apache/eg.conf /etc/apache2/sites-available/
242 cp Open-ILS/examples/apache/eg_vhost.conf /etc/apache2/
243 cp Open-ILS/examples/apache/eg_startup /etc/apache2/
245 mkdir -p /etc/apache2/ssl;
246 if [ ! -f /etc/apache2/ssl/server.key ] ; then
247 echo -e "\n\nConfiguring a new temporary SSL certificate....\n";
249 yes "" | openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key
251 openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key
254 echo -e "\nkeeping existing ssl/server.key file\n";
260 a2dissite 000-default
263 if [ ! "$(grep 'public.localhost' /etc/hosts)" ]; then
266 echo 'Adding public.localhost and private.localhost to /etc/hosts'
267 echo '127.0.1.2 public.localhost public' >> /etc/hosts
268 echo '127.0.1.3 private.localhost private' >> /etc/hosts
273 * Add these lines to /etc/hosts.
275 127.0.1.2 public.localhost public
276 127.0.1.3 private.localhost private
282 echo "INFO: /etc/hosts already has public.localhost line";
285 if [ $AUTOSTART ]; then
288 export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH \
289 && export PATH=/openils/bin:$PATH \
290 && /openils/bin/osrf_ctl.sh -l -a restart_router && sleep 5 \
291 && /openils/bin/osrf_ctl.sh -l -a restart_perl && sleep 10 \
292 && /openils/bin/osrf_ctl.sh -l -a restart_c && sleep 3 \
293 && /openils/bin/autogen.sh /openils/conf/opensrf_core.xml \
296 echo Starting services...
297 su - opensrf sh -c "$OSRF_COMMAND";
299 echo Modifying APACHE_RUN_USER/APACHE_RUN_GROUP in /etc/apache2/envvars
300 sed -i 's/www-data/opensrf/g' /etc/apache2/envvars
302 echo Making sure /var/lock/apache2 is owned by opensrf
303 chown opensrf:opensrf /var/lock/apache2
305 echo Modifying KeepAliveTimeout in /etc/apache2/apache2.conf
306 sed -i 's/KeepAliveTimeout .*/KeepAliveTimeout 1/' /etc/apache2/apache2.conf
308 echo Restarting Apache
309 /etc/init.d/apache2 restart
311 if [ $LIVETEST ]; then
312 # TODO: Eventually move these tests into a Make target within Evergreen
313 cd /home/opensrf/Evergreen
314 echo _.-~= Running pgTAP tests
315 su - postgres -c 'cd /home/opensrf/Evergreen ; pg_prove -vr -d evergreen Open-ILS/src/sql/Pg/t/ ; echo Return Value = $?'
316 echo End of pgTAP tests =~-._
317 echo _.-~= Running settings-tester.pl
318 su - opensrf sh -c 'export PATH=/openils/bin:$PATH ; cd /home/opensrf/Evergreen/Open-ILS/src/support-scripts/ ; ./settings-tester.pl ; echo Return Value = $?'
319 echo End of settings-tester.pl output =~-._
320 echo _.-~= Running perl live tests
321 su - opensrf sh -c 'export PATH=/openils/bin:$PATH ; cd /home/opensrf/Evergreen/Open-ILS/src/perlmods/ ; make livecheck; echo Return Value = $?'
322 echo End of perl live tests =~-._
328 echo "request open-ils.cstore open-ils.cstore.direct.actor.user.retrieve 1" | srfsh
338 osrf_ctl.sh -l -a start_router;
339 osrf_ctl.sh -l -a start_perl && sleep 10;
340 osrf_ctl.sh -l -a start_c && sleep 3;
341 /openils/bin/autogen.sh /openils/conf/opensrf_core.xml;
346 echo "request open-ils.cstore open-ils.cstore.direct.actor.user.retrieve 1" | srfsh
348 * Now finish configuring Apache
350 1. s/www-data/opensrf/g in envvars
351 2. KeepAliveTimeout 1 in apache2.conf