#!/bin/sh
# Arch incremental daily crawling script. Normally, this script
# should be run daily by cron. Arch will re-index only areas that are
# due to be reindexed.
#
# To customise, set the variables below

# Arch home directory
# Example: ARCH_HOME=/opt/arch-1.4

ARCH_HOME=

# Path to Java version to use
# Example JAVA_HOME=/usr/lib/jvm/java-6-sun

JAVA_HOME=

HADOOP_LIBS=$ARCH_HOME/lib/native

# Uncomment one (but not both!) of the lines below to use Hadoop native libraries
# Do not uncomment anything if your platform is not Linux 64 or Linux 32

#HADOOP_LIBS=$HADOOP_LIBS/Linux-amd64-64
#HADOOP_LIBS=$HADOOP_LIBS/Linux-i386-32

set -x

# Nutch home directory
NUTCH_HOME=$ARCH_HOME ; export NUTCH_HOME
export JAVA_HOME

arch=$ARCH_HOME

PATH=/usr/local/bin:$JAVA_HOME/bin:/usr/bin:/bin; export PATH
LIBS=$( echo $arch/lib/*jar . | sed 's/ /:/g')
CLASSP=.:$JAVA_HOME:$arch:$arch/conf:$LIBS
LDLIBS=$LD_LIBRARY_PATH:$HADOOP_LIBS


# java VM options to use
# WARNING: Whatever amount of available memory you allocate to Java VM,
# make sure that at least the same amount remains available in the free
# memory plus swap space. Hadoop forks external processes to access shell
# functions. This requires as much addidtional memory as the JVM uses.
#
opts="-XX:+UseConcMarkSweepGC -Xms500m -Xmx6000m -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=30 -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled"

# Uncomment one of the command lines to use

# To generate encryption keys, uncomment and modify the two lines below
#java $opts -cp $CLASSP au.csiro.cass.arch.logProcessing.LogProcessor \
       -a gk -c $arch/conf/arch/config.txt -o $arch/conf/arch/

# To generate, compress and encrypt a log digest, uncomment and modify the two lines below
#java $opts -cp $CLASSP au.csiro.cass.arch.logProcessing.LogProcessor \
#     -a es -z -k $arch/conf/arch/public.key -c $arch/conf/arch/config.txt -s MySite -o /var/www/vhosts/MySite/docroot/arch/sitemap.dat

# For normal processing, which includes processing of new locally available logs and indexing, use this
java $opts -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8001 -Djava.library.path=$LDLIBS -cp $CLASSP au.csiro.cass.arch.index.Indexer 

# For a remote debugging session, use this
#java $opts -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8001 -Djava.library.path=$LDLIBS -cp $CLASSP au.csiro.cass.arch.index.Indexer



