blob: cc1aaf200f4fb6201ba9e132d13ceea198074f7d [file] [log] [blame]
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# This files copies itself to $HOME/bin, renames itself to "zest"
# and from then on pretends to be the tools.shell script.
#
JARNAME=org.apache.zest.tool.shell-@version@.jar
MYNAME=`basename $0`
# check if it is executing as boot script or regular script.
if [ "$MYNAME" == "zest-boot" ] ; then
mkdir $HOME/bin >/dev/null 2>&1
cp $0 $HOME/bin/zest
if [ -f $HOME/bin/$JARNAME ] ; then
echo "JAR file exists."
else
JAR_URL=http://repo1.maven.org/maven2/org/apache/zest/$JARNAME
# check for wget
WGET=`which wget`
if [ "$WGET" == "" ] ; then
# check for curl
CURL=`which curl`
if [ "$CURL" == "" ] ; then
echo "You need either wget or curl installed to use this script."
exit 1
else
curl --output $HOME/bin/ $JAR_URL
fi
else
wget --output-document=$HOME/bin/ $HOME/bin/zest $JAR_URL
fi
fi
else
# Capture current directory
CWD=`pwd`
# Goto directory where this script was started from.
cd `dirname $0`
# Up one level
cd ..
# Get the home directory of Zest
ZESTPATH=`pwd`
# Figure out if we are executing from within the SDK or the QuickStart
if [ -f libs/$JARNAME ] ; then
JARFILE=libs/$JARNAME
else
if [ -f bin/$JARNAME ] ; then
JARFILE=bin/$JARNAME
else
fi
fi
# Restore the current directory
cd $CWD
java -Dzest.home=$ZESTPATH -jar $ZESTPATH/$JARFILE "$@"
fi