#!/bin/bash

if [ $# != 2 ]
then
    echo "usage: $0 <config-repo-path> <index-path>"
    exit 1
fi

set -e
set -x

MOZSEARCH_PATH=$(cd $(dirname "$0") && git rev-parse --show-toplevel)

export CONFIG_REPO=$(readlink -f $1)
WORKING=$(readlink -f $2)

if [ -z "$KEEP_WORKING" ]; then
    echo "Removing old contents of $WORKING/"
    rm -rf $WORKING/*
else
    echo "Keeping old contents of $WORKING/"
fi

$MOZSEARCH_PATH/scripts/generate-config.sh $CONFIG_REPO $WORKING

CONFIG_FILE=$WORKING/config.json

for TREE_NAME in $($MOZSEARCH_PATH/scripts/read-json.py $CONFIG_FILE trees)
do
   .  $MOZSEARCH_PATH/scripts/load-vars.sh $CONFIG_FILE $TREE_NAME
   mkdir -p $INDEX_ROOT

    $CONFIG_REPO/$TREE_NAME/setup
done

#!/bin/bash

if [ $# != 2 ]
then
    echo "usage: $0 <config-repo-path> <index-path>"
    exit 1
fi

set -e
set -x

MOZSEARCH_PATH=$(cd $(dirname "$0") && git rev-parse --show-toplevel)

export CONFIG_REPO=$(readlink -f $1)
WORKING=$(readlink -f $2)

rm -rf $WORKING/*

$MOZSEARCH_PATH/scripts/generate-config.sh $CONFIG_REPO $WORKING

CONFIG_FILE=$WORKING/config.json

for TREE_NAME in $($MOZSEARCH_PATH/scripts/read-json.py $CONFIG_FILE trees)
do
   .  $MOZSEARCH_PATH/scripts/load-vars.sh $CONFIG_FILE $TREE_NAME
   mkdir -p $INDEX_ROOT

    $CONFIG_REPO/$TREE_NAME/setup
done

--- 
+++ 
@@ -14,7 +14,12 @@
 export CONFIG_REPO=$(readlink -f $1)
 WORKING=$(readlink -f $2)
 
-rm -rf $WORKING/*
+if [ -z "$KEEP_WORKING" ]; then
+    echo "Removing old contents of $WORKING/"
+    rm -rf $WORKING/*
+else
+    echo "Keeping old contents of $WORKING/"
+fi
 
 $MOZSEARCH_PATH/scripts/generate-config.sh $CONFIG_REPO $WORKING
 
Allow preserving the old working dir when setting up the indexer

When indexing mozilla-central, blowing away the working dir is
painful because it has to redownload the world which takes forever.
This allows devs (who know what they are doing) to run indexer-setup
with KEEP_WORKING=1 to keep the working directory instead of
blowing it away.
