Support edition aliases in start script

This commit is contained in:
Duarte Meneses 2018-06-13 11:35:56 +02:00 committed by SonarTech
parent 964114c0da
commit 323edff58d
2 changed files with 28 additions and 32 deletions

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
}
distributionDirOf() {
local edition="$1"
if [ "$edition" = "oss" ]; then
echo "sonar-application/build/distributions/"
else
echo "unsupported edition $edition"
exit 1
fi
resolveAliases() {
local lowerEditionAlias=$(toLower "$1")
case "$lowerEditionAlias" in
oss )
echo community ;;
* )
echo "$lowerEditionAlias" ;;
esac
}
distributionDirOf() {
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"
}

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