Browse Source

Add support for Windows in ./scripts/start.sh

tags/7.8
philippe-perrin-sonarsource 4 years ago
parent
commit
41f73e8c27
3 changed files with 37 additions and 19 deletions
  1. 25
    0
      scripts/os.sh
  2. 5
    10
      scripts/start.sh
  3. 7
    9
      scripts/stop.sh

+ 25
- 0
scripts/os.sh View File

#!/usr/bin/env bash
###############################
# Helper for OS folders and scripts
###############################

set -euo pipefail

if [[ "${OSTYPE:-}" == "darwin"* ]]; then
OS_DIR='macosx-universal-64'
SH_FILE="sonar.sh"
elif [[ "${OSTYPE:-}" == "msys"* ]]; then
OS_DIR='windows-x86-64'
SH_FILE="StartSonar.bat"
else
OS_DIR='linux-x86-64'
SH_FILE="sonar.sh"
fi

runSQ() {
if [[ "${OSTYPE:-}" == "msys"* ]]; then
"$1"
else
"$1" start
fi
}

+ 5
- 10
scripts/start.sh View File

fi fi
source "$ROOT/scripts/logs.sh" source "$ROOT/scripts/logs.sh"
source "$ROOT/scripts/stop.sh" source "$ROOT/scripts/stop.sh"
source "$ROOT/scripts/os.sh"


PATCHES="" PATCHES=""
EDITION="$DEFAULT_EDITION" EDITION="$DEFAULT_EDITION"
checkEdition "$EDITION" checkEdition "$EDITION"
checkLogArgument "$LOG" checkLogArgument "$LOG"


if [[ "${OSTYPE:-}" == "darwin"* ]]; then
OS='macosx-universal-64'
else
OS='linux-x86-64'
fi

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


cd "$(distributionDirOf "$EDITION")" cd "$(distributionDirOf "$EDITION")"


SH_FILE="sonarqube-*/bin/$OS/sonar.sh"
if ! ls ${SH_FILE} &> /dev/null; then
SH_FILE_DIR="sonarqube-*/bin/$OS_DIR/"
if ! ls $SH_FILE_DIR &> /dev/null; then
BASE_FILE_NAME="$(baseFileNameOf "$EDITION")" BASE_FILE_NAME="$(baseFileNameOf "$EDITION")"
echo "Unpacking ${BASE_FILE_NAME}..." echo "Unpacking ${BASE_FILE_NAME}..."
ZIP_FILE="${BASE_FILE_NAME}-*.zip" ZIP_FILE="${BASE_FILE_NAME}-*.zip"


source "$ROOT"/scripts/patches_utils.sh source "$ROOT"/scripts/patches_utils.sh


SQ_EXEC="$SQ_HOME/bin/$OS/sonar.sh"
SQ_EXEC="$SQ_HOME/bin/$OS_DIR/$SH_FILE"


# invoke patches if at least one was specified # 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 # each patch is passed the path to the SQ instance home directory as first and only argument
call_patches "$PATCHES" "$SQ_HOME" call_patches "$PATCHES" "$SQ_HOME"
fi fi


"$SQ_EXEC" start
runSQ $SQ_EXEC
sleep 1 sleep 1
doTail "$LOG" doTail "$LOG"



+ 7
- 9
scripts/stop.sh View File



ROOT=$(pwd) ROOT=$(pwd)
source "$ROOT/scripts/editions.sh" source "$ROOT/scripts/editions.sh"
source "$ROOT/scripts/os.sh"
if [ -r "$ROOT/private/scripts/editions.sh" ]; then if [ -r "$ROOT/private/scripts/editions.sh" ]; then
source "$ROOT/private/scripts/editions.sh" source "$ROOT/private/scripts/editions.sh"
fi fi


if [[ "$OSTYPE" == "darwin"* ]]; then
OS='macosx-universal-64'
else
OS='linux-x86-64'
fi

stopAny() { stopAny() {
for edition in $EDITIONS; do
SONAR_SH="$(distributionDirOf "$edition")/sonarqube-*/bin/$OS/sonar.sh"
# Don't try to stop on windows for now
if [[ "${OSTYPE:-}" != "msys" ]]; then
for edition in $EDITIONS; do
SONAR_SH="$(distributionDirOf "$edition")/sonarqube-*/bin/$OS_DIR/sonar.sh"
if ls $SONAR_SH &> /dev/null; then if ls $SONAR_SH &> /dev/null; then
echo "$(baseFileNameOf "$edition") is unpacked" echo "$(baseFileNameOf "$edition") is unpacked"
sh $SONAR_SH stop sh $SONAR_SH stop
fi fi
done
done
fi
} }


# check the script was called to avoid execute when script is only sourced # check the script was called to avoid execute when script is only sourced

Loading…
Cancel
Save