Browse Source

Support edition aliases in start script

tags/7.5
Duarte Meneses 5 years ago
parent
commit
323edff58d
2 changed files with 28 additions and 32 deletions
  1. 19
    28
      scripts/editions.sh
  2. 9
    4
      scripts/start.sh

+ 19
- 28
scripts/editions.sh View File

@@ -2,49 +2,40 @@

set -euo pipefail

DEFAULT_EDITION="oss"
EDITIONS="oss"
DEFAULT_EDITION="community"
EDITIONS="community"

toLower() {
echo "$1" | tr '[:upper:]' '[:lower:]'
}

checkEditionArgument() {
local editionArg="$1"
local lowerEditionArg=$(toLower $editionArg)

if [ "$lowerEditionArg" = "$DEFAULT_EDITION" ]; then
return
fi

checkEdition() {
for t in $EDITIONS; do
if [ "$lowerEditionArg" = "$t" ]; then
if [ "$1" = "$t" ]; then
return
fi
done

echo "Unsupported edition $editionArg"
echo "Unsupported edition $1"
exit 1
}


resolveAliases() {
local lowerEditionAlias=$(toLower "$1")

case "$lowerEditionAlias" in
oss )
echo community ;;
* )
echo "$lowerEditionAlias" ;;
esac
}

distributionDirOf() {
local edition="$1"

if [ "$edition" = "oss" ]; then
echo "sonar-application/build/distributions/"
else
echo "unsupported edition $edition"
exit 1
fi
echo "sonar-application/build/distributions/"
}

baseFileNameOf() {
local edition="$1"

if [ "$edition" = "oss" ]; then
echo "sonar-application"
else
echo "unsupported edition $edition"
exit 1
fi
echo "sonar-application"
}

+ 9
- 4
scripts/start.sh View File

@@ -2,8 +2,12 @@
###############################
# usage: start.sh [ -e ARG ] [ -p ARG ] [ -l ARG ]
# -e ARG: edition to run
# valid values are 'oss' (Open Source), 'dev' (Developer), 'ent' (Enterprise) and 'dce' (Data Center) (case insensitive)
# default value is 'oss'.
# valid values are (case insensitive):
# 'community', 'oss',
# 'developer', 'dev',
# 'enterprise', 'ent',
# 'datacenter', 'dc', 'dce'.
# default value is 'community'.
# -p ARG: name(s) of patch separated by colon (name of patch is filename without extension)
# -l ARG: name of log file to display.
# valid values are 'all', 'sonar', 'web', 'ce' and 'es' (case insensitive).
@@ -39,7 +43,8 @@ while getopts ":e:p:l:" opt; do
esac
done

checkEditionArgument "$EDITION"
EDITION=$(resolveAliases "$EDITION")
checkEdition "$EDITION"
checkLogArgument "$LOG"

if [[ "${OSTYPE:-}" == "darwin"* ]]; then
@@ -48,7 +53,7 @@ else
OS='linux-x86-64'
fi

OSS_ZIP="$(distributionDirOf "oss")/$(baseFileNameOf "oss")-*.zip"
OSS_ZIP="$(distributionDirOf "community")/$(baseFileNameOf "community")-*.zip"
if ! ls ${OSS_ZIP} &> /dev/null; then
echo 'Sources are not built'
"$ROOT"/build.sh

Loading…
Cancel
Save