# -----------------------------------------------------------------------
# -----------------------------------------------------------------------
+# 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 '
-----------------------------------------------------------------------
fi;
done;
fi;
-# -----------------------------------------------------------------------
+fi;
+# -----------------------------------------------------------------------
# And they're off...
BASE_DIR=$PWD
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
# 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/;
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
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
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.
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
EOF
-
+fi;