Apache Nutch is an extensible and scalable web crawler
NUTCH-1566 bin/nutch to allow whitespace in paths
Sebastian Nagel282af5ef4fc3
diff --git a/CHANGES.txt b/CHANGES.txtindex a1db58ddd..7a56bc8d4 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,6 +2,8 @@ Nutch Change LogNutch Current Development+* NUTCH-1566 bin/nutch to allow whitespace in paths (tejasp, snagel)+* NUTCH-1605 MIME type detector recognizes xlsx as zip file (snagel)* NUTCH-1802 Move TestbedProxy to test environment (jnioche)diff --git a/src/bin/crawl b/src/bin/crawlindex d869fb1e8..e3f06d148 100644--- a/src/bin/crawl+++ b/src/bin/crawl@@ -69,12 +69,12 @@ numThreads=50#############################################-bin=`dirname "$0"`-bin=`cd "$bin"; pwd`+bin="`dirname "$0"`"+bin="`cd "$bin"; pwd`"# determines whether mode based on presence of job filemode=local-if [ -f ${bin}/../*nutch*.job ]; then+if [ -f "${bin}"/../*nutch*.job ]; thenmode=distributedfi@@ -91,7 +91,7 @@ if [ $mode = "distributed" ]; thenfi# initial injection-$bin/nutch inject $CRAWL_PATH/crawldb $SEEDDIR+"$bin/nutch" inject "$CRAWL_PATH"/crawldb "$SEEDDIR"if [ $? -ne 0 ]then exit $?@@ -110,7 +110,7 @@ doecho `date` ": Iteration $a of $LIMIT"echo "Generating a new segment"- $bin/nutch generate $commonOptions $CRAWL_PATH/crawldb $CRAWL_PATH/segments -topN $sizeFetchlist -numFetchers $numSlaves -noFilter+ "$bin/nutch" generate $commonOptions "$CRAWL_PATH"/crawldb "$CRAWL_PATH"/segments -topN $sizeFetchlist -numFetchers $numSlaves -noFilterif [ $? -ne 0 ]then exit $?@@ -121,16 +121,16 @@ do# or use lsif [ $mode = "local" ]; then- SEGMENT=`ls $CRAWL_PATH/segments/ | sort -n | tail -n 1`+ SEGMENT=`ls "$CRAWL_PATH"/segments/ | sort -n | tail -n 1`else- SEGMENT=`hadoop fs -ls $CRAWL_PATH/segments/ | grep segments | sed -e "s/\//\\n/g" | egrep 20[0-9]+ | sort -n | tail -n 1`+ SEGMENT=`hadoop fs -ls "$CRAWL_PATH"/segments/ | grep segments | sed -e "s/\//\\n/g" | egrep 20[0-9]+ | sort -n | tail -n 1`fiecho "Operating on segment : $SEGMENT"# fetching the segmentecho "Fetching : $SEGMENT"- $bin/nutch fetch $commonOptions -D fetcher.timelimit.mins=$timeLimitFetch $CRAWL_PATH/segments/$SEGMENT -noParsing -threads $numThreads+ "$bin/nutch" fetch $commonOptions -D fetcher.timelimit.mins=$timeLimitFetch "$CRAWL_PATH"/segments/$SEGMENT -noParsing -threads $numThreadsif [ $? -ne 0 ]then exit $?@@ -141,7 +141,7 @@ do# enable the skipping of records for the parsing so that a dodgy document# so that it does not fail the full taskskipRecordsOptions="-D mapred.skip.attempts.to.start.skipping=2 -D mapred.skip.map.max.skip.records=1"- $bin/nutch parse $commonOptions $skipRecordsOptions $CRAWL_PATH/segments/$SEGMENT+ "$bin/nutch" parse $commonOptions $skipRecordsOptions "$CRAWL_PATH"/segments/$SEGMENTif [ $? -ne 0 ]then exit $?@@ -149,7 +149,7 @@ do# updatedb with this segmentecho "CrawlDB update"- $bin/nutch updatedb $commonOptions $CRAWL_PATH/crawldb $CRAWL_PATH/segments/$SEGMENT+ "$bin/nutch" updatedb $commonOptions "$CRAWL_PATH"/crawldb "$CRAWL_PATH"/segments/$SEGMENTif [ $? -ne 0 ]then exit $?@@ -158,7 +158,7 @@ do# note that the link inversion - indexing routine can be done within the main loop# on a per segment basisecho "Link inversion"- $bin/nutch invertlinks $CRAWL_PATH/linkdb $CRAWL_PATH/segments/$SEGMENT+ "$bin/nutch" invertlinks "$CRAWL_PATH"/linkdb "$CRAWL_PATH"/segments/$SEGMENTif [ $? -ne 0 ]then exit $?@@ -172,14 +172,14 @@ dofiecho "Indexing $SEGMENT on SOLR index -> $SOLRURL"- $bin/nutch index -D solr.server.url=$SOLRURL $CRAWL_PATH/crawldb -linkdb $CRAWL_PATH/linkdb $CRAWL_PATH/segments/$SEGMENT+ "$bin/nutch" index -D solr.server.url=$SOLRURL "$CRAWL_PATH"/crawldb -linkdb "$CRAWL_PATH"/linkdb "$CRAWL_PATH"/segments/$SEGMENTif [ $? -ne 0 ]then exit $?fiecho "Cleanup on SOLR index -> $SOLRURL"- $bin/nutch clean -D solr.server.url=$SOLRURL $CRAWL_PATH/crawldb+ "$bin/nutch" clean -D solr.server.url=$SOLRURL "$CRAWL_PATH"/crawldbif [ $? -ne 0 ]then exit $?diff --git a/src/bin/nutch b/src/bin/nutchindex 502ffb133..7e60fc00f 100755--- a/src/bin/nutch+++ b/src/bin/nutch@@ -25,6 +25,14 @@# Default is 1000.## NUTCH_OPTS Extra Java runtime options.+# Multiple options must be separated by white space.+#+# NUTCH_LOG_DIR Log directory (default: $NUTCH_HOME/logs)+#+# NUTCH_LOGFILE Log file (default: hadoop.log)+#+# NUTCH_CONF_DIR Path(s) to configuration files (default: $NUTCH_HOME/conf).+# Multiple paths must be separated by a colon ':'.#cygwin=falsecase "`uname`" in@@ -86,13 +94,13 @@ COMMAND=$1shift# some directories-THIS_DIR=`dirname "$THIS"`-NUTCH_HOME=`cd "$THIS_DIR/.." ; pwd`+THIS_DIR="`dirname "$THIS"`"+NUTCH_HOME="`cd "$THIS_DIR/.." ; pwd`"# some Java parametersif [ "$NUTCH_JAVA_HOME" != "" ]; then#echo "run java in $NUTCH_JAVA_HOME"- JAVA_HOME=$NUTCH_JAVA_HOME+ JAVA_HOME="$NUTCH_JAVA_HOME"fiif [ "$JAVA_HOME" = "" ]; then@@ -103,19 +111,18 @@ filocal=true# NUTCH_JOB-if [ -f ${NUTCH_HOME}/*nutch*.job ]; then- local=false- for f in $NUTCH_HOME/*nutch*.job; do- NUTCH_JOB=$f;+if [ -f "${NUTCH_HOME}"/*nutch*.job ]; then+ local=false+ for f in "$NUTCH_HOME"/*nutch*.job; do+ NUTCH_JOB="$f"done+ # cygwin path translation+ if $cygwin; then+ NUTCH_JOB="`cygpath -p -w "$NUTCH_JOB"`"+ fifi-# cygwin path translation-if $cygwin; then- NUTCH_JOB=`cygpath -p -w "$NUTCH_JOB"`-fi--JAVA=$JAVA_HOME/bin/java+JAVA="$JAVA_HOME/bin/java"JAVA_HEAP_MAX=-Xmx1000m# check envvars which might override default args@@ -126,46 +133,47 @@ if [ "$NUTCH_HEAPSIZE" != "" ]; thenfi# CLASSPATH initially contains $NUTCH_CONF_DIR, or defaults to $NUTCH_HOME/conf-CLASSPATH=${NUTCH_CONF_DIR:=$NUTCH_HOME/conf}-CLASSPATH=${CLASSPATH}:$JAVA_HOME/lib/tools.jar+CLASSPATH="${NUTCH_CONF_DIR:=$NUTCH_HOME/conf}"+CLASSPATH="${CLASSPATH}:$JAVA_HOME/lib/tools.jar"# so that filenames w/ spaces are handled correctly in loops belowIFS=# add libs to CLASSPATHif $local; then- for f in $NUTCH_HOME/lib/*.jar; do- CLASSPATH=${CLASSPATH}:$f;+ for f in "$NUTCH_HOME"/lib/*.jar; do+ CLASSPATH="${CLASSPATH}:$f";done# local runtime# add plugins to classpathif [ -d "$NUTCH_HOME/plugins" ]; then- CLASSPATH=${NUTCH_HOME}:${CLASSPATH}+ CLASSPATH="${NUTCH_HOME}:${CLASSPATH}"fifi# cygwin path translationif $cygwin; then- CLASSPATH=`cygpath -p -w "$CLASSPATH"`+ CLASSPATH="`cygpath -p -w "$CLASSPATH"`"fi# setup 'java.library.path' for native-hadoop code if necessary# used only in local modeJAVA_LIBRARY_PATH=''if [ -d "${NUTCH_HOME}/lib/native" ]; then- JAVA_PLATFORM=`CLASSPATH=${CLASSPATH} ${JAVA} org.apache.hadoop.util.PlatformName | sed -e 's/ /_/g'`-++ JAVA_PLATFORM=`"${JAVA}" -classpath "$CLASSPATH" org.apache.hadoop.util.PlatformName | sed -e 's/ /_/g'`+if [ -d "${NUTCH_HOME}/lib/native" ]; thenif [ "x$JAVA_LIBRARY_PATH" != "x" ]; then- JAVA_LIBRARY_PATH=${JAVA_LIBRARY_PATH}:${NUTCH_HOME}/lib/native/${JAVA_PLATFORM}+ JAVA_LIBRARY_PATH="${JAVA_LIBRARY_PATH}:${NUTCH_HOME}/lib/native/${JAVA_PLATFORM}"else- JAVA_LIBRARY_PATH=${NUTCH_HOME}/lib/native/${JAVA_PLATFORM}+ JAVA_LIBRARY_PATH="${NUTCH_HOME}/lib/native/${JAVA_PLATFORM}"fififiif [ $cygwin = true -a "X${JAVA_LIBRARY_PATH}" != "X" ]; then- JAVA_LIBRARY_PATH=`cygpath -p -w "$JAVA_LIBRARY_PATH"`+ JAVA_LIBRARY_PATH="`cygpath -p -w "$JAVA_LIBRARY_PATH"`"fi# restore ordinary behaviour@@ -181,14 +189,14 @@ fi#Fix log path under cygwinif $cygwin; then- NUTCH_LOG_DIR=`cygpath -p -w "$NUTCH_LOG_DIR"`+ NUTCH_LOG_DIR="`cygpath -p -w "$NUTCH_LOG_DIR"`"fi-NUTCH_OPTS="$NUTCH_OPTS -Dhadoop.log.dir=$NUTCH_LOG_DIR"-NUTCH_OPTS="$NUTCH_OPTS -Dhadoop.log.file=$NUTCH_LOGFILE"+NUTCH_OPTS=($NUTCH_OPTS -Dhadoop.log.dir="$NUTCH_LOG_DIR")+NUTCH_OPTS=("${NUTCH_OPTS[@]}" -Dhadoop.log.file="$NUTCH_LOGFILE")if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then- NUTCH_OPTS="$NUTCH_OPTS -Djava.library.path=$JAVA_LIBRARY_PATH"+ NUTCH_OPTS=("${NUTCH_OPTS[@]}" -Djava.library.path="$JAVA_LIBRARY_PATH")fi# figure out which class to run@@ -253,17 +261,17 @@ elif [ "$COMMAND" = "nodedumper" ] ; thenelif [ "$COMMAND" = "plugin" ] ; thenCLASS=org.apache.nutch.plugin.PluginRepositoryelif [ "$COMMAND" = "junit" ] ; then- CLASSPATH=$CLASSPATH:$NUTCH_HOME/test/classes/+ CLASSPATH="$CLASSPATH:$NUTCH_HOME/test/classes/"CLASS=junit.textui.TestRunnerelseCLASS=$COMMANDfi# distributed mode-EXEC_CALL="hadoop jar $NUTCH_JOB"+EXEC_CALL=(hadoop jar "$NUTCH_JOB")if $local; then- EXEC_CALL="$JAVA $JAVA_HEAP_MAX $NUTCH_OPTS -classpath $CLASSPATH"+ EXEC_CALL=("$JAVA" $JAVA_HEAP_MAX "${NUTCH_OPTS[@]}" -classpath "$CLASSPATH")else# check that hadoop can be found on the pathif [ $(which hadoop | wc -l ) -eq 0 ]; then@@ -273,5 +281,5 @@ elsefi# run it-exec $EXEC_CALL $CLASS "$@"+exec "${EXEC_CALL[@]}" $CLASS "$@"