diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2015-08-03 15:05:20 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2015-08-06 14:18:35 +0200 |
commit | c31e0667170091488cfdaf1f4b7c576546832e11 (patch) | |
tree | 30ba9c4e85c44e32885f8eb85dfa4b0d692e2b23 /scripts/start.sh | |
parent | 0ddae3998e34e24c5877b784332085a81a1ebe7e (diff) | |
download | sonarqube-c31e0667170091488cfdaf1f4b7c576546832e11.tar.gz sonarqube-c31e0667170091488cfdaf1f4b7c576546832e11.zip |
[SCRIPTS] add support for patches to start.sh
use seperate start and stop to avoid unpredictable errors when applying patches on a live SQ instance
Diffstat (limited to 'scripts/start.sh')
-rwxr-xr-x | scripts/start.sh | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100755 index 00000000000..e71adaf7d3d --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,59 @@ +#!/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 + ;; + \?) + >&2 echo "Unsupported option $OPTARG" + exit 1 + ;; + esac +done + +if [[ "$OSTYPE" == "darwin"* ]]; then + OS='macosx-universal-64' +else + OS='linux-x86-64' +fi + +ls sonar-application/target/sonarqube-*.zip 1> /dev/null 2>&1 +if [ "$?" != "0" ]; then + echo 'Sources are not built' + ./build.sh +fi + +cd sonar-application/target/ +ls sonarqube-*/bin/$OS/sonar.sh 1> /dev/null 2>&1 +if [ "$?" != "0" ]; then + unzip sonarqube-*.zip +fi +cd sonarqube-* + +# from that point on, strict bash +set -euo pipefail +SQ_HOME=$(pwd) +cd $ROOT + +source $ROOT/scripts/patches_utils.sh + +SQ_EXEC=$SQ_HOME/bin/$OS/sonar.sh + +$SQ_EXEC stop + +# 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 +if [ "$PATCHES" != "" ]; then + call_patches $PATCHES $SQ_HOME +fi + +$SQ_EXEC start +sleep 1 +tail -100f $SQ_HOME/logs/sonar.log |