#!/bin/bash

#  Copyright 2007-2015 Zuse Institute Berlin
#
#   Licensed 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.

# inspired by the start script of ant

prefix=/usr
exec_prefix=/usr
SCALARISDIR=/usr/lib64/scalaris
SCALARISCLIENT_RUBY="/usr/local/share/ruby/site_ruby//scalaris_client.rb"

for arg in "$@"; do
  args="$args \"$arg\""
done

# activate no_config if called in the source tree:
ABSPATH="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"
DIRNAME=`dirname $ABSPATH`
# is this a source checkout or an (rpm/deb/manual) installation?
if [ "$DIRNAME" != "/usr/bin" -a "$DIRNAME" != "/bin" -a "${DIRNAME##*/}" = "ruby-api" ]; then
  # local mode, i.e. uninstalled
  SCALARISCLIENT_RUBY="`dirname $0`/scalaris_client.rb"
fi

eval $SCALARISCLIENT_RUBY $args
