--- /dev/null
+#!/bin/bash
+# -----------------------------------------------------------------------
+# Copyright (C) 2009-2012 Equinox Software Inc.
+# Bill Erickson <berick@esilibrary.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# -----------------------------------------------------------------------
+
+while getopts ayst option
+do
+ case "${option}"
+ in
+ a) AUTOSTART=1;;
+ y) YES=1;;
+ s) SAMPLEDATA=--load-all-sample;;
+ t) LIVETEST=1;;
+ esac
+done
+
+function my_init {
+
+ echo __--== Setup
+
+ date
+ init_variables
+ configure_timezone
+ configure_cpan
+ build_essentials
+
+ echo __--== Installing OpenSRF
+ echo __--==2 1. Preamble: referenced user accounts
+
+ setting_up_test_user_env
+
+ echo __--==2 2. Download and unpack the code
+
+ cloning_opensrf_git_repos
+
+ echo __--==2 3. Installing prerequisites
+
+ opensrf_prereqs
+
+ echo __--==2 4. Preamble: Developer instructions
+
+ opensrf_developer_steps
+
+ echo __--==2 5. Configuration and compilation instructions
+
+ build_opensrf
+ test_opensrf_build
+
+ echo __--==2 6. Installation instructions
+
+ install_opensrf
+
+ echo __--==2 7. Create and set up the opensrf Unix user environment
+
+ setting_up_opensrf_env
+
+ echo __--==2 8. Define your public and private OpenSRF domains
+
+ set_domains
+
+ echo __--==2 9. Adjust the system dynamic library path
+
+ adjust_dynamic_library_path
+
+ echo __--==2 10. Configure the ejabberd server
+
+ configure_ejabberd
+
+ echo __--==2 11. Create the OpenSRF Jabber users
+
+ create_jabber_users
+
+ echo __--==2 12. Update the OpenSRF configuration files
+ echo __--==3 12.1. About the OpenSRF configuration files
+
+ echo __--==3 12.2. Updating the OpenSRF configuration files
+
+ set_opensrf_config
+
+ echo __--==2 13. Starting and stopping OpenSRF services
+
+ start_opensrf
+ sleep 10
+ stop_opensrf
+ sleep 10
+
+ echo __--==2 14. Testing the default OpenSRF services
+
+ start_opensrf
+ sleep 10
+ test_srfsh
+
+ echo __--==2 15. Websockets installation instructions
+
+ configure_websockets
+
+ echo __--==2 16. Optional: Using a web proxy
+
+ echo __--==2 17. Optional: Using NGINX as a proxy
+
+ echo __--==2 18. Optional: Using HAProxy as a proxy
+
+ echo __--==2 19. Troubleshooting note for Python users
+
+ echo __--==2 20. Getting help
+
+ echo __--== Installing Evergreen
+ echo __--==2 1. Preamble: referenced user accounts
+
+ stop_opensrf
+ cloning_evergreen_git_repos
+
+ echo __--==2 2. Preamble: developer instructions
+
+ eg_developer_steps
+
+ echo __--==2 3. Installing prerequisites
+
+ eg_prereqs
+
+ echo __--==3 OPTIONAL: Developer additions
+
+ eg_dev_additions
+
+ echo __--==2 4. Extra steps for web staff client
+
+
+ echo __--==3 4.1. Install dependencies for web staff client
+
+ echo __--==3 4.2. Install AngularJS files for web staff client
+
+ eg_angularjs_web_build
+
+ echo __--==3 4.3. Install Angular files for web staff client
+
+ eg_angular_web_build
+
+ echo __--==2 5. Configuration and compilation instructions
+
+ build_eg
+ test_eg_build
+
+ echo __--==2 6. Installation instructions
+
+ install_eg
+
+ echo __--==2 7. Change ownership of the Evergreen files
+
+ eg_post_install1
+
+ echo __--==2 8. Run ldconfig
+
+ eg_post_install2
+
+ echo __--==2 9. Additional Instructions for Developers
+
+ eg_dojo_install
+
+ echo __--==2 10. Configure the Apache Web server
+
+ configure_apache
+
+ echo __--==2 11. Configure OpenSRF for the Evergreen application
+
+ eg_configure_opensrf
+
+ echo __--==2 12. Configure action triggers for the Evergreen application
+
+ eg_configure_action_trigger
+
+ echo __--==2 13. Creating the Evergreen database
+
+ echo __--==3 13.1. Setting up the PostgreSQL server
+
+ evergreen_db_prereqs
+ evergreen_db_superuser
+
+ echo __--==3 13.2. Creating the Evergreen database and schema
+
+ evergreen_db_create
+ evergreen_db_pgtap
+
+ echo __--==2 14. Starting Evergreen
+
+ if [ $AUTOSTART ]; then
+ start_opensrf
+ sleep 10
+ eg_autogen
+ sleep 10
+ eg_restart_apache
+ sleep 10
+ else
+ echo AUTOSTART not enabled
+ fi
+
+ echo __--==2 15. Testing connections to Evergreen
+
+ if [ $AUTOSTART ]; then
+ if [ $LIVETEST ]; then
+ eg_test_srfsh
+ test_evergreen_live
+ fi
+ else
+ echo AUTOSTART not enabled
+ fi
+
+ echo __--==2 16. Getting help
+
+ echo __--==2 17. License
+
+ echo __--== Miscellaneous
+
+ #docs_builder_prereqs
+ #build_the_docs
+ get_opensrf_tip
+ get_eg_tip
+
+ exit 0;
+}
+
+function init_variables {
+ echo _.-~= initializing installer
+ date
+ # -----------------------------------------------------------------------
+ # Handling passed arguments to the script
+ # -----------------------------------------------------------------------
+ export DOJO_VERSION='1.3.3';
+ export PATH=/openils/bin:$PATH
+ export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH
+ export BASE_DIR=$PWD
+ echo AUTOSTART=${AUTOSTART}
+ echo YES=${YES}
+ echo SAMPLEDATA=${SAMPLEDATA}
+ echo LIVETEST=${LIVETEST}
+ echo DOJO_VERSION=${DOJO_VERSION}
+ echo PATH=${PATH}
+ echo LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
+ echo BASE_DIR=${BASE_DIR}
+ # -----------------------------------------------------------------------
+ # Change to suit...
+ # -----------------------------------------------------------------------
+ # If you change the jabber password, you will need to
+ # edit opensrf_core.xml and srfsh.xml accordingly
+ export JABBER_PASSWORD='password'
+ export ADMIN_USER='admin';
+ export ADMIN_PASS='demo123';
+ # -----------------------------------------------------------------------
+ # Database variables
+ # -----------------------------------------------------------------------
+ export PGDATABASE=evergreen
+ export PGUSER=evergreen
+ export PGPASSWORD=evergreen
+ export PGHOST=localhost
+ # -----------------------------------------------------------------------
+ # You can override these like so:
+ # EVERGREEN_BRANCH='master' ./eg_stretch_installer.sh
+ # -----------------------------------------------------------------------
+ OPENSRF_REPO='git://git.evergreen-ils.org/OpenSRF.git'
+ OPENSRF_BRANCH='master'
+ EVERGREEN_REPO='git://git.evergreen-ils.org/working/Evergreen.git'
+ EVERGREEN_BRANCH='collab/phasefx/34-lp1787968-wip'
+ echo OPENSRF_REPO=${OPENSRF_REPO}
+ echo OPENSRF_BRANCH=${OPENSRF_BRANCH}
+ echo EVERGREEN_REPO=${EVERGREEN_REPO}
+ echo EVERGREEN_BRANCH=${EVERGREEN_BRANCH}
+ OPENSRF_PREREQ_TARGET=debian-stretch
+ EVERGREEN_PREREQ_TARGET=debian-stretch
+ EVERGREEN_DB_PREREQ_TARGET=postgres-server-debian-stretch-10
+ echo OPENSRF_PREREQ_TARGET=${OPENSRF_PREREQ_TARGET}
+ echo EVERGREEN_PREREQ_TARGET=${EVERGREEN_PREREQ_TARGET}
+ echo EVERGREEN_DB_PREREQ_TARGET=${EVERGREEN_DB_PREREQ_TARGET}
+
+ export NODEJS_VERSION='v8.11.4'
+ export NODEJS_BINDIR="node-$NODEJS_VERSION-linux-x64"
+ export NODEJS_TARBIN="$NODEJS_BINDIR.tar.xz"
+ export NODEJS_BINARY="https://nodejs.org/dist/$NODEJS_VERSION/$NODEJS_TARBIN"
+ echo "NODEJS_BINARY=$NODEJS_BINARY"
+ echo "NODEJS_VERSION=$NODEJS_VERSION"
+
+ echo End of intializing installer =~-._
+}
+
+function configure_timezone {
+ echo _.-~= configure timezone
+ date
+ # should be America/New_York
+ perl -e 'print "2\n\n104\n";' | dpkg-reconfigure -fteletype tzdata
+ echo End of configure timezone =~-._
+}
+
+function configure_cpan {
+ echo _.-~= configure CPAN
+ date
+ # -----------------------------------------------------------------------
+ # force CPAN to load by installing something that should already be installed
+ if [ $YES ]; then
+ yes | cpan Fcntl
+ else
+ cpan Fcntl
+ fi
+ echo Return Value = $?
+ # CPAN follow pre-reqs?
+ if [ ! "$(echo 'o conf prerequisites_policy' | cpan | grep follow)" ]; then
+ if [ $YES ]; then
+
+ echo "setting cpan prerequisites_policy to follow"
+ echo -e "o conf prerequisites_policy follow\\n o conf commit" | cpan
+
+ else
+
+ echo '
+
+-----------------------------------------------------------------------
+The install will go faster if CPAN is configured to automatically install
+prerequisites. You can revert the action later with:
+
+echo -e "o conf prerequisites_policy ask\n o conf commit" | cpan
+'
+ while true; do
+ echo -n 'Automatically install prereqs? [Y/n] ';
+ read X;
+ [ "$X" == 'n' -o "$X" == "N" ] && break;
+ if [ "$X" == 'y' -o "$X" == 'Y' ]; then
+ echo -e "o conf prerequisites_policy follow\\n o conf commit" | cpan
+ break;
+ fi;
+ done;
+ fi;
+ fi;
+ echo End of configure CPAN =~-._
+}
+
+function build_essentials {
+ echo _.-~= Installing some build essentials
+ date
+ # Install some essential tools
+ apt-get update \
+ && apt-get -yq dist-upgrade \
+ && apt-get -yq install build-essential automake git psmisc ntp rsyslog lsb-release unzip;
+ echo Return Value = $?
+
+ if [ $LIVETEST ]; then
+ cpan TAP::Parser::SourceHandler::pgTAP
+ echo Return Value = $?
+ fi;
+ echo End of Installing some build essentials =~-._
+}
+
+function setting_up_test_user_env {
+ echo _.-~= creating test user and environment
+ date
+ # Create test user and set up environment
+ if [ ! "$(grep ^test: /etc/passwd)" ]; then
+ useradd -m -s /bin/bash test
+ echo Return Value = $?
+ fi;
+ echo end of creating test user and environment =~-._
+}
+
+function cloning_opensrf_git_repos {
+ echo _.-~= cloning OpenSRF git repository
+ date
+ TEST_COMMAND="
+ cd /home/test;
+ git clone --depth 1 --branch $OPENSRF_BRANCH $OPENSRF_REPO OpenSRF;
+ "
+ su - test sh -c "$TEST_COMMAND";
+ echo Return Value = $?
+
+ echo End of cloning OpenSRF git repository =~-._
+}
+
+function opensrf_prereqs {
+ echo _.-~= Installing OpenSRF pre-requisites
+ date
+ # Install pre-reqs
+ apt-get -yq install make
+ cd /home/test/OpenSRF/
+ if [ $YES ]; then
+ yes | make -f src/extras/Makefile.install ${OPENSRF_PREREQ_TARGET}
+ else
+ make -f src/extras/Makefile.install ${OPENSRF_PREREQ_TARGET}
+ fi;
+ echo Return Value = $?
+ echo End of Installing OpenSRF pre-requisites =~-._
+}
+
+function opensrf_developer_steps {
+ echo _.-~= OpenSRF developer steps
+ apt-get -yq install autoconf automake libtool
+ echo Return Value = $?
+ cd /home/test/OpenSRF/
+ autoreconf -i
+ echo Return Value = $?
+ echo End of OpenSRF developer steps =~-._
+}
+
+function build_opensrf {
+ # Build and install OpenSRF
+ echo _.-~= Building OpenSRF
+ date
+ TEST_COMMAND='
+ cd /home/test/OpenSRF;
+ ./configure --prefix=/openils --sysconfdir=/openils/conf;
+ make;'
+ su - test sh -c "$TEST_COMMAND"
+ echo Return Value = $?
+ echo End of Building OpenSRF =~-._
+}
+
+function test_opensrf_build {
+ echo _.-~= Running OpenSRF build tests
+ date
+ cd /home/test/OpenSRF;
+ make check
+ echo Return Value = $?
+ echo End of OpenSRF build tests =~-._
+}
+
+function install_opensrf {
+ echo _.-~= Installing OpenSRF
+ date
+ make install
+ echo Return Value = $?
+ echo End of Installing OpenSRF =~-._
+}
+
+function setting_up_opensrf_env {
+ echo _.-~= creating opensrf user and environment
+ date
+ # Create opensrf user and set up environment
+ if [ ! "$(grep ^opensrf: /etc/passwd)" ]; then
+ useradd -m -s /bin/bash opensrf
+ echo Return Value = $?
+ echo 'export PATH=/openils/bin:$PATH' >> /home/opensrf/.bashrc
+ chown -R opensrf:opensrf /openils
+ fi;
+ echo end of creating opensrf user and environment =~-._
+}
+
+function set_domains {
+ echo _.-~= updating /etc/hosts
+ if [ ! "$(grep 'public.localhost' /etc/hosts)" ]; then
+
+ if [ $YES ]; then
+ echo 'Adding public.localhost and private.localhost to /etc/hosts'
+ echo '127.0.1.2 public.localhost public' >> /etc/hosts
+ echo '127.0.1.3 private.localhost private' >> /etc/hosts
+ else
+
+ cat <<EOF
+
+ * Add these lines to /etc/hosts.
+
+ 127.0.1.2 public.localhost public
+ 127.0.1.3 private.localhost private
+
+EOF
+ fi;
+
+ else
+ echo "INFO: /etc/hosts already has public.localhost line";
+ fi
+ echo Return Value = $?
+ echo End of updating /etc/hosts =~-._
+}
+
+function adjust_dynamic_library_path {
+ echo _.-~= setting ld.so.conf.d
+ #echo 'export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH' >> /home/opensrf/.bashrc
+ echo /openils/lib > /etc/ld.so.conf.d/opensrf.conf
+ ldconfig
+ echo end of setting ld.so.conf.d =~-._
+}
+
+function configure_ejabberd {
+ echo _.-~= configuring ejabberd
+ echo stopping ejabberd
+ if [ -e /etc/init.d/ejabberd ]; then
+ /etc/init.d/ejabberd stop
+ else
+ systemctl stop ejabberd.service
+ fi
+ if [ ! "$(grep 'public.localhost' /etc/ejabberd/ejabberd.yml)" ]; then
+ cd /etc/ejabberd/
+ cp ejabberd.yml /root/ejabberd.yml
+ patch -p0 < $BASE_DIR/ejabberd.EG.patch
+ chown ejabberd:ejabberd ejabberd.yml
+ fi;
+ echo starting ejabberd after patching
+ date
+ if [ -e /etc/init.d/ejabberd ]; then
+ /etc/init.d/ejabberd start
+ else
+ systemctl start ejabberd.service
+ fi
+ echo Return Value = $?
+ sleep 10;
+ echo End of configuring ejabberd =~-._
+}
+
+function create_jabber_users {
+ echo _.-~= creating jabber users
+ ejabberdctl register router private.localhost $JABBER_PASSWORD
+ echo Return Value = $?
+ ejabberdctl register opensrf private.localhost $JABBER_PASSWORD
+ echo Return Value = $?
+ ejabberdctl register router public.localhost $JABBER_PASSWORD
+ echo Return Value = $?
+ ejabberdctl register opensrf public.localhost $JABBER_PASSWORD
+ echo Return Value = $?
+ echo End of creating jabber users =~-._
+}
+
+function set_opensrf_config {
+ echo _.-~= configuring OpenSRF
+
+ cd /openils/conf/
+ cp opensrf_core.xml.example opensrf_core.xml
+ cp opensrf.xml.example opensrf.xml
+
+ chown -R opensrf:opensrf /openils/conf
+
+ cp srfsh.xml.example /home/opensrf/.srfsh.xml
+
+ chown opensrf:opensrf /home/opensrf/.srfsh.xml
+
+ echo End of configuring OpenSRF =~-._
+}
+
+function start_opensrf {
+ echo _.-~= start opensrf
+ OSRF_COMMAND='PATH=/openils/bin:$PATH osrf_control --localhost --start-all'
+ su - opensrf sh -c "$OSRF_COMMAND"
+ echo Return Value = $?
+ echo End of start opensrf =~-._
+}
+
+function stop_opensrf {
+ echo _.-~= stop opensrf
+ OSRF_COMMAND='PATH=/openils/bin:$PATH osrf_control --localhost --stop-all'
+ su - opensrf sh -c "$OSRF_COMMAND"
+ echo Return Value = $?
+ echo End of stop opensrf =~-._
+}
+
+function test_srfsh {
+ echo _.-~= test opensrf
+ OSRF_COMMAND='echo request opensrf.math add 2,2 | PATH=/openils/bin:$PATH srfsh'
+ su - opensrf sh -c "$OSRF_COMMAND"
+ echo Return Value = $?
+ echo End of test opensrf =~-._
+}
+
+function configure_websockets {
+ echo _.-~= configuring websockets
+
+ echo Install websocketd
+ cd /tmp
+ wget 'https://github.com/joewalnes/websocketd/releases/download/v0.3.0/websocketd-0.3.0-linux_amd64.zip'
+ unzip websocketd-0.3.0-linux_amd64.zip
+ sudo cp websocketd /usr/local/bin/
+ echo Return Value = $?
+
+ echo Before you can start websockets, you must install a valid SSL certificate in /etc/apache2/ssl/
+
+ mkdir -p /etc/apache2/ssl;
+ if [ ! -f /etc/apache2/ssl/server.key ] ; then
+ echo -e "\n\nConfiguring a new temporary SSL certificate....\n";
+ if [ $YES ]; then
+ yes "" | openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key
+ else
+ openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key
+ fi;
+ else
+ echo -e "\nkeeping existing ssl/server.key file\n";
+ fi
+
+ a2enmod ssl
+ echo Return Value = $?
+
+ echo Run websocketd, choosing option b:
+
+ echo 'b. Run websocketd without a proxy (chosen)'
+
+ /usr/local/bin/websocketd --port 7682 --ssl --sslcert=/etc/apache2/ssl/server.crt --sslkey=/etc/apache2/ssl/server.key /openils/bin/osrf-websocket-stdio &
+
+ echo Return Value = $?
+
+ echo End of configuring websockets =~-._
+}
+
+function cloning_evergreen_git_repos {
+ echo _.-~= cloning Evergreen git repository
+ date
+ TEST_COMMAND="
+ cd /home/test;
+ git clone --depth 1 --branch $EVERGREEN_BRANCH $EVERGREEN_REPO Evergreen;
+ "
+ su - test sh -c "$TEST_COMMAND";
+ echo Return Value = $?
+
+ echo End of cloning Evergreen git repository =~-._
+}
+
+function eg_developer_steps {
+ echo _.-~= Evergreen developer steps
+ cd /home/test/Evergreen/
+ autoreconf -i
+ echo Return Value = $?
+ echo End of Evergreen developer steps =~-._
+}
+
+function eg_prereqs {
+ echo _.-~= Installing Evergreen pre-requisites
+ date
+ cd /home/test/Evergreen/
+ if [ $YES ]; then
+ yes | make -f Open-ILS/src/extras/Makefile.install ${EVERGREEN_PREREQ_TARGET}
+ else
+ make -f Open-ILS/src/extras/Makefile.install ${EVERGREEN_PREREQ_TARGET}
+ fi;
+ echo Return Value = $?
+ echo End of Installing Evergreen pre-requisites =~-._
+}
+
+function eg_dev_additions {
+ echo _.-~= Installing Evergreen pre-requisites
+ date
+ cd /home/test/Evergreen/
+ echo ${EVERGREEN_PREREQ_TARGET}-developer
+ if [ $YES ]; then
+ yes | make -f Open-ILS/src/extras/Makefile.install ${EVERGREEN_PREREQ_TARGET}-developer
+ else
+ make -f Open-ILS/src/extras/Makefile.install ${EVERGREEN_PREREQ_TARGET}-developer
+ fi;
+ echo ${EVERGREEN_PREREQ_TARGET}-translator
+ if [ $YES ]; then
+ yes | make -f Open-ILS/src/extras/Makefile.install ${EVERGREEN_PREREQ_TARGET}-translator
+ else
+ make -f Open-ILS/src/extras/Makefile.install ${EVERGREEN_PREREQ_TARGET}-translator
+ fi;
+ echo ${EVERGREEN_PREREQ_TARGET}-packager
+ if [ $YES ]; then
+ yes | make -f Open-ILS/src/extras/Makefile.install ${EVERGREEN_PREREQ_TARGET}-packager
+ else
+ make -f Open-ILS/src/extras/Makefile.install ${EVERGREEN_PREREQ_TARGET}-packager
+ fi;
+ echo Return Value = $?
+ echo End of Installing Evergreen pre-requisites =~-._
+}
+
+function eg_angularjs_web_build {
+ echo _.-~= Installing AngularJS web client
+ date
+ TEST_COMMAND='
+ cd /home/test/Evergreen/Open-ILS/web/js/ui/default/staff/ ;
+ export CHROME_BIN=/usr/bin/chromium
+ echo Running npm install: ;
+ npm install ;
+ echo Return Value = $? ;
+ echo Running npm run build-prod: ;
+ npm run build-prod ;
+ echo Return Value = $? ;
+ echo Running npm run test: ;
+ npm run test ;
+ echo Return Value = $? ;
+ '
+ su - test sh -c "$TEST_COMMAND"
+ echo Return Value = $?
+ echo End of Installing AngularJS web client =~-._
+}
+
+function eg_angular_web_build {
+ echo _.-~= Installing Angular web client
+ date
+ TEST_COMMAND='
+ cd /home/test/Evergreen/Open-ILS/src/eg2/ ;
+ export CHROME_BIN=/usr/bin/chromium
+ echo Running npm install: ;
+ npm install ;
+ echo Return Value = $? ;
+ echo "Running ng build --prod:" ;
+ ng build --prod ;
+ echo Return Value = $? ;
+ echo Running npm run test: ;
+ npm run test ;
+ echo Return Value = $? ;
+ '
+ su - test sh -c "$TEST_COMMAND"
+ echo Return Value = $?
+ echo End of Installing AngularJS web client =~-._
+}
+
+function build_eg {
+ echo _.-~= Building Evergreen
+ date
+ TEST_COMMAND='
+ cd /home/test/Evergreen;
+ PATH=/openils/bin:$PATH ./configure --prefix=/openils --sysconfdir=/openils/conf;
+ make;'
+ su - test sh -c "$TEST_COMMAND"
+ echo Return Value = $?
+ echo End of Building Evergreen =~-._
+}
+
+function test_eg_build {
+ echo _.-~= Running Evergreen tests
+ date
+ cd /home/test/Evergreen;
+ make check
+ echo Return Value = $?
+ echo End of Running Evergreen tests =~-._
+}
+
+function install_eg {
+ echo _.-~= Installing Evergreen
+ date
+ cd /home/test/Evergreen
+ make install
+ echo Return Value = $?
+ echo End of Installing Evergreen =~-._
+}
+
+function eg_post_install1 {
+ echo _.-~= Change File Ownership
+ date
+ chown -R opensrf:opensrf /openils
+ echo End of Change File Ownership =~-._
+}
+
+function eg_post_install2 {
+ echo _.-~= Run ldconfig
+ date
+ ldconfig
+ echo End of Run ldconfig =~-._
+}
+
+function eg_dojo_install {
+ echo _.-~= Installing Dojo
+ date
+ OSRF_COMMAND='
+ cd /home/opensrf/;
+ wget -N "http://download.dojotoolkit.org/release-'$DOJO_VERSION'/dojo-release-'$DOJO_VERSION'.tar.gz" \
+ || wget -N "http://evergreen-ils.org/~phasefx/download.dojotoolkit.org/dojo-release-'$DOJO_VERSION'.tar.gz"
+ tar -C /openils/var/web/js -xzf dojo-release-'$DOJO_VERSION'.tar.gz
+ cp -r /openils/var/web/js/dojo-release-'$DOJO_VERSION'/* /openils/var/web/js/dojo/.'
+ su - opensrf sh -c "$OSRF_COMMAND"
+ cd
+ echo End of Installing Dojo =~-._
+}
+
+function configure_apache {
+ echo _.-~= configure apache
+ date
+ echo State of Apache processes
+ ps -aef | egrep -i 'apache|http'
+ echo Copy apache configs into place
+ cd /home/test/Evergreen/
+ cp Open-ILS/examples/apache_24/eg_24.conf /etc/apache2/sites-available/eg.conf
+ cp Open-ILS/examples/apache_24/eg_vhost_24.conf /etc/apache2/eg_vhost.conf
+ cp Open-ILS/examples/apache_24/eg_startup /etc/apache2/
+
+ echo SSL cert
+ /etc/init.d/apache2 stop
+ mkdir -p /etc/apache2/ssl/;
+ cd /etc/apache2/ssl/
+ if [ ! -f server.key ] ; then
+ echo -e "\n\nConfiguring a new temporary SSL certificate....\n";
+ if [ $YES ]; then
+ yes "" | openssl req -new -x509 -days 365 -nodes -out server.crt -keyout server.key
+ else
+ openssl req -new -x509 -days 365 -nodes -out server.crt -keyout server.key
+ fi;
+ else
+ echo -e "\nkeeping existing ssl/server.key file\n";
+ fi
+
+ echo Modifying APACHE_RUN_USER/APACHE_RUN_GROUP in /etc/apache2/envvars
+ sed -i 's/www-data/opensrf/g' /etc/apache2/envvars
+
+ echo Modifying KeepAliveTimeout in /etc/apache2/apache2.conf
+ echo Before:
+ grep KeepAliveTimeout /etc/apache2/apache2.conf
+ sed -i 's/KeepAliveTimeout .*/KeepAliveTimeout 1/' /etc/apache2/apache2.conf
+ echo After:
+ grep KeepAliveTimeout /etc/apache2/apache2.conf
+
+ echo Modifying KeepAliveMaxRequests in /etc/apache2/apache2.conf
+ echo Before:
+ grep KeepAliveMaxRequests /etc/apache2/apache2.conf
+ sed -i 's/KeepAliveMaxRequests .*/KeepAliveMaxRequests 100/' /etc/apache2/apache2.conf
+ echo After:
+ grep KeepAliveMaxRequests /etc/apache2/apache2.conf
+
+ echo Setting /etc/apache2/mods-available/mpm_prefork.conf
+ echo '<IfModule mpm_prefork_module>' > /etc/apache2/mods-available/mpm_prefork.conf
+ echo ' StartServers 15' >> /etc/apache2/mods-available/mpm_prefork.conf
+ echo ' MinSpareServers 5' >> /etc/apache2/mods-available/mpm_prefork.conf
+ echo ' MaxSpareServers 15' >> /etc/apache2/mods-available/mpm_prefork.conf
+ echo ' MaxRequestWorkers 75' >> /etc/apache2/mods-available/mpm_prefork.conf
+ echo ' MaxConnectionsPerChild 500' >> /etc/apache2/mods-available/mpm_prefork.conf
+ echo '</IfModule>' >> /etc/apache2/mods-available/mpm_prefork.conf
+
+ echo Ensuring mpm_prefork over mpm_event
+ a2dismod mpm_event
+ a2enmod mpm_prefork
+
+ echo Enable the EG site
+ a2dissite 000-default # OPTIONAL: disable the default site (the "It Works" page)
+ a2ensite eg.conf
+
+ echo Making sure /var/lock/apache2 is owned by opensrf
+ chown opensrf /var/lock/apache2
+
+ #a2enmod ssl
+ #echo Return Value = $?
+ #a2enmod rewrite
+ #echo Return Value = $?
+ #a2enmod expires
+ #echo Return Value = $?
+ #a2dissite 000-default
+ #echo Return Value = $?
+ #a2ensite eg.conf
+ #echo Return Value = $?
+
+ echo State of Apache processes
+ ps -aef | egrep -i 'apache|http'
+
+ echo End of configure apache =~-._
+}
+
+function eg_configure_opensrf {
+ echo _.-~= configure EG OpenSRF
+ date
+ OSRF_COMMAND='cp -b /openils/conf/opensrf_core.xml.example /openils/conf/opensrf_core.xml;
+ cp -b /openils/conf/opensrf.xml.example /openils/conf/opensrf.xml;'
+ su - opensrf sh -c "$OSRF_COMMAND"
+ echo Return Value = $?
+ echo End of configure EG OpenSRF =~-._
+}
+
+function eg_configure_action_trigger {
+ echo _.-~= configure EG Action/Trigger
+ date
+ OSRF_COMMAND='cp -b /openils/conf/action_trigger_filters.json.example /openils/conf/action_trigger_filters.json'
+ su - opensrf sh -c "$OSRF_COMMAND"
+ echo Return Value = $?
+ echo End of configure EG Action/Trigger =~-._
+}
+
+function evergreen_db_prereqs {
+ echo _.-~= Installing Evergreen database pre-requisites
+ date
+ cd /home/test/Evergreen/
+ if [ $YES ]; then
+ yes | make -f Open-ILS/src/extras/Makefile.install ${EVERGREEN_DB_PREREQ_TARGET}
+ else
+ make -f Open-ILS/src/extras/Makefile.install ${EVERGREEN_DB_PREREQ_TARGET}
+ fi;
+ echo Return Value = $?
+ echo End of Installing Evergreen database pre-requisites =~-._
+}
+
+function evergreen_db_superuser {
+ echo _.-~= Create PostgreSQL superuser
+ date
+ if [ $YES ]; then
+ echo "Using password $PGPASSWORD for the $PGUSER database user."
+ echo -e "$PGPASSWORD\n$PGPASSWORD\n" | su - postgres sh -c "createuser -P -s $PGUSER;"
+ else
+ echo -e "\n\nPlease enter a password for the $PGUSER database user.\n If you do not want to edit configs, use \"$PGPASSWORD\"\n"
+ su - postgres sh -c "createuser -s -P $PGUSER;"
+ fi;
+ echo Return Value = $?
+ echo End of Create PostgreSQL superuser =~-._
+}
+
+function evergreen_db_create {
+ echo _.-~= Create Evergreen Database
+ date
+
+ echo Running eg_db_config:
+ cd /home/test/Evergreen
+ perl Open-ILS/src/support-scripts/eg_db_config \
+ --create-database \
+ --create-schema \
+ --create-offline \
+ --update-config $SAMPLEDATA \
+ --service all \
+ --user $PGUSER \
+ --password $PGPASSWORD \
+ --hostname $PGHOST \
+ --database $PGDATABASE \
+ --admin-user $ADMIN_USER \
+ --admin-pass $ADMIN_PASS;
+ echo Return Value = $?
+
+ echo Installing pgtap
+
+ # output the name of the currently installed pg server dev package, then
+ # throw away everything up to and including the last '-' to get the correct pg version
+ PGVERS=`dpkg-query --showformat="\\${binary:Package}\\n" --show 'postgresql-server-dev-*' | grep -v postgresql-server-dev-all`
+ apt-get install -y postgresql-${PGVERS##*-}-pgtap
+
+ echo 'CREATE EXTENSION pgtap;' | su - postgres -c "psql evergreen"
+
+ echo End of Create Evergreen Database =~-._
+}
+
+function evergreen_db_pgtap {
+ echo _.-~= Running pgTAP tests
+ date
+ su - postgres -c 'cd /home/test/Evergreen ; pg_prove -vr -d evergreen Open-ILS/src/sql/Pg/t/ ; echo Return Value = $?'
+ echo End of pgTAP tests =~-._
+}
+
+function eg_autogen {
+ echo _.-~= Running autogen.sh
+ date
+ su - opensrf sh -c "PATH=$PATH:/openils/bin autogen.sh";
+ echo Return Value = $?
+ echo End of Running autogen.sh =~-._
+}
+
+function eg_restart_apache {
+ echo _.-~= Restarting Apache
+ date
+ #if [ -e /etc/init.d/apache2-websockets ]; then
+ # /etc/init.d/apache2-websockets stop
+ # echo Return Value = $?
+ #else
+ # systemctl stop apache2@websockets.service
+ # echo Return Value = $?
+ #fi
+ echo State of Apache processes
+ ps -aef | egrep -i 'apache|http'
+ if [ -e /etc/init.d/apache2 ]; then
+ echo trying /etc/init.d/apache2 stop
+ /etc/init.d/apache2 stop
+ echo Return Value = $?
+ else
+ echo trying systemctl stop apache2
+ systemctl stop apache2
+ echo Return Value = $?
+ fi
+ echo State of Apache processes
+ ps -aef | egrep -i 'apache|http'
+ if [ -e /etc/init.d/apache2 ]; then
+ echo trying /etc/init.d/apache2 start
+ /etc/init.d/apache2 start
+ echo Return Value = $?
+ else
+ echo trying systemctl start apache2
+ systemctl start apache2
+ echo Return Value = $?
+ fi
+ echo State of Apache processes
+ ps -aef | egrep -i 'apache|http'
+ #if [ -e /etc/init.d/apache2-websockets ]; then
+ # /etc/init.d/apache2-websockets start
+ # echo Return Value = $?
+ #else
+ # systemctl start apache2@websockets.service
+ # echo Return Value = $?
+ #fi
+ echo End of Restarting Apache =~-._
+}
+
+function eg_test_srfsh {
+ echo _.-~= test EG opensrf
+ OSRF_COMMAND="echo login $ADMIN_USER $ADMIN_PASS | PATH=/openils/bin:\$PATH srfsh"
+ su - opensrf sh -c "$OSRF_COMMAND"
+ echo Return Value = $?
+ echo End of test EG opensrf =~-._
+}
+
+function test_evergreen_live {
+ # TODO: Eventually move these tests into a Make target within Evergreen
+ cd /home/test/Evergreen
+ #echo _.-~= Running pgTAP tests
+ #date
+ #su - postgres -c 'cd /home/opensrf/Evergreen ; pg_prove -vr -d evergreen Open-ILS/src/sql/Pg/t/ ; echo Return Value = $?'
+ #echo End of pgTAP tests =~-._
+ echo _.-~= Running pgTAP live tests
+ date
+ su - postgres -c 'cd /home/test/Evergreen ; pg_prove -vr -d evergreen Open-ILS/src/sql/Pg/live_t/ ; echo Return Value = $?'
+ echo End of pgTAP live tests =~-._
+ echo _.-~= Running settings-tester.pl
+ date
+ su - opensrf sh -c 'export PATH=/openils/bin:$PATH ; cd /home/test/Evergreen/Open-ILS/src/support-scripts/ ; ./settings-tester.pl ; echo Return Value = $?'
+ echo End of settings-tester.pl output =~-._
+ echo _.-~= Running perl live tests
+ date
+ su - root sh -c 'export PATH=/openils/bin:$PATH ; cd /home/test/Evergreen/Open-ILS/src/perlmods/ ; make livecheck; echo Return Value = $?'
+ echo End of perl live tests =~-._
+ echo _.-~= Gathering log summary
+ date
+ echo ''
+ echo 'wc -l *.log:'
+ su - opensrf sh -c 'cd /openils/var/log/ ; wc -l *.log'
+ echo ''
+ echo 'du -sh *.log:'
+ su - opensrf sh -c 'cd /openils/var/log/ ; du -sh *.log'
+ echo ''
+ echo 'perl -ne ''if (/^\[.*?\] (.*?) \[/) { print "$1\n"; }'' osrfsys.log | sort | uniq -c | sort -k2:'
+ (cd /openils/var/log/ ; perl -ne 'if (/^\[.*?\] (.*?) \[/) { print "$1\n"; }' osrfsys.log | sort | uniq -c | sort -k2)
+ echo ''
+ echo End of log summary =~-._
+ cd /openils/var/log/
+ for x in *.log; do
+ echo _.-~= Log Output: $x
+ date
+ cat $x
+ echo End of $x =~-._
+ done
+ echo _.-~= Gathering system information
+ echo ''
+ date
+ echo ''
+ uname -a
+ echo 'select version();' | su - postgres -c 'psql -At'
+ echo ''
+ echo '/proc/meminfo:'
+ cat /proc/meminfo
+ echo ''
+ echo '/proc/cpuinfo:'
+ cat /proc/cpuinfo
+ echo ''
+ echo 'dpkg --list:'
+ dpkg --list
+ echo ''
+ echo 'cpan -l:'
+ cpan -l 2> /dev/null | sort
+ echo End of system information =~-._
+ date
+}
+
+function docs_builder_prereqs {
+ echo _.-~= Installing prereqs for building the documentation formats
+ date
+ # Install tools used for building the docs
+ apt-get -yq install asciidoc source-highlight fop;
+ echo Return Value = $?
+
+ echo End of Installing prereqs for building the documentation formats =~-._
+}
+
+function build_the_docs {
+ echo _.-~= Building the AsciiDoc output formats
+ date
+ # build HTML
+ su - test sh -c 'cd /home/test/Evergreen/docs/ ; asciidoc root.adoc ; echo Return Value = $?'
+ # build PDF
+ su - test sh -c 'cd /home/test/Evergreen/docs/ ; a2x --fop --fop-opts="-q" root.adoc ; echo Return Value = $?'
+ # build EPUB
+ su - test sh -c 'cd /home/test/Evergreen/docs/ ; a2x --no-xmllint --format epub root.adoc ; echo Return Value = $?'
+
+ echo End of Building the AsciiDoc output formats =~-._
+}
+
+function get_opensrf_tip {
+ cd /home/test/OpenSRF/
+ echo 'Tip of OpenSRF:' `git log --format=oneline | head -1`
+}
+
+function get_eg_tip {
+ cd /home/test/Evergreen/
+ echo 'Tip of Evergreen:' `git log --format=oneline | head -1`
+}
+
+my_init
+