Index: /gs3-extensions/i-jetty/trunk/src/DEX-TO-PREPARED-SDCARD.sh
===================================================================
--- /gs3-extensions/i-jetty/trunk/src/DEX-TO-PREPARED-SDCARD.sh	(revision 25605)
+++ /gs3-extensions/i-jetty/trunk/src/DEX-TO-PREPARED-SDCARD.sh	(revision 25605)
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+#if [ "x$SDCARD_WEBAPPS" = "x" ] ; then
+#  echo "Environment variable SDCARD_WEBAPPS undefined"
+#  echo "  => No valid directory to install to on Android device"
+#  echo "  => Did you run setup.bash before the Android device was in disk mode?"
+#  echo "  => Alternatively, set the environment variable explicitly"
+#  exit -1
+#fi
+
+if [ "x$PREPARE_SDCARD_GSDL3HOME" = "x" ] ; then
+  echo "Environment variable PREPARE_SDCARD_GSDL3HOME undefined"
+  exit -1
+fi
+
+echo "#---"
+echo "# Copying dexified servlet code to "
+echo "#   $PREPARE_SDCARD_GSDL3HOME/WEB-INF/lib"
+echo "#---"
+echo ""
+
+if [ -d $PREPARE_SDCARD_GSDL3HOME/WEB-INF/lib ] ; then
+  /bin/rm -rf $PREPARE_SDCARD_GSDL3HOME/WEB-INF/lib 
+fi
+
+/bin/cp -r lib $PREPARE_SDCARD_GSDL3HOME/WEB-INF/.
Index: /gs3-extensions/i-jetty/trunk/src/PREPARE-JAVA-TO-DEX.sh
===================================================================
--- /gs3-extensions/i-jetty/trunk/src/PREPARE-JAVA-TO-DEX.sh	(revision 25605)
+++ /gs3-extensions/i-jetty/trunk/src/PREPARE-JAVA-TO-DEX.sh	(revision 25605)
@@ -0,0 +1,136 @@
+#!/bin/bash
+
+if [ "x$PREPARE_SDCARD_GSDL3HOME" = "x" ] ; then
+  echo "Environment variable PREPARE_SDCARD_GSDL3HOME undefined"
+  exit -1
+fi
+
+
+JARS="axis.jar commons-lang3-3.0-beta.jar cp.jar \
+  gsdl3.jar gutil.jar \
+  jdbm.jar js.jar serializer.jar \
+  xercesImpl.jar xml-apis.jar"
+
+# LuceneWrapper.jar and xalan.jar used to be in the list,
+# but are now in modified-jars.  See README.txt in that
+# directory for details
+
+#---
+# Copy GS3 classes files to I-Jetty classes
+#---
+
+if [ -d classes ] ; then
+  echo "#---"
+  echo "# Regenerating directory: classes"
+  echo "#---"
+  /bin/rm -rf classes
+fi
+
+echo "#---"
+echo "# Copying Greenstone-3 classes to the I-Jetty extension"
+/bin/cp -rf "$GSDL3HOME/WEB-INF/classes" classes
+/bin/rm -rf classes/.svn
+
+echo "# Setting GSDL3HOME to match SD-Card on Android device"
+echo "#---"
+
+if [ "x$IJOS" = "xcygwin" ] ; then
+  SDCARD_GSDL3HOME_ONDEVICE=`echo $SDCARD_GSDL3HOME | sed 's@^/.\+/war/@/sdcard/@'`
+else 
+  echo "Need to change mapped location of Android device on host machine" 
+  echo "But no support currently implemented for: $IJOS"
+  SDCARD_GSDL3HOME_ONDEVICE=$PREPARE_SDCARD_GSDL3HOME
+fi
+
+cat classes/global.properties \
+  | sed "s@^gsdl3\.home=.*@gsdl3.home=$SDCARD_GSDL3HOME_ONDEVICE@" \
+  | sed "s@^tomcat\.port=.*@tomcat.port=$IJETTY_PORT@" \
+  > classes/global.properties.android
+
+/bin/mv classes/global.properties.android classes/global.properties
+
+cat classes/log4j.properties \
+  | sed "s@^gsdl3\.home=.*@gsdl3.home=$SDCARD_GSDL3HOME_ONDEVICE@" \
+  > classes/log4j.properties.android
+
+/bin/mv classes/log4j.properties.android classes/log4j.properties
+
+
+#---
+# Copy selected GS3 Jar files to I-Jetty jars
+#---
+
+echo "#---"
+if [ -d jars ] ; then
+  echo "# Regenerating jars"
+  /bin/rm -rf jars
+else
+  echo "# Generating jars"
+fi
+echo "#---"
+mkdir jars
+
+for f in $JARS ; do
+  echo "  Copying from Greenstone-3 to I-Jetty: $f"
+  /bin/cp "$GSDL3HOME/WEB-INF/lib/$f" jars/.
+done
+
+echo "Overriding existings Greenstone jars with ones that needed tweaking for Android"
+/bin/cp -v modified-jars/* jars/.
+
+
+echo "Topping up 'jars' with Android specific jars"
+/bin/cp -v extra-jars/* jars/.
+
+
+#---
+# Generate dex file in I-Jetty 'classes' directory
+#---
+
+
+# If need more memory, add
+# -JXmx1024M
+
+OUTPUT_DEX=$IJETTY_HOME/classes/classes.dex 
+INPUT_DIR=$IJETTY_HOME/jars
+
+
+if [ "x$IJOS" = "xcygwin" ] ; then
+  OUTPUT_DEX=`cygpath -w $OUTPUT_DEX`
+  INPUT_DIR=`cygpath -w $INPUT_DIR`
+fi
+
+# add --verbose for more information
+dx.bat --verbose --dex --core-library --positions=lines --output=$OUTPUT_DEX $INPUT_DIR
+##dx.bat --dex --core-library --positions=lines --output=$OUTPUT_DEX $INPUT_DIR
+
+if [ $? != 0 ] ; then
+  echo "Error(s) encountered when running 'dx'"
+  exit 
+fi
+
+#---
+# Zip up I-Jetty classes directory and put it in lib
+#---
+
+echo "#---"
+if [ -d lib ] ; then
+  echo "# Regenerating directory: lib"
+  /bin/rm -rf lib
+else 
+  echo "# Generating directory: lib"
+fi
+echo "#---"
+mkdir lib
+
+echo "#---"
+echo "Zipping up I-Jetty 'classes' and storing in 'lib'"
+echo "#---"
+(cd classes && zip -r ../lib/classes.zip . && cd ..)
+
+
+echo ""
+echo "####"
+echo "# Run ./DEX-TO-SDCARD.sh to install the latest DEX files on the device"
+echo "####"
+echo ""
Index: /gs3-extensions/i-jetty/trunk/src/PREPARE-WEBAPP-ROOT-FOR-SDCARD.sh
===================================================================
--- /gs3-extensions/i-jetty/trunk/src/PREPARE-WEBAPP-ROOT-FOR-SDCARD.sh	(revision 25605)
+++ /gs3-extensions/i-jetty/trunk/src/PREPARE-WEBAPP-ROOT-FOR-SDCARD.sh	(revision 25605)
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+if [ ! -d $PREPARE_SDCARD_GSDL3HOME ] ; then
+  # First time install has been run => do a full copy
+  mode="Installing"
+
+else
+  # Only need to regenerate 'lib' folder
+  mode="Updating"
+fi
+
+echo "#---"
+echo "# $mode $GSDL3HOME -> $PREPARE_SDCARD_GSDL3HOME"
+echo "# (this may take several minutes)"
+echo "#---"
+echo ""
+
+if [ $mode = "Installing" ] ; then
+  (cd $GSDL3HOME && find . -type d ) \
+    | egrep -v '/\.svn' \
+    | egrep -v 'sites/' \
+    | egrep -v 'WEB-INF/classes' \
+    | egrep -v 'WEB-INF/lib' \
+    | xargs -I {} mkdir -p $PREPARE_SDCARD_GSDL3HOME/{}
+fi
+
+(cd $GSDL3HOME && find . -type f ) \
+  | egrep -v '/\.svn' \
+  | egrep -v 'sites/' \
+  | egrep -v 'WEB-INF/classes' \
+  | egrep -v 'WEB-INF/lib' \
+  | xargs -I {} /bin/cp -u -v $GSDL3HOME/{} $PREPARE_SDCARD_GSDL3HOME/{}
+
+/bin/cp resources/index.html $PREPARE_SDCARD_GSDL3HOME/.
+/bin/cp resources/web.xml $PREPARE_SDCARD_GSDL3HOME/WEB-INF/.
+
+if [ ! -d $PREPARE_SDCARD_GSDL3HOME/sites/localsite ] ; then
+  echo "Creating 'localsite' in $PREPARE_SDCARD_GSDLHOME"
+  mkdir $PREPARE_SDCARD_GSDL3HOME/sites/localsite
+  mkdir $PREPARE_SDCARD_GSDL3HOME/sites/localsite/collect
+fi
+
+/bin/cp -u -v $GSDL3HOME/sites/localsite/siteConfig.xml $PREPARE_SDCARD_GSDL3HOME/sites/localsite/.
+
+/bin/cp -u -v -r $GSDL3HOME/sites/localsite/etc $PREPARE_SDCARD_GSDL3HOME/sites/localsite/.
+
+/bin/cp -u -v -r $GSDL3HOME/sites/localsite/collect/lucene-jdbm-demo $PREPARE_SDCARD_GSDL3HOME/sites/localsite/collect/.
+
+if [ ! -d $PREPARE_SDCARD_GSDL3HOME/sites/localsite/collect/lucene-jdbm-demo/index ] ; then
+  pushd $PREPARE_SDCARD_GSDL3HOME/sites/localsite/collect/lucene-jdbm-demo
+  unzip index.zip
+  popd
+fi
+
+echo ""
+echo "####"
+echo "# If not already done so, run: "
+echo "#   ./JAVA-TO-DEX.sh"
+echo "# to cross-compile the Greenstone code and supporting JAR files"
+echo "####"
+echo ""
+
+
+
