2015-08-03 21:05:20 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
###############################
|
2017-01-03 22:41:13 +08:00
|
|
|
# usage: start.sh [ -p ARG ] [ -l ARG ]
|
2015-08-03 21:05:20 +08:00
|
|
|
# -p ARG: name(s) of patch separated by colon (name of patch is filename without extension)
|
2017-01-03 22:41:13 +08:00
|
|
|
# -l ARG: name of log file to display.
|
|
|
|
|
# valid values are 'all', 'sonar', 'web', 'ce' and 'es' (case insensitive).
|
|
|
|
|
# default value is 'all'.
|
2015-08-03 21:05:20 +08:00
|
|
|
###############################
|
|
|
|
|
|
2017-01-03 22:41:13 +08:00
|
|
|
set -euo pipefail
|
|
|
|
|
|
2015-08-03 21:05:20 +08:00
|
|
|
ROOT=$(pwd)
|
|
|
|
|
|
2017-01-03 22:41:13 +08:00
|
|
|
source "$ROOT"/scripts/logs.sh
|
|
|
|
|
|
2015-08-03 21:05:20 +08:00
|
|
|
PATCHES=""
|
2017-01-03 22:41:13 +08:00
|
|
|
LOG="$DEFAULT_LOG"
|
|
|
|
|
while getopts ":p:l:" opt; do
|
2015-08-03 21:05:20 +08:00
|
|
|
case "$opt" in
|
|
|
|
|
p) PATCHES=$OPTARG
|
|
|
|
|
;;
|
2017-01-03 22:41:13 +08:00
|
|
|
l) LOG=${OPTARG:=$DEFAULT_LOG}
|
|
|
|
|
;;
|
2015-08-03 21:05:20 +08:00
|
|
|
\?)
|
2016-11-18 06:39:28 +08:00
|
|
|
echo "Unsupported option $OPTARG" >&2
|
2015-08-03 21:05:20 +08:00
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
2017-01-03 22:41:13 +08:00
|
|
|
checkLogArgument "$LOG"
|
|
|
|
|
|
|
|
|
|
if [[ "${OSTYPE:-}" == "darwin"* ]]; then
|
2015-08-03 21:05:20 +08:00
|
|
|
OS='macosx-universal-64'
|
|
|
|
|
else
|
|
|
|
|
OS='linux-x86-64'
|
|
|
|
|
fi
|
|
|
|
|
|
2016-11-18 06:41:37 +08:00
|
|
|
if ! ls sonar-application/target/sonarqube-*.zip &> /dev/null; then
|
2015-08-03 21:05:20 +08:00
|
|
|
echo 'Sources are not built'
|
2017-01-03 22:41:13 +08:00
|
|
|
"$ROOT"/build.sh
|
2015-08-03 21:05:20 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cd sonar-application/target/
|
2016-11-18 06:41:37 +08:00
|
|
|
if ! ls sonarqube-*/bin/$OS/sonar.sh &> /dev/null; then
|
2015-08-06 17:04:05 +08:00
|
|
|
echo "Unzipping SQ..."
|
|
|
|
|
unzip -qq sonarqube-*.zip
|
2015-08-03 21:05:20 +08:00
|
|
|
fi
|
2017-07-24 15:55:16 +08:00
|
|
|
cd $(find sonarqube-* -type d | head -1)
|
2015-08-03 21:05:20 +08:00
|
|
|
|
|
|
|
|
SQ_HOME=$(pwd)
|
2016-11-18 06:43:10 +08:00
|
|
|
cd "$ROOT"
|
2015-08-03 21:05:20 +08:00
|
|
|
|
2016-11-18 06:43:10 +08:00
|
|
|
source "$ROOT"/scripts/patches_utils.sh
|
2015-08-03 21:05:20 +08:00
|
|
|
|
|
|
|
|
SQ_EXEC=$SQ_HOME/bin/$OS/sonar.sh
|
|
|
|
|
|
2016-11-18 06:43:10 +08:00
|
|
|
"$SQ_EXEC" stop
|
2015-08-03 21:05:20 +08:00
|
|
|
|
|
|
|
|
# invoke patches if at least one was specified
|
|
|
|
|
# each patch is passed the path to the SQ instance home directory as first and only argument
|
2016-11-18 06:43:49 +08:00
|
|
|
if [ "$PATCHES" ]; then
|
2016-11-18 06:43:10 +08:00
|
|
|
call_patches "$PATCHES" "$SQ_HOME"
|
2015-08-03 21:05:20 +08:00
|
|
|
fi
|
|
|
|
|
|
2016-11-18 06:43:10 +08:00
|
|
|
"$SQ_EXEC" start
|
2015-08-03 21:05:20 +08:00
|
|
|
sleep 1
|
2017-01-03 22:41:13 +08:00
|
|
|
doTail "$LOG"
|
|
|
|
|
|