more de-bash-ing

git-svn-id: http://google-refine.googlecode.com/svn/trunk@426 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-04-08 20:45:02 +00:00
parent fff6eb0aa2
commit be084ff0da

108
gridworks
View File

@ -87,7 +87,7 @@ load_configs() {
} }
check_macosx() { check_macosx() {
if [ "$SYSTEM" != 'Darwin' ] ; then if [ "$SYSTEM" != 'Darwin' ]; then
error "This action can only run on MacOSX" error "This action can only run on MacOSX"
fi fi
} }
@ -104,18 +104,18 @@ check_downloaders() {
check_unzip() { check_unzip() {
UNZIP="`which unzip`" UNZIP="`which unzip`"
if [ -z "$UNZIP" ] ; then if [ -z "$UNZIP" ]; then
error "We need 'unzip' present in PATH to expand external dependencies." error "We need 'unzip' present in PATH to expand external dependencies."
fi fi
} }
check_python() { check_python() {
PYTHON="`which python`" PYTHON="`which python`"
if [ -z "$PYTHON" ] ; then if [ -z "$PYTHON" ]; then
error "This action requires you to have 'python' installed. You can download it for free at http://www.python.org/" error "This action requires you to have 'python' installed. You can download it for free at http://www.python.org/"
fi fi
PYTHON_VERSION="`python --version 2>&1 | cut -f 2 -d ' ' | cut -f 1,2 -d .`" PYTHON_VERSION="`python --version 2>&1 | cut -f 2 -d ' ' | cut -f 1,2 -d .`"
if [ "$PYTHON_VERSION" != "2.5" -a "$PYTHON_VERSION" != "2.6" ] ; then if [ "$PYTHON_VERSION" != "2.5" -a "$PYTHON_VERSION" != "2.6" ]; then
error "This action requires python version 2.5.x or 2.6.x. You can download it for free at http://www.python.org/" error "This action requires python version 2.5.x or 2.6.x. You can download it for free at http://www.python.org/"
fi fi
} }
@ -124,9 +124,9 @@ check_running() {
check_downloaders check_downloaders
URL="http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/" URL="http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/"
if [ "$CURL" ] ; then if [ "$CURL" ]; then
NOT_RUNNING=`curl -s $URL > /dev/null || echo not_running` NOT_RUNNING=`curl -s $URL > /dev/null || echo not_running`
elif [ "$WGET" ] ; then elif [ "$WGET" ]; then
NOT_RUNNING=`wget -q -O - $URL > /dev/null || echo not_running` NOT_RUNNING=`wget -q -O - $URL > /dev/null || echo not_running`
fi fi
} }
@ -134,7 +134,7 @@ check_running() {
get_version() { get_version() {
VERSION="$1" VERSION="$1"
if [ -z "$VERSION" ] ; then if [ -z "$VERSION" ]; then
fail "Must specify a version number" fail "Must specify a version number"
fi fi
@ -159,9 +159,9 @@ download() {
check_downloaders check_downloaders
if [ "$CURL" ] ; then if [ "$CURL" ]; then
curl -L -o $DEST $URL || exit "Error while downloading $URL" curl -L -o $DEST $URL || exit "Error while downloading $URL"
elif [ "$WGET" ] ; then elif [ "$WGET" ]; then
wget -O $DEST $URL || error "Error while downloading $URL" wget -O $DEST $URL || error "Error while downloading $URL"
fi fi
} }
@ -172,14 +172,14 @@ tool_download() {
DIR=$3 DIR=$3
cd $GRIDWORKS_TOOLS_DIR cd $GRIDWORKS_TOOLS_DIR
if [ ! -f "$FILE" ] ; then if [ ! -f "$FILE" ]; then
download $URL $FILE download $URL $FILE
fi fi
if [ ! -d "$DIR" ] ; then if [ ! -d "$DIR" ]; then
if [ -z "`echo $FILE | sed 's@.*.tar.gz$@@' | sed 's@.*.tgz$@@'`" ] ; then if [ -z "`echo $FILE | sed 's@.*.tar.gz$@@' | sed 's@.*.tgz$@@'`" ]; then
tar xzf $FILE || error "Error while expanding $FILE" tar xzf $FILE || error "Error while expanding $FILE"
fi fi
if [ -z "`echo $FILE | sed 's@.*.zip$@@'`" ] ; then if [ -z "`echo $FILE | sed 's@.*.zip$@@'`" ]; then
check_unzip check_unzip
$UNZIP -q $FILE || error "Error while expanding $FILE" $UNZIP -q $FILE || error "Error while expanding $FILE"
fi fi
@ -193,7 +193,7 @@ load_data() {
URL="http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/command/create-project-from-upload" URL="http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/command/create-project-from-upload"
CURL="`which curl`" CURL="`which curl`"
if [ -z "$CURL" ] ; then if [ -z "$CURL" ]; then
error "We need 'curl' present in PATH to upload data to gridworks." error "We need 'curl' present in PATH to upload data to gridworks."
else else
curl -s -F "project-file=@$FILE" -F "project-name=$NAME" $URL > /dev/null || error "Error while uploading $FILE to Gridworks" curl -s -F "project-file=@$FILE" -F "project-name=$NAME" $URL > /dev/null || error "Error while uploading $FILE to Gridworks"
@ -204,19 +204,19 @@ load_data() {
# ---------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------
build_prepare() { build_prepare() {
if [ ! -d $GRIDWORKS_BUILD_DIR ] ; then if [ ! -d $GRIDWORKS_BUILD_DIR ]; then
mkdir $GRIDWORKS_BUILD_DIR || error "Error while making directory $GRIDWORKS_BUILD_DIR" mkdir $GRIDWORKS_BUILD_DIR || error "Error while making directory $GRIDWORKS_BUILD_DIR"
fi fi
} }
dist_prepare() { dist_prepare() {
if [ ! -d $GRIDWORKS_DIST_DIR ] ; then if [ ! -d $GRIDWORKS_DIST_DIR ]; then
mkdir $GRIDWORKS_DIST_DIR || error "Error while making directory $GRIDWORKS_DIST_DIR" mkdir $GRIDWORKS_DIST_DIR || error "Error while making directory $GRIDWORKS_DIST_DIR"
fi fi
} }
tools_prepare() { tools_prepare() {
if [ ! -d $GRIDWORKS_TOOLS_DIR ] ; then if [ ! -d $GRIDWORKS_TOOLS_DIR ]; then
mkdir $GRIDWORKS_TOOLS_DIR || error "Error while making directory $GRIDWORKS_TOOLS_DIR" mkdir $GRIDWORKS_TOOLS_DIR || error "Error while making directory $GRIDWORKS_TOOLS_DIR"
fi fi
} }
@ -227,13 +227,13 @@ ant_prepare() {
ANT_DIR="apache-ant-1.8.0" ANT_DIR="apache-ant-1.8.0"
ANT=`which ant` ANT=`which ant`
if [ -z "$ANT" ] ; then if [ -z "$ANT" ]; then
if [ -z "$ANT_HOME" ] ; then if [ -z "$ANT_HOME" ]; then
cd $GRIDWORKS_TOOLS_DIR cd $GRIDWORKS_TOOLS_DIR
if [ ! -f "$ANT_FILE" ] ; then if [ ! -f "$ANT_FILE" ]; then
download $ANT_URL $ANT_FILE download $ANT_URL $ANT_FILE
fi fi
if [ ! -d "$ANT_DIR" ] ; then if [ ! -d "$ANT_DIR" ]; then
tar xzf $ANT_FILE -C . || error "Error while expanding $ANT_FILE" tar xzf $ANT_FILE -C . || error "Error while expanding $ANT_FILE"
fi fi
export ANT_HOME="`pwd`/$ANT_DIR" export ANT_HOME="`pwd`/$ANT_DIR"
@ -272,7 +272,7 @@ virtualenv_prepare() {
tool_download $VIRTUALENV_URL $VIRTUALENV_FILE $VIRTUALENV_DIR tool_download $VIRTUALENV_URL $VIRTUALENV_FILE $VIRTUALENV_DIR
if [ ! -d "$GRIDWORKS_TOOLS_DIR/python" ] ; then if [ ! -d "$GRIDWORKS_TOOLS_DIR/python" ]; then
$PYTHON $GRIDWORKS_TOOLS_DIR/$VIRTUALENV_DIR/virtualenv.py $GRIDWORKS_TOOLS_DIR/python $PYTHON $GRIDWORKS_TOOLS_DIR/$VIRTUALENV_DIR/virtualenv.py $GRIDWORKS_TOOLS_DIR/python
fi fi
@ -283,12 +283,12 @@ virtualenv_prepare() {
windmill_prepare() { windmill_prepare() {
WINDMILL="`which windmill`" WINDMILL="`which windmill`"
if [ -z "$WINDMILL" ] ; then if [ -z "$WINDMILL" ]; then
check_python check_python
tools_prepare tools_prepare
WINDMILL="$GRIDWORKS_TOOLS_DIR/windmill" WINDMILL="$GRIDWORKS_TOOLS_DIR/windmill"
if [ ! -f "$WINDMILL" ] ; then if [ ! -f "$WINDMILL" ]; then
virtualenv_prepare virtualenv_prepare
$PYTHON_INSTALL windmill $PYTHON_INSTALL windmill
ln -s $PYTHON_HOME/bin/windmill $GRIDWORKS_TOOLS_DIR/windmill ln -s $PYTHON_HOME/bin/windmill $GRIDWORKS_TOOLS_DIR/windmill
@ -396,7 +396,7 @@ mac_dist() {
SIZE=30 SIZE=30
if [ -f "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg" ] ; then if [ -f "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg" ]; then
rm "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg" rm "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg"
fi fi
@ -434,7 +434,7 @@ mac_dist() {
sync sync
hdiutil detach $DEVICE hdiutil detach $DEVICE
if [ -f "$GRIDWORKS_DIST_DIR/gridworks-$VERSION-$REVISION.dmg" ] ; then if [ -f "$GRIDWORKS_DIST_DIR/gridworks-$VERSION-$REVISION.dmg" ]; then
rm "$GRIDWORKS_DIST_DIR/gridworks-$VERSION-$REVISION.dmg" rm "$GRIDWORKS_DIST_DIR/gridworks-$VERSION-$REVISION.dmg"
fi fi
@ -470,7 +470,7 @@ ui_test() {
echo "" echo ""
echo "Starting Windmill..." echo "Starting Windmill..."
if [ -z "$INTERACTIVE" ] ; then if [ -z "$INTERACTIVE" ]; then
$WINDMILL firefox http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/ test=$GRIDWORKS_TEST_DIR/windmill/python exit > /dev/null $WINDMILL firefox http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/ test=$GRIDWORKS_TEST_DIR/windmill/python exit > /dev/null
#$WINDMILL firefox http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/ jsdir=$GRIDWORKS_TEST_DIR/windmill/js exit > /dev/null #$WINDMILL firefox http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/ jsdir=$GRIDWORKS_TEST_DIR/windmill/js exit > /dev/null
else else
@ -485,14 +485,14 @@ ui_test() {
} }
server_test() { server_test() {
if [ ! -d "$GRIDWORKS_TEST_DIR/java/classes" ] ; then if [ ! -d "$GRIDWORKS_TEST_DIR/java/classes" ]; then
ant build_tests ant build_tests
echo "" echo ""
fi fi
CLASSPATH="$GRIDWORKS_BUILD_DIR/classes:$GRIDWORKS_WEBAPP/WEB-INF/classes:$GRIDWORKS_TEST_DIR/java/classes:$GRIDWORKS_TEST_DIR/java/lib/*:$GRIDWORKS_LIB_DIR/*:$GRIDWORKS_WEBAPP/WEB-INF/lib/*" CLASSPATH="$GRIDWORKS_BUILD_DIR/classes:$GRIDWORKS_WEBAPP/WEB-INF/classes:$GRIDWORKS_TEST_DIR/java/classes:$GRIDWORKS_TEST_DIR/java/lib/*:$GRIDWORKS_LIB_DIR/*:$GRIDWORKS_WEBAPP/WEB-INF/lib/*"
if [ -z "$1" ] ; then if [ -z "$1" ]; then
cd $GRIDWORKS_TEST_DIR/java/classes cd $GRIDWORKS_TEST_DIR/java/classes
TESTS=`find . -name '*.class' | sed s@/@.@g | sed s@.class@@ | sed s@..@@` TESTS=`find . -name '*.class' | sed s@/@.@g | sed s@.class@@ | sed s@..@@`
cd ../../.. cd ../../..
@ -511,9 +511,9 @@ server_test() {
run() { run() {
FORK=$1 FORK=$1
if [ ! -d $GRIDWORKS_BUILD_DIR/classes ] ; then if [ ! -d $GRIDWORKS_BUILD_DIR/classes ]; then
IS_JAR=`ls $GRIDWORKS_LIB_DIR | grep gridworks` IS_JAR=`ls $GRIDWORKS_LIB_DIR | grep gridworks`
if [ -z "$IS_JAR" ] ; then if [ -z "$IS_JAR" ]; then
ant build ant build
echo "" echo ""
fi fi
@ -521,19 +521,19 @@ run() {
check_running check_running
if [ -z "$NOT_RUNNING" ] ; then if [ -z "$NOT_RUNNING" ]; then
warn "Gridworks is already running." warn "Gridworks is already running."
fi fi
if [ -d $GRIDWORKS_BUILD_DIR/classes ] ; then if [ -d $GRIDWORKS_BUILD_DIR/classes ]; then
add_option "-Dgridworks.autoreloading=true" add_option "-Dgridworks.autoreloading=true"
fi fi
if [ "$SYSTEM" = 'Darwin' ] ; then if [ "$SYSTEM" = 'Darwin' ]; then
add_option "-Xdock:name=Gridworks -Xdock:icon=src/graphics/icon/gridworks.icns" add_option "-Xdock:name=Gridworks -Xdock:icon=src/graphics/icon/gridworks.icns"
fi fi
if [ "$GRIDWORKS_DATA_DIR" ] ; then if [ "$GRIDWORKS_DATA_DIR" ]; then
add_option "-Dgridworks.data_dir=$GRIDWORKS_DATA_DIR" add_option "-Dgridworks.data_dir=$GRIDWORKS_DATA_DIR"
fi fi
@ -547,7 +547,7 @@ run() {
echo "Starting Gridworks at 'http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/'" echo "Starting Gridworks at 'http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/'"
echo "" echo ""
if [ -z "$FORK" ] ; then if [ -z "$FORK" ]; then
exec $RUN_CMD exec $RUN_CMD
else else
sh -c "$RUN_CMD" & sh -c "$RUN_CMD" &
@ -556,7 +556,7 @@ run() {
} }
execute() { execute() {
if [ ! -d $GRIDWORKS_BUILD_DIR/classes ] ; then if [ ! -d $GRIDWORKS_BUILD_DIR/classes ]; then
ant build ant build
echo "" echo ""
fi fi
@ -611,7 +611,7 @@ OPTS=""
SYSTEM=`uname` SYSTEM=`uname`
if [ "$SYSTEM" = "Darwin" -a "$JAVA_HOME" = "" ] ; then if [ "$SYSTEM" = "Darwin" -a "$JAVA_HOME" = "" ]; then
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home" export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home"
fi fi
@ -621,12 +621,12 @@ load_configs gridworks.ini
# ----- Make sure there is an appropriate java environment is available ------------- # ----- Make sure there is an appropriate java environment is available -------------
if [ "$JAVA_HOME" ] ; then if [ "$JAVA_HOME" ]; then
JAVA="$JAVA_HOME/bin/java" JAVA="$JAVA_HOME/bin/java"
else else
JAVA=`which java` JAVA=`which java`
if [ -z "$JAVA" ] ; then if [ -z "$JAVA" ]; then
if [ "$SYSTEM" = 'Darwin' ] ; then if [ "$SYSTEM" = 'Darwin' ]; then
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
else else
error "The 'java' command should be in your path or the 'JAVA_HOME' environment variable should be set" error "The 'java' command should be in your path or the 'JAVA_HOME' environment variable should be set"
@ -635,7 +635,7 @@ else
fi fi
JAVA_VERSION=`$JAVA -version 2>&1 | grep version | cut -d ' ' -f 3 | egrep ^\"1.6` JAVA_VERSION=`$JAVA -version 2>&1 | grep version | cut -d ' ' -f 3 | egrep ^\"1.6`
if [ -z "$JAVA_VERSION" ] ; then if [ -z "$JAVA_VERSION" ]; then
error "Gridworks requires java version 6 or later." error "Gridworks requires java version 6 or later."
fi fi
@ -656,7 +656,9 @@ while [ $# -ne 0 ] ; do
esac esac
done done
ACTION=$1; shift if [ $# -ne 0 ]; then
ACTION=$1; shift
fi
if [ -z "$ACTION" ]; then if [ -z "$ACTION" ]; then
ACTION="run" ACTION="run"
@ -664,48 +666,48 @@ fi
# ----- Verify and Set Required Environment Variables ------------------------- # ----- Verify and Set Required Environment Variables -------------------------
if [ -z "$JAVA_OPTIONS" ] ; then if [ -z "$JAVA_OPTIONS" ]; then
JAVA_OPTIONS="" JAVA_OPTIONS=""
fi fi
add_option "$JAVA_OPTIONS" add_option "$JAVA_OPTIONS"
if [ -z "$GRIDWORKS_MEMORY" ] ; then if [ -z "$GRIDWORKS_MEMORY" ]; then
GRIDWORKS_MEMORY="1024M" GRIDWORKS_MEMORY="1024M"
fi fi
add_option "-Xms256M -Xmx$GRIDWORKS_MEMORY" add_option "-Xms256M -Xmx$GRIDWORKS_MEMORY"
if [ -z "$GRIDWORKS_PORT" ] ; then if [ -z "$GRIDWORKS_PORT" ]; then
GRIDWORKS_PORT="3333" GRIDWORKS_PORT="3333"
fi fi
add_option "-Dgridworks.port=$GRIDWORKS_PORT" add_option "-Dgridworks.port=$GRIDWORKS_PORT"
if [ -z "$GRIDWORKS_HOST" ] ; then if [ -z "$GRIDWORKS_HOST" ]; then
GRIDWORKS_HOST="127.0.0.1" GRIDWORKS_HOST="127.0.0.1"
fi fi
add_option "-Dgridworks.host=$GRIDWORKS_HOST" add_option "-Dgridworks.host=$GRIDWORKS_HOST"
if [ -z "$GRIDWORKS_WEBAPP" ] ; then if [ -z "$GRIDWORKS_WEBAPP" ]; then
GRIDWORKS_WEBAPP="src/main/webapp" GRIDWORKS_WEBAPP="src/main/webapp"
fi fi
add_option "-Dgridworks.webapp=$GRIDWORKS_WEBAPP" add_option "-Dgridworks.webapp=$GRIDWORKS_WEBAPP"
if [ -z "$GRIDWORKS_TEST_DIR" ] ; then if [ -z "$GRIDWORKS_TEST_DIR" ]; then
GRIDWORKS_TEST_DIR="tests" GRIDWORKS_TEST_DIR="tests"
fi fi
if [ -z "$GRIDWORKS_BUILD_DIR" ] ; then if [ -z "$GRIDWORKS_BUILD_DIR" ]; then
GRIDWORKS_BUILD_DIR="build" GRIDWORKS_BUILD_DIR="build"
fi fi
if [ -z "$GRIDWORKS_LIB_DIR" ] ; then if [ -z "$GRIDWORKS_LIB_DIR" ]; then
GRIDWORKS_LIB_DIR="lib" GRIDWORKS_LIB_DIR="lib"
fi fi
if [ -z "$GRIDWORKS_TOOLS_DIR" ] ; then if [ -z "$GRIDWORKS_TOOLS_DIR" ]; then
GRIDWORKS_TOOLS_DIR="tools" GRIDWORKS_TOOLS_DIR="tools"
fi fi
if [ -z "$GRIDWORKS_DIST_DIR" ] ; then if [ -z "$GRIDWORKS_DIST_DIR" ]; then
GRIDWORKS_DIST_DIR="dist" GRIDWORKS_DIST_DIR="dist"
fi fi