aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/stop.sh
blob: 55f3757c30e612e6cf716acc616db66f2fe75f95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
###############################
# Shortcut to stop server. It must be already built.
###############################

set -euo pipefail

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

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

stopAny() {
  for edition in $EDITIONS; do
      SONAR_SH="$(distributionDirOf "$edition")/sonarqube-*/bin/$OS/sonar.sh"
      if ls $SONAR_SH &> /dev/null; then
        echo "$(baseFileNameOf "$edition") is unpacked"
        sh $SONAR_SH stop
      fi
  done
}

# check the script was called to avoid execute when script is only sourced
script_name=$(basename "$0")
if [ "$script_name" = "stop.sh" ]; then
  stopAny
fi