Revision 36072fc305536bf9c8f3b7562324d73a77cd5835 authored by Daniel Mitterdorfer on 17 August 2017, 12:52:58 UTC, committed by Daniel Mitterdorfer on 17 August 2017, 12:52:58 UTC
1 parent 96a9c05
Raw File
rallyd
#!/usr/bin/env bash

# fail this script immediately if any command fails with a non-zero exit code
set -e

# see http://stackoverflow.com/a/246128
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
  DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  SOURCE="$(readlink "$SOURCE")"
  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
RALLY_SRC_HOME="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

pushd . >/dev/null 2>&1
cd "${RALLY_SRC_HOME}" >/dev/null 2>&1

export PYTHONPATH=$RALLY_SRC_HOME:$PYTHONPATH

# see http://unix.stackexchange.com/a/155077
if output=$(git status --porcelain) && [ -z "$output" ] && on_master=$(git rev-parse --abbrev-ref HEAD) && [ "$on_master" == "master" ]
then
  # Working directory clean -> we assume this is a user that is not actively developing Rally and just upgrade it every time it is invoked
  set +e
  # this will fail if the user is offline
  git fetch origin --quiet >/dev/null 2>&1
  exit_code=$?
  set -e
  if [ ${exit_code} == 0 ]
  then
    echo "Auto-updating Rally"
    git rebase origin/master --quiet
    python3 setup.py -q develop --user
  #else
  # offline - skipping update
  fi
# else
  # Uncommitted changes - don't upgrade, just run
fi

popd >/dev/null 2>&1

# Provide a consistent binary name to the user and hide the fact that we call another binary under the hood.
export RALLY_ALTERNATIVE_BINARY_NAME=$(basename "$0")
RALLY_ROOT=$(python3 -c "import site; print(site.USER_BASE)")
RALLY_BIN=${RALLY_ROOT}/bin/esrallyd
if [ -x "$RALLY_BIN" ]
then
    ${RALLY_BIN} "$@"
else
    echo "Cannot execute Rally daemon in ${RALLY_BIN}."
fi
back to top