Index: /other-projects/nightly-tasks/crons-and-scripts/linux64/create-expeditee.sh
===================================================================
--- /other-projects/nightly-tasks/crons-and-scripts/linux64/create-expeditee.sh	(revision 32402)
+++ /other-projects/nightly-tasks/crons-and-scripts/linux64/create-expeditee.sh	(revision 32402)
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+
+# http://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
+#currentdir=$( cd "$(dirname "$0")" ; pwd -P )
+currentdir=/home/sjm84
+# On the linux VM machines that produce nightlies:
+# set currentdir to /home/sjm84 (after chroot on /opt/lsb) 
+# or set currentdir to home/sjm84 if lsb is only mounted but  
+# the chroot to /opt/lsb step has not been done yet.
+
+if ! test -f "$currentdir/expeditee-release-kits/rke-setup.sh"; then
+	echo ""
+	echo "********************"
+	echo "First edit $currentdir/expeditee-release-kits/rke-setup.sh.in"
+	echo "to generate $currentdir/expeditee-release-kits/rke-setup.sh"
+	echo ""
+	echo "********************"
+	echo ""
+	exit -1
+else
+	# rke-setup uses local paths, so cd into expeditee-release-kits first
+	# then call rke-setup.sh to source the environment vars it sets
+	pushd "$currentdir/expeditee-release-kits"
+	source "rke-setup.sh"
+	returnval=$?
+	if [ "$returnval" != "0" ]; then
+		echo "Error running rke-setup.sh, return value: $returnval"
+		popd
+		exit -2
+	else
+		popd
+
+		# Make sure the expeditee folder and its rke-build.properties file exist
+		# then run the 'rke' command from snapshots\expeditee
+		pushd "$currentdir/snapshots"
+		if test -d expeditee; then
+			echo "Deleting $currentdir/snapshots/expeditee...."
+			rm -rf $currentdir/snapshots/expeditee
+		fi
+		if ! test -d expeditee; then
+			mkdir expeditee
+		fi
+		if ! test -f expeditee/rke-build.properties; then
+			cp $currentdir/expeditee-release-kits/rke-build.properties.in expeditee/rke-build.properties
+		fi
+		pushd expeditee
+		rke
+
+		# http://stackoverflow.com/questions/1401482/yyyy-mm-dd-format-date-in-shell-script
+		DATE=`date +%Y-%m-%d`
+
+		# Uploading
+		mkdir uploads
+		cp products/Expeditee-1${products_suffix} uploads/Expeditee-1-${DATE}${uploads_suffix}
+		cp rke.out uploads/rke-${DATE}${out_suffix}.out
+		cd uploads && tar -c * | ssh -T -i "${identity_file}" anupama@wharariki.cms.waikato.ac.nz
+
+		exit 0
+	fi
+fi
Index: /other-projects/nightly-tasks/crons-and-scripts/linux64/create-expeditee.sh.unused
===================================================================
--- /other-projects/nightly-tasks/crons-and-scripts/linux64/create-expeditee.sh.unused	(revision 32402)
+++ /other-projects/nightly-tasks/crons-and-scripts/linux64/create-expeditee.sh.unused	(revision 32402)
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+currentdir=/home/sjm84
+# On the linux VM machines that produce nightlies:
+# set currentdir to /home/sjm84 (after chroot on /opt/lsb) 
+# or set currentdir to home/sjm84 if lsb is only mounted but  
+# the chroot to /opt/lsb step has not been done yet.
+
+
+if ! test -f "$currentdir/expeditee-release-kits/rke-setup.sh"; then
+	echo ""
+	echo "********************"
+	echo "First edit $currentdir/expeditee-release-kits/rke-setup.sh.in"
+	echo "to generate $currentdir/expeditee-release-kits/rke-setup.sh"
+	echo ""
+	echo "********************"
+	echo ""
+	exit -1
+else
+	# rke-setup uses local paths, so cd into expeditee-release-kits first
+	# then call rke-setup.sh to source the environment vars it sets
+	pushd "$currentdir/expeditee-release-kits"
+	source "rke-setup.sh"
+	returnval=$?
+	if [ "$returnval" != "0" ]; then
+		echo "Error running rke-setup.sh, return value: $returnval"
+		popd
+		exit -2
+	else
+		popd
+
+		# Make sure the expeditee folder and its rke-build.properties file exist
+		# then run the 'rke' command from snapshots\expeditee
+		pushd "$currentdir/snapshots"
+		if test -d expeditee; then
+			echo "Deleting $currentdir/snapshots/expeditee...."
+			rm -rf $currentdir/snapshots/expeditee
+		fi
+		if ! test -d expeditee; then
+			mkdir expeditee
+		fi
+		if ! test -f expeditee/rke-build.properties; then
+			cp $currentdir/expeditee-release-kits/rke-build.properties.in expeditee/rke-build.properties
+		fi
+		pushd expeditee
+		rke
+
+		# http://stackoverflow.com/questions/1401482/yyyy-mm-dd-format-date-in-shell-script
+		DATE=`date +%Y-%m-%d`
+
+		# Uploading
+		mkdir uploads
+		cp products/Expeditee-1-linux uploads/Expeditee-1-${DATE}-linux64
+		cp rke.out uploads/Expeditee-${DATE}-linux64.out
+		cd uploads && tar -c * | ssh -T -i "/root/.ssh/upload-expeditee-l64" anupama@wharariki.cms.waikato.ac.nz
+
+		exit 0
+	fi
+fi
Index: /other-projects/nightly-tasks/crons-and-scripts/linux64/create-release.sh.unused
===================================================================
--- /other-projects/nightly-tasks/crons-and-scripts/linux64/create-release.sh.unused	(revision 32402)
+++ /other-projects/nightly-tasks/crons-and-scripts/linux64/create-release.sh.unused	(revision 32402)
@@ -0,0 +1,133 @@
+#!/bin/bash
+
+# This script, create-release.sh, follows the instructions at
+# http://internal.greenstone.org/wiki/Generating_Caveats_and_Binaries:_Handy_instructions#Generating_the_64_bit_Linux_Caveat
+
+# IF ON DARWIN: sudo su - nzdl 
+# IF ON LINUX: sudo su -
+# Then run this script with gs-release-version and rc-number
+
+# http://stackoverflow.com/questions/6482377/bash-shell-script-check-input-argument
+if [ $# -eq 0 ]; then
+    echo "Run as $0 <version> [release-candidate-number]"    
+    echo "E.g. $0 3.06 rc1"
+    echo ""
+    exit
+fi
+
+# String comparisons http://tldp.org/LDP/abs/html/comparison-ops.html
+os=`uname`
+currmachine=$os
+arch=`uname -m`
+curruser=`whoami`
+if [ "$os" == "Linux" ] && [ "$curruser" != "root" ] ; then
+    echo "On linux release VMs, you need to first have run: sudo su -"
+    echo ""
+    exit
+elif [ "$os" == "Darwin" ] && [ "$curruser" != "nzdl" ] ; then
+    echo "On mac release machines, you need to first have run: sudo su - nzdl"
+    echo ""
+    exit
+fi
+
+
+version=$1
+if [ -n "$2" ]; then
+    versionextra=$2
+fi
+
+
+#######################################################################
+# variables that tend to be fixed for a release machine
+
+linuxpath=/home/sjm84
+darwinpath=/Volumes/Research/nzdl
+toro_relkit_path="${darwinpath}/release-kits"
+rata_relkit_path=/home/nzdl/release-kits
+
+
+#######################################################################
+
+majorversion=3
+# if prefixed with 2, then GS2. http://tldp.org/LDP/abs/html/comparison-ops.html
+if [[ $version == 2* ]]; then
+    majorversion=2;
+fi
+
+
+# Release foldername should use version without dot 
+# http://www.linuxquestions.org/questions/linux-newbie-8/bash-command-for-removing-special-characters-from-string-644828/
+releasefolder=`echo ${version//[-._]/}`
+releasefolder=gs$releasefolder$versionextra
+
+
+if [ "$os" == "Linux" ]; then
+    source ./setup-env.sh
+    # 64 bit or 32 bit linux vm
+    # http://stackoverflow.com/questions/229551/string-contains-in-bash
+    if [[ $arch == *64 ]]; then
+	currmachine+="64"
+	#/bin/mount --bind /proc /opt/lsb-buildenv-x86_64/proc 
+	#chroot /opt/lsb-buildenv-x86_64
+    #else
+	#/bin/mount --bind /proc /opt/lsb-buildenv-ia32/proc 
+	#chroot /opt/lsb-buildenv-ia32
+    fi
+    export PATH="${linuxpath}/release-kits/bin:$PATH"
+    #echo "PATH : $PATH"
+    cd "${linuxpath}/snapshots"
+
+elif [ "$os" == "Darwin" ]; then
+    kernel_release_ver=`uname -r`    
+    if [[ $kernel_release_ver == 12.5* ]]; then
+	# toro is 12.5.0
+	currmachine+="MountainLion"
+	export PATH=$toro_relkit_path/bin:$PATH
+    elif [[ $kernel_release_ver == 9.8* ]]; then
+	# rata is 9.8.0
+	currmachine+="Leopard"
+	export PATH="${rata_relkit_path}/bin:$PATH"
+    fi
+
+    cd "${darwinpath}/snapshots"
+else
+    # not a known OS
+    echo "Unknown OS $os. Cannot generate release-binary. Exitting."
+    echo ""
+    exit
+fi
+
+
+mkdir $releasefolder
+cd $releasefolder
+
+# create the rk properties file
+propfile="rk$majorversion"
+propfile+="-build.properties"
+touch $propfile
+
+echo "version:$version" > $propfile
+
+# http://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash
+# boolean operators: http://www.tldp.org/LDP/abs/html/ops.html
+if [ -n "$versionextra" ] && [ "$versionextra" != "" ]; then
+    echo "version-extra:$versionextra" >> $propfile
+fi
+
+# os = Linux|Darwin. We wouldn't be here if the os was windows
+# if GS2, add property pointing to server.exe
+if [ "$majorversion" == "2" ]; then
+    echo "server.exe.location:http://www.greenstone.org/caveat-emptor/latest-server.exe" >> $propfile
+fi
+
+# Add in architecture, if 64-bit
+# http://stackoverflow.com/questions/229551/string-contains-in-bash
+if [[ $arch == *64 ]]; then
+    echo "x64:true" >> $propfile
+fi
+
+# add an empty line
+echo "" >> $propfile
+
+# run `rk3` or `rk2` from the releasefolder
+`rk$majorversion`
Index: /other-projects/nightly-tasks/crons-and-scripts/linux64/gen-release.sh
===================================================================
--- /other-projects/nightly-tasks/crons-and-scripts/linux64/gen-release.sh	(revision 32402)
+++ /other-projects/nightly-tasks/crons-and-scripts/linux64/gen-release.sh	(revision 32402)
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+echo "RUNNING $* " > out.txt
+env >> out.txt
+cd /home/sjm84/envi/bin
+./envi release $*
Index: /other-projects/nightly-tasks/crons-and-scripts/linux64/linux64_crontab_file
===================================================================
--- /other-projects/nightly-tasks/crons-and-scripts/linux64/linux64_crontab_file	(revision 32402)
+++ /other-projects/nightly-tasks/crons-and-scripts/linux64/linux64_crontab_file	(revision 32402)
@@ -0,0 +1,6 @@
+# m h  dom mon dow   command
+
+01 1 * * * /bin/mount --bind /proc /opt/lsb-buildenv-x86_64/proc
+30 1 * * * /usr/sbin/chroot /opt/lsb-buildenv-x86_64 ./create-expeditee.sh
+00 2 * * * /usr/sbin/chroot /opt/lsb-buildenv-x86_64 ./run-gs2-caveat.sh ; ./run-gs2-caveat.sh wrap
+00 3 * * * /usr/sbin/chroot /opt/lsb-buildenv-x86_64 ./run-gs3-caveat.sh ; ./run-gs3-caveat.sh wrap
Index: /other-projects/nightly-tasks/crons-and-scripts/linux64/run-gs2-caveat.sh
===================================================================
--- /other-projects/nightly-tasks/crons-and-scripts/linux64/run-gs2-caveat.sh	(revision 32402)
+++ /other-projects/nightly-tasks/crons-and-scripts/linux64/run-gs2-caveat.sh	(revision 32402)
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+
+if [ "x$1" != "xwrap" ]; then
+    echo "RUNNING GS2 CAVEAT at " `date` > out.txt
+    env >> out.txt
+    cd /home/sjm84/envi/bin
+    ./envi gs2-caveat-x64 $*
+else
+
+# REDO the WRAP step, in case it failed
+# - prepend release-kits/bin to PATH (and also have access to svn)
+#source ./setup-env.sh
+# - go to the release folder and run the steps for the wrap stage:
+#cd /home/sjm84/snapshots/gs2-caveat-x64/from-*
+#rk2 create-installer
+#rk2 wrap
+# go back and run the upload step
+#cd /
+##cd -
+#./run-gs2-caveat.sh upload
+
+
+# $1 = "wrap"
+# On the 32 bit linux, the wrapping stage sometimes 
+# fails when calculating sizeof during wrapping
+# Everything until then has usually worked, so we just
+# re-try wrapping to make the nightly binaries go through
+
+    cd /
+    source ./setup-env.sh
+
+    export PATH=/home/sjm84/release-kits/bin/:$PATH
+
+    # the star at the end does tab-completion
+    cd /home/sjm84/snapshots/gs2-caveat/from*
+    
+    # store a copy of the original build log
+    mv rk2.out rk2orig.out
+
+    #rk2 create-installer
+    rk2 wrap
+
+    # concatenate current log to the original build log, overwriting any previous rk2.out
+    # http://stackoverflow.com/questions/2150614/bash-shell-scripting-combining-txt-into-one-file
+    mv rk2.out rk2wrap.out
+    cat rk*.out > rk2.out
+    rm rk2wrap.out
+    rm rk2orig.out
+
+    # upload the newly wrapped binary and the log
+    cd /home/sjm84/envi/bin
+    ./envi gs2-caveat upload
+
+    # back to lsb root
+    cd /
+fi
Index: /other-projects/nightly-tasks/crons-and-scripts/linux64/run-gs3-caveat.sh
===================================================================
--- /other-projects/nightly-tasks/crons-and-scripts/linux64/run-gs3-caveat.sh	(revision 32402)
+++ /other-projects/nightly-tasks/crons-and-scripts/linux64/run-gs3-caveat.sh	(revision 32402)
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+
+if [ "x$1" != "xwrap" ]; then
+    echo "RUNNING GS3 CAVEAT at " `date` > out.txt
+    env >> out.txt
+    cd /home/sjm84/envi/bin
+    ./envi gs3-caveat-x64 $*
+
+else
+# $1 = "wrap"
+# On the 32 bit linux, the wrapping stage sometimes 
+# fails when calculating sizeof during wrapping
+# Everything until then has usually worked, so we just
+# re-try wrapping to make the nightly binaries go through
+
+    cd /
+    source ./setup-env.sh
+
+    export PATH=/home/sjm84/release-kits/bin/:$PATH
+
+    # the star at the end does tab-completion
+    cd /home/sjm84/snapshots/gs3-caveat/from*
+    
+    # store a copy of the original build log
+    mv rk3.out rk3orig.out
+
+    #rk3 create-installer
+    rk3 wrap
+
+    # concatenate current log to the original build log, overwriting any previous rk3.out
+    # http://stackoverflow.com/questions/2150614/bash-shell-scripting-combining-txt-into-one-file
+    mv rk3.out rk3wrap.out
+    cat rk*.out > rk3.out
+    rm rk3wrap.out
+    rm rk3orig.out
+
+    # upload the newly wrapped binary and the log
+    cd /home/sjm84/envi/bin
+    ./envi gs3-caveat upload
+
+    # back to lsb root
+    cd /
+fi
Index: /other-projects/nightly-tasks/crons-and-scripts/linux64/setup-env.sh
===================================================================
--- /other-projects/nightly-tasks/crons-and-scripts/linux64/setup-env.sh	(revision 32402)
+++ /other-projects/nightly-tasks/crons-and-scripts/linux64/setup-env.sh	(revision 32402)
@@ -0,0 +1,32 @@
+HOME_DIR=/home/sjm84
+
+#JAVA
+export JAVA_HOME=$HOME_DIR/jdk1.6.0_22
+#export JAVA_HOME=$HOME_DIR/jdk1.7.0_80
+echo Setting JAVA_HOME to $JAVA_HOME
+export PATH=$JAVA_HOME/bin:$PATH
+echo Adding $JAVA_HOME/bin to PATH
+export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/amd64/jli:$LD_LIBRARY_PATH
+echo Adding $JAVA_HOME/jre/lib/amd64/jli to LD_LIBRARY_PATH
+
+#ANT
+export ANT_HOME=$HOME_DIR/apache-ant-1.8.1
+echo Setting ANT_HOME to $ANT_HOME
+export PATH=$ANT_HOME/bin:$PATH
+echo Adding $ANT_HOME/bin to PATH
+
+#SVN
+export PATH=$HOME_DIR/subversion/src/linux/bin:$PATH
+export LD_LIBRARY_PATH=$HOME_DIR/subversion/src/linux/lib:$LD_LIBRARY_PATH
+#export PATH=$HOME_DIR/greenstone2/ext/svn/linux/bin:$PATH
+echo Adding $HOME_DIR/subversion/src/linux/bin to PATH and setting LD_LIB_PATH
+
+#RELEASE-KITS
+export PATH=$HOME_DIR/release-kits/bin:$PATH
+echo Adding $HOME_DIR/release-kits/bin to PATH
+export LC_ALL=C
+
+#already_set=`echo $CFLAGS | grep fPIC`
+#if [ "x$already_set" = "x" ] ; then
+#    export CFLAGS=-fPIC $CFLAGS
+#fi
