adds arguments for full-auto install and run
authorJason Etheridge <jason@esilibrary.com>
Tue, 9 Jul 2013 19:20:06 +0000 (15:20 -0400)
committerJason Etheridge <jason@esilibrary.com>
Thu, 11 Jul 2013 15:33:31 +0000 (11:33 -0400)
-y will supply yes or enter presses to every prompt the installer would
otherwise ask for, and supply 'evergreen' as the default password for the
evergreen database user, and also automate the editing of /etc/hosts

-a will automatically start OpenSRF, modify some Apache settings, and
restart Apache

This commit also changes the default branch from
collab/berick/debian-wheezy-install-target to
collab/berick/per-distro-install-makefiles

and makes shallow git clones

Thanks to Bill and Lebbeous for help on this.

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
installer/wheezy/eg_wheezy_installer.sh

index 37c75a9..91621dd 100755 (executable)
@@ -27,11 +27,34 @@ ADMIN_PASS='demo123';
 # -----------------------------------------------------------------------
 
 # -----------------------------------------------------------------------
+# Handling passed arguments to the script
+# -----------------------------------------------------------------------
+while getopts ay option
+do
+        case "${option}"
+        in
+                a) AUTOSTART=1;;
+                y) YES=1;;
+        esac
+done
+
+# -----------------------------------------------------------------------
 # force CPAN to load by installing something that should already be installed
-cpan Fcntl
+if [ $YES ]; then
+    yes | cpan Fcntl
+else
+    cpan Fcntl
+fi
 
 # 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 '
 
 -----------------------------------------------------------------------
@@ -50,8 +73,9 @@ echo -e "o conf prerequisites_policy ask\n o conf commit" | cpan
         fi;
     done;
 fi;
-# -----------------------------------------------------------------------
+fi;
 
+# -----------------------------------------------------------------------
 
 # And they're off...
 BASE_DIR=$PWD
@@ -73,19 +97,29 @@ export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRAR
 fi;
 
 # XXX for now, fetch the debian-wheezy install target working branches and merge in master
-# XXX The git-config pieces are only necessary for merging the working branches
-OSRF_COMMAND='
+# 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/berick/per-distro-install-makefiles'
+OSRF_COMMAND="
 cd /home/opensrf;
-git clone git://git.evergreen-ils.org/OpenSRF.git;
-git clone git://git.evergreen-ils.org/Evergreen.git;
-'
+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
 su - opensrf sh -c "$OSRF_COMMAND";
 
 # Install pre-reqs
 mkdir -p /usr/src/evergreen; 
 cd /usr/src/evergreen;
-make -f /home/opensrf/OpenSRF/src/extras/Makefile.install debian-wheezy
-make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install debian-wheezy install_pgsql_server_debs_91
+if [ $YES ]; then
+    yes | make -f /home/opensrf/OpenSRF/src/extras/Makefile.install debian-wheezy
+    yes | make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install debian-wheezy postgres-server-debian-wheezy
+else
+    make -f /home/opensrf/OpenSRF/src/extras/Makefile.install debian-wheezy
+    make -f /home/opensrf/Evergreen/Open-ILS/src/extras/Makefile.install debian-wheezy postgres-server-debian-wheezy
+fi;
 
 # Configure rsyslog and restart
 cp /home/opensrf/Evergreen/Open-ILS/examples/evergreen-rsyslog.conf /etc/rsyslog.d/evergreen.conf
@@ -140,7 +174,7 @@ cp /openils/conf/opensrf_core.xml.example /openils/conf/opensrf_core.xml
 
 # fetch and install Dojo
 cd /tmp;
-wget "http://download.dojotoolkit.org/release-$DOJO_VERSION/dojo-release-$DOJO_VERSION.tar.gz";
+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/;
 
@@ -151,8 +185,13 @@ chown -R opensrf:opensrf /openils
 cp /openils/conf/srfsh.xml.example /home/opensrf/.srfsh.xml;
 chown opensrf:opensrf /home/opensrf/.srfsh.xml;
 
-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;'
+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
@@ -177,7 +216,11 @@ 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";
-    openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key
+    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
@@ -188,8 +231,14 @@ a2enmod expires
 a2dissite 000-default
 a2ensite eg.conf
 
-
 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.
@@ -198,12 +247,48 @@ if [ ! "$(grep 'public.localhost' /etc/hosts)" ]; then
 127.0.1.3   private.localhost   private
 
 EOF
+    fi;
 
 else
     echo "INFO: /etc/hosts already has public.localhost line";
 fi
 
+if [ $AUTOSTART ]; then
+
+OSRF_COMMAND='
+export LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH \
+&& export PATH=/openils/bin:$PATH \
+&& /openils/bin/osrf_ctl.sh -l -a start_router && sleep 5 \
+&& /openils/bin/osrf_ctl.sh -l -a start_perl   && sleep 10 \
+&& /openils/bin/osrf_ctl.sh -l -a start_c      && 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
+
 cat <<EOF
+* Test the system
+
+# as opensrf user
+echo "request open-ils.cstore open-ils.cstore.direct.actor.user.retrieve 1" | srfsh
+EOF
+
+else
+
+    cat <<EOF
 * Start services
 
 su - opensrf
@@ -225,4 +310,4 @@ echo "request open-ils.cstore open-ils.cstore.direct.actor.user.retrieve 1" | sr
 
 EOF
 
-
+fi;