# GNU General Public License for more details.
# -----------------------------------------------------------------------
-date
-
-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
-
-# -----------------------------------------------------------------------
-# Change to suit...
-# -----------------------------------------------------------------------
-# If you change the jabber password, you will need to
-# edit opensrf_core.xml and srfsh.xml accordingly
-JABBER_PASSWORD='password'
-ADMIN_USER='admin';
-ADMIN_PASS='demo123';
-# -----------------------------------------------------------------------
-
-# -----------------------------------------------------------------------
-# Handling passed arguments to the script
-# -----------------------------------------------------------------------
-while getopts ayst option
-do
- case "${option}"
- in
- a) AUTOSTART=1;;
- y) YES=1;;
- s) SAMPLEDATA=--load-all-sample;;
- t) LIVETEST=1;;
- esac
-done
-
-# -----------------------------------------------------------------------
-# force CPAN to load by installing something that should already be installed
-echo _.-~= test CPAN
-if [ $YES ]; then
- yes | cpan Fcntl
-else
- cpan Fcntl
-fi
-echo Return Value = $?
-echo End of test CPAN =~-._
-
-# CPAN follow pre-reqs?
-if [ ! "$(echo 'o conf prerequisites_policy' | cpan | grep follow)" ]; then
-if [ $YES ]; then
+function my_init {
+ date
+ init_variables
+ configure_cpan
+ build_essentials
+ setting_up_opensrf_env
+ cloning_git_repos
+ opensrf_prereqs
+ evergreen_prereqs
+ evergreen_db_prereqs
+ setting_ldconfig_and_rsyslog_and_hosts_and_ejabberd
+ build_opensrf
+ test_opensrf_build
+ install_opensrf
+ build_evergreen
+ test_evergreen_build
+ install_evergreen
+ configure_database
+ configure_apache
+ if [ $AUTOSTART ]; then
+ start_evergreen
+ fi
+}
+
+function init_variables {
+ echo _.-~= initializing installer
+ # -----------------------------------------------------------------------
+ # Handling passed arguments to the script
+ # -----------------------------------------------------------------------
+ while getopts ayst option
+ do
+ case "${option}"
+ in
+ a) AUTOSTART=1;;
+ y) YES=1;;
+ s) SAMPLEDATA=--load-all-sample;;
+ t) LIVETEST=1;;
+ esac
+ done
+ 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';
+ # -----------------------------------------------------------------------
+ # You can override these like so:
+ # EVERGREEN_BRANCH='master' ./eg_wheezy_installer.sh
+ # -----------------------------------------------------------------------
+ OPENSRF_REPO='git://git.evergreen-ils.org/OpenSRF.git'
+ OPENSRF_BRANCH='master'
+ EVERGREEN_REPO='git://git.evergreen-ils.org/Evergreen.git'
+ EVERGREEN_BRANCH='master'
+ echo OPENSRF_REPO=${OPENSRF_REPO}
+ echo OPENSRF_BRANCH=${OPENSRF_BRANCH}
+ echo EVERGREEN_REPO=${EVERGREEN_REPO}
+ echo EVERGREEN_BRANCH=${EVERGREEN_BRANCH}
+ OPENSRF_PREREQ_TARGET=debian-wheezy
+ EVERGREEN_PREREQ_TARGET=debian-wheezy
+ EVERGREEN_DB_PREREQ_TARGET=postgres-server-debian-wheezy
+ echo OPENSRF_PREREQ_TARGET=${OPENSRF_PREREQ_TARGET}
+ echo EVERGREEN_PREREQ_TARGET=${EVERGREEN_PREREQ_TARGET}
+ echo EVERGREEN_DB_PREREQ_TARGET=${EVERGREEN_DB_PREREQ_TARGET}
+ echo End of intializing installer =~-._
+}
+
+function configure_cpan {
+ echo _.-~= configure CPAN
+ # -----------------------------------------------------------------------
+ # 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
+ echo "setting cpan prerequisites_policy to follow"
+ echo -e "o conf prerequisites_policy follow\\n o conf commit" | cpan
-else
+ else
- echo '
+ echo '
-----------------------------------------------------------------------
The install will go faster if CPAN is configured to automatically install
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;
-
-# -----------------------------------------------------------------------
-
-# And they're off...
-BASE_DIR=$PWD
-
-# Install some essential tools
-echo _.-~= Installing some pre-requisites
-apt-get update \
-&& apt-get -yq dist-upgrade \
-&& apt-get -yq install build-essential automake git psmisc ntp rsyslog;
-echo Return Value = $?
-echo End of Installing some pre-requisites =~-._
-
-if [ $LIVETEST ]; then
- cpan TAP::Parser::SourceHandler::pgTAP
-fi;
-
-cp $BASE_DIR/evergreen.ld.conf /etc/ld.so.conf.d/
-ldconfig;
-
-# Create opensrf user and set up environment
-if [ ! "$(grep ^opensrf: /etc/passwd)" ]; then
- useradd -m -s /bin/bash opensrf
- echo 'export PATH=/openils/bin:$PATH' >> /home/opensrf/.bashrc
- echo 'export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH' >> /home/opensrf/.bashrc
-fi;
-
-# XXX for now, fetch the debian-wheezy install target working branches and merge in master
-# You can override these like so: EVERGREEN_BRANCH='master' ./eg_wheezy_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/qa-integration'
-EVERGREEN_REPO='git://git.evergreen-ils.org/Evergreen.git'
-EVERGREEN_BRANCH='master'
-OSRF_COMMAND="
-cd /home/opensrf;
-git clone --depth 0 --branch $OPENSRF_BRANCH $OPENSRF_REPO OpenSRF;
-git clone --depth 0 --branch $EVERGREEN_BRANCH $EVERGREEN_REPO Evergreen;
-"
-rm -rf /home/opensrf/Evergreen /home/opensrf/OpenSRF
-echo _.-~= Cloning git repos
-su - opensrf sh -c "$OSRF_COMMAND";
-echo Return Value = $?
-echo End of Cloning git repos =~-._
-
-# Show tips
-
-cd /home/opensrf/OpenSRF/
-echo 'Tip of OpenSRF:' `git log --format=oneline | head -1`
-cd /home/opensrf/Evergreen/
-echo 'Tip of Evergreen:' `git log --format=oneline | head -1`
-
-# Install pre-reqs
-mkdir -p /usr/src/evergreen;
-cd /usr/src/evergreen;
-echo _.-~= Installing OpenSRF pre-requisites
-if [ $YES ]; then
- yes | make -f /home/opensrf/OpenSRF/src/extras/Makefile.install debian-wheezy
-else
- make -f /home/opensrf/OpenSRF/src/extras/Makefile.install debian-wheezy
-fi;
-echo Return Value = $?
-echo End of Installing OpenSRF pre-requisites =~-._
-echo _.-~= Installing Evergreen pre-requisites
-if [ $YES ]; then
- yes | make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install debian-wheezy
-else
- make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install debian-wheezy
-fi;
-echo Return Value = $?
-echo End of Installing Evergreen pre-requisites =~-._
-echo _.-~= Installing Evergreen database pre-requisites
-if [ $YES ]; then
- yes | make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install postgres-server-debian-wheezy
-else
- make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install postgres-server-debian-wheezy
-fi;
-echo Return Value = $?
-echo End of Installing Evergreen database pre-requisites =~-._
-
-# Configure rsyslog and restart
-cp /home/opensrf/Evergreen/Open-ILS/examples/evergreen-rsyslog.conf /etc/rsyslog.d/evergreen.conf
-/etc/init.d/rsyslog restart
-
-
-# Patch Ejabberd and register users
-if [ ! "$(grep 'public.localhost' /etc/ejabberd/ejabberd.cfg)" ]; then
- cd /etc/ejabberd/
- /etc/init.d/ejabberd stop;
- killall beam epmd; # just in case
- cp ejabberd.cfg /root/ejabberd.cfg.orig
- patch -p0 < $BASE_DIR/ejabberd.EG.patch
- chown ejabberd:ejabberd ejabberd.cfg
- /etc/init.d/ejabberd start
- sleep 2;
- ejabberdctl register router private.localhost $JABBER_PASSWORD
- ejabberdctl register opensrf private.localhost $JABBER_PASSWORD
- ejabberdctl register router public.localhost $JABBER_PASSWORD
- ejabberdctl register opensrf public.localhost $JABBER_PASSWORD
-fi;
-
-
-
-# Build and install OpenSRF
-OSRF_COMMAND='
-cd /home/opensrf/OpenSRF;
-autoreconf -i;
-./configure --prefix=/openils --sysconfdir=/openils/conf;
-make;'
-
-echo _.-~= Building OpenSRF
-su - opensrf sh -c "$OSRF_COMMAND"
-echo Return Value = $?
-echo End of Building OpenSRF =~-._
-cd /home/opensrf/OpenSRF;
-echo _.-~= Running OpenSRF build tests
-make check
-echo Return Value = $?
-echo End of OpenSRF build tests =~-._
-echo _.-~= Installing OpenSRF
-make install
-echo Return Value = $?
-echo End of Installing OpenSRF =~-._
-
-# Build and install the ILS
-OSRF_COMMAND='
-export PATH=/openils/bin:$PATH
-cd /home/opensrf/Evergreen;
-autoreconf -i;
-./configure --prefix=/openils --sysconfdir=/openils/conf;
-make;
-'
-
-echo _.-~= Building Evergreen
-su - opensrf sh -c "$OSRF_COMMAND"
-echo Return Value = $?
-echo End of Building Evergreen =~-._
-cd /home/opensrf/Evergreen
-echo _.-~= Running Evergreen build tests
-make check
-echo Return Value = $?
-echo End of Evergreen build tests =~-._
-
-echo _.-~= Installing Evergreen
-make install
-echo Return Value = $?
-
-cp /openils/conf/opensrf.xml.example /openils/conf/opensrf.xml
-cp /openils/conf/opensrf_core.xml.example /openils/conf/opensrf_core.xml
-
-# fetch and install Dojo
-cd /tmp;
-wget -N "http://download.dojotoolkit.org/release-$DOJO_VERSION/dojo-release-$DOJO_VERSION.tar.gz";
-tar -zxf dojo-release-$DOJO_VERSION.tar.gz;
-cp -r dojo-release-$DOJO_VERSION/* /openils/var/web/js/dojo/;
-
-# give it all to opensrf
-chown -R opensrf:opensrf /openils
-
-# copy srfsh config into place
-cp /openils/conf/srfsh.xml.example /home/opensrf/.srfsh.xml;
-chown opensrf:opensrf /home/opensrf/.srfsh.xml;
-
-if [ $YES ]; then
- echo "Using password evergreen for the evergreen database user."
- echo -e "evergreen\nevergreen\n" | su - postgres sh -c 'createuser -P -s evergreen;'
-else
- echo -e "\n\nPlease enter a password for the evergreen database user.\n If you do not want to edit configs, use \"evergreen\"\n"
- su - postgres sh -c 'createuser -P -s evergreen;'
-fi;
-
-# Apply the DB schema
-cd /home/opensrf/Evergreen
-perl Open-ILS/src/support-scripts/eg_db_config \
- --create-database \
- --create-schema \
- --create-offline \
- --update-config $SAMPLEDATA \
- --service all \
- --user evergreen \
- --password evergreen \
- --hostname localhost \
- --database evergreen \
- --admin-user $ADMIN_USER \
- --admin-pass $ADMIN_PASS;
-echo Return Value = $?
-
-if [ $LIVETEST ]; then
- PG_CMD="
- git clone --depth 0 https://github.com/theory/pgtap.git \
- && cd pgtap \
- && make \
- && make installcheck
+ 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
+ # Install some essential tools
+ apt-get update \
+ && apt-get -yq dist-upgrade \
+ && apt-get -yq install build-essential automake git psmisc ntp rsyslog;
+ 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_opensrf_env {
+ echo _.-~= creating opensrf user and environment
+ # 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
+ echo 'export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH' >> /home/opensrf/.bashrc
+ fi;
+ echo end of creating opensrf user and environment =~-._
+}
+
+function cloning_git_repos {
+ echo _.-~= cloning git repositories
+ OSRF_COMMAND="
+ cd /home/opensrf;
+ git clone --depth 0 --branch $OPENSRF_BRANCH $OPENSRF_REPO OpenSRF;
+ git clone --depth 0 --branch $EVERGREEN_BRANCH $EVERGREEN_REPO Evergreen;
"
- su - postgres -c "$PG_CMD"
- cd /var/lib/postgresql/pgtap \
- && make install;
- echo 'CREATE EXTENSION pgtap;' | su - postgres -c "psql evergreen"
-fi;
-
-# Copy apache configs into place and create SSL cert
-cd /home/opensrf/Evergreen/
-cp Open-ILS/examples/apache/eg.conf /etc/apache2/sites-available/
-cp Open-ILS/examples/apache/eg_vhost.conf /etc/apache2/
-cp Open-ILS/examples/apache/eg_startup /etc/apache2/
-
-mkdir -p /etc/apache2/ssl;
-if [ ! -f /etc/apache2/ssl/server.key ] ; then
- echo -e "\n\nConfiguring a new temporary SSL certificate....\n";
+ rm -rf /home/opensrf/Evergreen /home/opensrf/OpenSRF
+ su - opensrf sh -c "$OSRF_COMMAND";
+ echo Return Value = $?
+
+ # Show tips
+ cd /home/opensrf/OpenSRF/
+ echo 'Tip of OpenSRF:' `git log --format=oneline | head -1`
+ cd /home/opensrf/Evergreen/
+ echo 'Tip of Evergreen:' `git log --format=oneline | head -1`
+
+ echo End of cloning git repositories =~-._
+}
+
+function opensrf_prereqs {
+ echo _.-~= Installing OpenSRF pre-requisites
+ # Install pre-reqs
+ mkdir -p /usr/src/evergreen;
+ cd /usr/src/evergreen;
if [ $YES ]; then
- yes "" | openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key
+ yes | make -f /home/opensrf/OpenSRF/src/extras/Makefile.install ${OPENSRF_PREREQ_TARGET}
else
- openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key
+ make -f /home/opensrf/OpenSRF/src/extras/Makefile.install ${OPENSRF_PREREQ_TARGET}
fi;
-else
- echo -e "\nkeeping existing ssl/server.key file\n";
-fi
-
-a2enmod ssl
-a2enmod rewrite
-a2enmod expires
-a2dissite 000-default
-a2ensite eg.conf
-
-if [ ! "$(grep 'public.localhost' /etc/hosts)" ]; then
+ echo Return Value = $?
+ echo End of Installing OpenSRF pre-requisites =~-._
+}
+function evergreen_prereqs {
+ echo _.-~= Installing Evergreen pre-requisites
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
+ yes | make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install ${EVERGREEN_PREREQ_TARGET}
else
-
- cat <<EOF
-
-* Add these lines to /etc/hosts.
-
-127.0.1.2 public.localhost public
-127.0.1.3 private.localhost private
-
-EOF
+ make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install ${EVERGREEN_PREREQ_TARGET}
fi;
+ echo Return Value = $?
+ echo End of Installing Evergreen pre-requisites =~-._
+}
-else
- echo "INFO: /etc/hosts already has public.localhost line";
-fi
-
-echo End of Installing Evergreen =~-._
-
-if [ $AUTOSTART ]; then
-
-if [ $LIVETEST ]; then
- rm /openils/var/log/*.log
-fi
-
-echo _.-~= Starting Evergreen
-
-OSRF_COMMAND='
-export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH \
-&& export PATH=/openils/bin:$PATH \
-&& OSRF_HOSTNAME="dns_hack" /openils/bin/osrf_control --localhost --stop_all && sleep 3 \
-&& OSRF_HOSTNAME="dns_hack" /openils/bin/osrf_control --localhost --start_all && sleep 3 \
-&& /openils/bin/autogen.sh /openils/conf/opensrf_core.xml \
-&& echo Finis;
-'
-echo Starting services...
-su - opensrf sh -c "$OSRF_COMMAND";
-
-echo Modifying APACHE_RUN_USER/APACHE_RUN_GROUP in /etc/apache2/envvars
-sed -i 's/www-data/opensrf/g' /etc/apache2/envvars
-
-echo Making sure /var/lock/apache2 is owned by opensrf
-chown opensrf:opensrf /var/lock/apache2
-
-echo Modifying KeepAliveTimeout in /etc/apache2/apache2.conf
-sed -i 's/KeepAliveTimeout .*/KeepAliveTimeout 1/' /etc/apache2/apache2.conf
-
-echo Restarting Apache
-/etc/init.d/apache2 restart
+function evergreen_db_prereqs {
+ echo _.-~= Installing Evergreen database pre-requisites
+ if [ $YES ]; then
+ yes | make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install ${EVERGREEN_DB_PREREQ_TARGET}
+ else
+ make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install ${EVERGREEN_DB_PREREQ_TARGET}
+ fi;
+ echo Return Value = $?
+ echo End of Installing Evergreen database pre-requisites =~-._
+}
+
+function setting_ldconfig_and_rsyslog_and_hosts_ejabberd {
+ echo _.-~= setting ld.so.conf and rsyslog and /etc/hosts and ejabberd
+ cp $BASE_DIR/evergreen.ld.conf /etc/ld.so.conf.d/
+ ldconfig;
+ echo Return Value = $?
+ # Configure rsyslog and restart
+ cp /home/opensrf/Evergreen/Open-ILS/examples/evergreen-rsyslog.conf /etc/rsyslog.d/evergreen.conf
+ /etc/init.d/rsyslog restart
+ echo Return Value = $?
+ 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;
-echo End of Starting Evergreen =~-._
+ else
+ echo "INFO: /etc/hosts already has public.localhost line";
+ fi
+ echo Return Value = $?
+ # Patch Ejabberd and register users
+ if [ ! "$(grep 'public.localhost' /etc/ejabberd/ejabberd.cfg)" ]; then
+ cd /etc/ejabberd/
+ /etc/init.d/ejabberd stop;
+ killall beam epmd; # just in case
+ cp ejabberd.cfg /root/ejabberd.cfg.orig
+ patch -p0 < $BASE_DIR/ejabberd.EG.patch
+ chown ejabberd:ejabberd ejabberd.cfg
+ /etc/init.d/ejabberd start
+ echo Return Value = $?
+ sleep 2;
+ 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 = $?
+ fi;
+ echo End of setting ld.so.conf and rsyslog and /etc/hosts and ejabberd =~-._
+}
+
+function build_opensrf {
+ # Build and install OpenSRF
+ echo _.-~= Building OpenSRF
+ OSRF_COMMAND='
+ cd /home/opensrf/OpenSRF;
+ autoreconf -i;
+ ./configure --prefix=/openils --sysconfdir=/openils/conf;
+ make;'
+ su - opensrf sh -c "$OSRF_COMMAND"
+ echo Return Value = $?
+ echo End of Building OpenSRF =~-._
+}
+
+function test_opensrf_build {
+ echo _.-~= Running OpenSRF build tests
+ cd /home/opensrf/OpenSRF;
+ make check
+ echo Return Value = $?
+ echo End of OpenSRF build tests =~-._
+}
+
+function install_opensrf {
+ echo _.-~= Installing OpenSRF
+ make install
+ echo Return Value = $?
+ echo End of Installing OpenSRF =~-._
+}
+
+function build_evergreen {
+ echo _.-~= Building Evergreen
+ OSRF_COMMAND='
+ export PATH=/openils/bin:$PATH
+ cd /home/opensrf/Evergreen;
+ autoreconf -i;
+ ./configure --prefix=/openils --sysconfdir=/openils/conf;
+ make;
+ '
+ su - opensrf sh -c "$OSRF_COMMAND"
+ echo Return Value = $?
+ echo End of Building Evergreen =~-._
+}
+
+function test_evergreen_build {
+ echo _.-~= Running Evergreen build tests
+ cd /home/opensrf/Evergreen
+ make check
+ echo Return Value = $?
+ echo End of Evergreen build tests =~-._
+}
+
+function install_evergreen {
+ echo _.-~= Installing Evergreen
+ make install
+ echo Return Value = $?
+
+ cp /openils/conf/opensrf.xml.example /openils/conf/opensrf.xml
+ cp /openils/conf/opensrf_core.xml.example /openils/conf/opensrf_core.xml
+
+ # fetch and install Dojo
+ cd /tmp;
+ 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 -zxf dojo-release-$DOJO_VERSION.tar.gz;
+ cp -r dojo-release-$DOJO_VERSION/* /openils/var/web/js/dojo/;
+
+ # give it all to opensrf
+ chown -R opensrf:opensrf /openils
+
+ # copy srfsh config into place
+ cp /openils/conf/srfsh.xml.example /home/opensrf/.srfsh.xml;
+ chown opensrf:opensrf /home/opensrf/.srfsh.xml;
+ echo End of Installing Evergreen =~-._
+}
+
+function configure_database {
+ echo _.-~= configure database
+ if [ $YES ]; then
+ echo "Using password evergreen for the evergreen database user."
+ echo -e "evergreen\nevergreen\n" | su - postgres sh -c 'createuser -P -s evergreen;'
+ else
+ echo -e "\n\nPlease enter a password for the evergreen database user.\n If you do not want to edit configs, use \"evergreen\"\n"
+ su - postgres sh -c 'createuser -P -s evergreen;'
+ fi;
-if [ $LIVETEST ]; then
-# TODO: Eventually move these tests into a Make target within Evergreen
+ # Apply the DB schema
+ cd /home/opensrf/Evergreen
+ perl Open-ILS/src/support-scripts/eg_db_config \
+ --create-database \
+ --create-schema \
+ --create-offline \
+ --update-config $SAMPLEDATA \
+ --service all \
+ --user evergreen \
+ --password evergreen \
+ --hostname localhost \
+ --database evergreen \
+ --admin-user $ADMIN_USER \
+ --admin-pass $ADMIN_PASS;
+ echo Return Value = $?
+
+ if [ $LIVETEST ]; then
+ PG_CMD="
+ git clone --depth 0 https://github.com/theory/pgtap.git \
+ && cd pgtap \
+ && make \
+ && make installcheck
+ "
+ su - postgres -c "$PG_CMD"
+ cd /var/lib/postgresql/pgtap \
+ && make install;
+ echo 'CREATE EXTENSION pgtap;' | su - postgres -c "psql evergreen"
+ fi;
+ echo configure database =~-._
+}
+
+function configure_apache {
+ echo _.-~= configure apache
+ /etc/init.d/apache2 stop
+ # Copy apache configs into place and create SSL cert
+ cd /home/opensrf/Evergreen/
+ cp Open-ILS/examples/apache/eg.conf /etc/apache2/sites-available/
+ cp Open-ILS/examples/apache/eg_vhost.conf /etc/apache2/
+ cp Open-ILS/examples/apache/eg_startup /etc/apache2/
+
+ 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 = $?
+ a2enmod rewrite
+ echo Return Value = $?
+ a2enmod expires
+ echo Return Value = $?
+ a2dissite 000-default
+ echo Return Value = $?
+ a2ensite eg.conf
+ echo Return Value = $?
+
+ echo Modifying APACHE_RUN_USER/APACHE_RUN_GROUP in /etc/apache2/envvars
+ sed -i 's/www-data/opensrf/g' /etc/apache2/envvars
+
+ echo Making sure /var/lock/apache2 is owned by opensrf
+ chown opensrf:opensrf /var/lock/apache2
+
+ echo Modifying KeepAliveTimeout in /etc/apache2/apache2.conf
+ sed -i 's/KeepAliveTimeout .*/KeepAliveTimeout 1/' /etc/apache2/apache2.conf
+
+ echo End of configure apache =~-._
+}
+
+function start_evergreen {
+ echo _.-~= Starting Evergreen
+ if [ $LIVETEST ]; then
+ rm /openils/var/log/*.log
+ fi
+
+ OSRF_COMMAND='
+ export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH \
+ && export PATH=/openils/bin:$PATH \
+ && OSRF_HOSTNAME="dns_hack" /openils/bin/osrf_control --localhost --stop_all && sleep 3 \
+ && OSRF_HOSTNAME="dns_hack" /openils/bin/osrf_control --localhost --start_all && sleep 3 \
+ && /openils/bin/autogen.sh /openils/conf/opensrf_core.xml \
+ && echo Finis;
+ '
+ echo Starting services...
+ su - opensrf sh -c "$OSRF_COMMAND";
+ echo Return Value = $?
+
+ echo Restarting Apache
+ /etc/init.d/apache2 restart
+ echo Return Value = $?
+
+ echo End of Starting Evergreen =~-._
+}
+
+function test_evergreen_live {
+ # TODO: Eventually move these tests into a Make target within Evergreen
cd /home/opensrf/Evergreen
echo _.-~= Running pgTAP tests
su - postgres -c 'cd /home/opensrf/Evergreen ; pg_prove -vr -d evergreen Open-ILS/src/sql/Pg/t/ ; echo Return Value = $?'
sudo cpan -l
echo End of system information =~-._
date
-else
- cat <<EOF
-* Test the system
-
-# as opensrf user
-echo "request open-ils.cstore open-ils.cstore.direct.actor.user.retrieve 1" | srfsh
-EOF
-fi;
-
-else
-
- cat <<EOF
-* Start services
-
-su - opensrf
-osrf_control --localhost --start-all && sleep 3;
-/openils/bin/autogen.sh /openils/conf/opensrf_core.xml;
-
-* Test the system
-
-# as opensrf user
-echo "request open-ils.cstore open-ils.cstore.direct.actor.user.retrieve 1" | srfsh
-
-* Now finish configuring Apache
-
-1. s/www-data/opensrf/g in envvars
-2. KeepAliveTimeout 1 in apache2.conf
+}
+my_init
-EOF
-fi;