You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

start.sh 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. ###############################
  3. # usage: start.sh [ -p ARG ] [ -l ARG ]
  4. # -p ARG: name(s) of patch separated by colon (name of patch is filename without extension)
  5. # -l ARG: name of log file to display.
  6. # valid values are 'all', 'sonar', 'web', 'ce' and 'es' (case insensitive).
  7. # default value is 'all'.
  8. ###############################
  9. set -euo pipefail
  10. ROOT=$(pwd)
  11. source "$ROOT"/scripts/logs.sh
  12. PATCHES=""
  13. LOG="$DEFAULT_LOG"
  14. while getopts ":p:l:" opt; do
  15. case "$opt" in
  16. p) PATCHES=$OPTARG
  17. ;;
  18. l) LOG=${OPTARG:=$DEFAULT_LOG}
  19. ;;
  20. \?)
  21. echo "Unsupported option $OPTARG" >&2
  22. exit 1
  23. ;;
  24. esac
  25. done
  26. checkLogArgument "$LOG"
  27. if [[ "${OSTYPE:-}" == "darwin"* ]]; then
  28. OS='macosx-universal-64'
  29. else
  30. OS='linux-x86-64'
  31. fi
  32. if ! ls sonar-application/target/sonarqube-*.zip &> /dev/null; then
  33. echo 'Sources are not built'
  34. "$ROOT"/build.sh
  35. fi
  36. cd sonar-application/target/
  37. if ! ls sonarqube-*/bin/$OS/sonar.sh &> /dev/null; then
  38. echo "Unzipping SQ..."
  39. unzip -qq sonarqube-*.zip
  40. fi
  41. cd sonarqube-*
  42. SQ_HOME=$(pwd)
  43. cd "$ROOT"
  44. source "$ROOT"/scripts/patches_utils.sh
  45. SQ_EXEC=$SQ_HOME/bin/$OS/sonar.sh
  46. "$SQ_EXEC" stop
  47. # invoke patches if at least one was specified
  48. # each patch is passed the path to the SQ instance home directory as first and only argument
  49. if [ "$PATCHES" ]; then
  50. call_patches "$PATCHES" "$SQ_HOME"
  51. fi
  52. "$SQ_EXEC" start
  53. sleep 1
  54. doTail "$LOG"