2015-08-03 21:05:20 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
###############################
|
|
|
|
|
# usage: start.sh [ -p ARG ]
|
|
|
|
|
# -p ARG: name(s) of patch separated by colon (name of patch is filename without extension)
|
|
|
|
|
###############################
|
|
|
|
|
|
|
|
|
|
ROOT=$(pwd)
|
|
|
|
|
|
|
|
|
|
PATCHES=""
|
|
|
|
|
while getopts ":p:" opt; do
|
|
|
|
|
case "$opt" in
|
|
|
|
|
p) PATCHES=$OPTARG
|
|
|
|
|
;;
|
|
|
|
|
\?)
|
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
|
|
|
|
|
|
|
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
|
|
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'
|
|
|
|
|
./build.sh
|
|
|
|
|
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
|
|
|
|
|
cd sonarqube-*
|
|
|
|
|
|
|
|
|
|
# from that point on, strict bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
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
|
2016-11-18 06:46:01 +08:00
|
|
|
tail -fn 100 "$SQ_HOME"/logs/sonar.log
|