caved to the compulsion and fixed the bash-isms

git-svn-id: http://google-refine.googlecode.com/svn/trunk@422 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-04-08 18:23:14 +00:00
parent fbc1d04efb
commit 2c221a5bf6

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
########################################################## ##########################################################
# Gridworks Control System # # Gridworks Control System #
@ -96,7 +96,7 @@ check_downloaders() {
CURL="`which curl`" CURL="`which curl`"
WGET="`which wget`" WGET="`which wget`"
if [ "$CURL" == "" ] && [ "$WGET" == "" ]; then if [ -z "$CURL" -a -z "$WGET" ]; then
error "We need either 'curl' or 'wget' present in PATH to download external dependencies." error "We need either 'curl' or 'wget' present in PATH to download external dependencies."
fi fi
} }
@ -104,18 +104,18 @@ check_downloaders() {
check_unzip() { check_unzip() {
UNZIP="`which unzip`" UNZIP="`which unzip`"
if [ "$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 [ "$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" ] && [ "$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,17 +124,17 @@ 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
} }
get_version() { get_version() {
VERSION=$1 VERSION="$1"
if [ "$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
} }
@ -176,10 +176,10 @@ tool_download() {
download $URL $FILE download $URL $FILE
fi fi
if [ ! -d "$DIR" ] ; then if [ ! -d "$DIR" ] ; then
if [ "`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 [ "`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 [ "$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"
@ -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 [ $ANT == "" ] ; then if [ -z "$ANT" ] ; then
if [ $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"
@ -283,12 +283,12 @@ virtualenv_prepare() {
windmill_prepare() { windmill_prepare() {
WINDMILL="`which windmill`" WINDMILL="`which windmill`"
if [ "$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
@ -470,7 +470,7 @@ ui_test() {
echo "" echo ""
echo "Starting Windmill..." echo "Starting Windmill..."
if [ "$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 [ "$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 ../../..
@ -512,8 +512,8 @@ 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 [ "$is_jar" == "" ] ; then if [ -z "$IS_JAR" ] ; then
ant build ant build
echo "" echo ""
fi fi
@ -521,7 +521,7 @@ run() {
check_running check_running
if [ "$NOT_RUNNING" == "" ] ; then if [ -z "$NOT_RUNNING" ] ; then
warn "Gridworks is already running." warn "Gridworks is already running."
fi fi
@ -529,11 +529,11 @@ run() {
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 [ "$FORK" == "" ] ; then if [ -z "$FORK" ] ; then
exec $RUN_CMD exec $RUN_CMD
else else
sh -c "$RUN_CMD" & sh -c "$RUN_CMD" &
@ -611,7 +611,7 @@ OPTS=""
SYSTEM=`uname` SYSTEM=`uname`
if [ "$SYSTEM" == "Darwin" ] && [ "$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 [ ! -z "$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"
@ -634,7 +634,7 @@ else
fi fi
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
@ -658,54 +658,54 @@ done
ACTION=$1; shift ACTION=$1; shift
if [ "$ACTION" == "" ]; then if [ -z "$ACTION" ]; then
ACTION="run" ACTION="run"
fi fi
# ----- Verify and Set Required Environment Variables ------------------------- # ----- Verify and Set Required Environment Variables -------------------------
if [ "$JAVA_OPTIONS" == "" ] ; then if [ -z "$JAVA_OPTIONS" ] ; then
JAVA_OPTIONS="" JAVA_OPTIONS=""
fi fi
add_option "$JAVA_OPTIONS" add_option "$JAVA_OPTIONS"
if [ "$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 [ "$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 [ "$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 [ "$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 [ "$GRIDWORKS_TEST_DIR" == "" ] ; then if [ -z "$GRIDWORKS_TEST_DIR" ] ; then
GRIDWORKS_TEST_DIR="tests" GRIDWORKS_TEST_DIR="tests"
fi fi
if [ "$GRIDWORKS_BUILD_DIR" == "" ] ; then if [ -z "$GRIDWORKS_BUILD_DIR" ] ; then
GRIDWORKS_BUILD_DIR="build" GRIDWORKS_BUILD_DIR="build"
fi fi
if [ "$GRIDWORKS_LIB_DIR" == "" ] ; then if [ -z "$GRIDWORKS_LIB_DIR" ] ; then
GRIDWORKS_LIB_DIR="lib" GRIDWORKS_LIB_DIR="lib"
fi fi
if [ "$GRIDWORKS_TOOLS_DIR" == "" ] ; then if [ -z "$GRIDWORKS_TOOLS_DIR" ] ; then
GRIDWORKS_TOOLS_DIR="tools" GRIDWORKS_TOOLS_DIR="tools"
fi fi
if [ "$GRIDWORKS_DIST_DIR" == "" ] ; then if [ -z "$GRIDWORKS_DIST_DIR" ] ; then
GRIDWORKS_DIST_DIR="dist" GRIDWORKS_DIST_DIR="dist"
fi fi