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 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/bash
  2. ###############################
  3. # usage: start.sh [ -e ARG ] [ -p ARG ] [ -l ARG ]
  4. # -e ARG: edition to run
  5. # valid values are 'oss' (Open Source), 'dev' (Developer), 'ent' (Enterprise) and 'dce' (Data Center) (case insensitive)
  6. # default value is 'oss'.
  7. # -p ARG: name(s) of patch separated by colon (name of patch is filename without extension)
  8. # -l ARG: name of log file to display.
  9. # valid values are 'all', 'sonar', 'web', 'ce' and 'es' (case insensitive).
  10. # default value is 'all'.
  11. ###############################
  12. set -euo pipefail
  13. ROOT=$(pwd)
  14. source "$ROOT/scripts/editions.sh"
  15. if [ -r "$ROOT/private/scripts/editions.sh" ]; then
  16. source "$ROOT/private/scripts/editions.sh"
  17. fi
  18. source "$ROOT/scripts/logs.sh"
  19. source "$ROOT/scripts/stop.sh"
  20. PATCHES=""
  21. EDITION="$DEFAULT_EDITION"
  22. LOG="$DEFAULT_LOG"
  23. while getopts ":e:p:l:" opt; do
  24. case "$opt" in
  25. e) EDITION=${OPTARG:=$DEFAULT_EDITION}
  26. ;;
  27. p) PATCHES="$OPTARG"
  28. ;;
  29. l) LOG=${OPTARG:=$DEFAULT_LOG}
  30. ;;
  31. \?)
  32. echo "Unsupported option $OPTARG" >&2
  33. exit 1
  34. ;;
  35. esac
  36. done
  37. checkEditionArgument "$EDITION"
  38. checkLogArgument "$LOG"
  39. if [[ "${OSTYPE:-}" == "darwin"* ]]; then
  40. OS='macosx-universal-64'
  41. else
  42. OS='linux-x86-64'
  43. fi
  44. OSS_ZIP="$(distributionDirOf "oss")/$(baseFileNameOf "oss")-*.zip"
  45. if ! ls ${OSS_ZIP} &> /dev/null; then
  46. echo 'Sources are not built'
  47. "$ROOT"/build.sh
  48. fi
  49. # stop SQ running in any instance
  50. stopAny
  51. cd "$(distributionDirOf "$EDITION")"
  52. TARGET_DIR="$(targetDirOf "$EDITION")"
  53. SH_FILE="${TARGET_DIR}/sonarqube-*/bin/$OS/sonar.sh"
  54. if ! ls ${SH_FILE} &> /dev/null; then
  55. echo "Unpacking ${TARGET_DIR}..."
  56. ZIP_FILE="$(baseFileNameOf "$EDITION")-*.zip"
  57. unzip -qq ${ZIP_FILE} -d "${TARGET_DIR}"
  58. fi
  59. cd $(find ${TARGET_DIR}/sonarqube-* -type d | head -1)
  60. SQ_HOME=$(pwd)
  61. cd "$ROOT"
  62. source "$ROOT"/scripts/patches_utils.sh
  63. SQ_EXEC="$SQ_HOME/bin/$OS/sonar.sh"
  64. # invoke patches if at least one was specified
  65. # each patch is passed the path to the SQ instance home directory as first and only argument
  66. if [ "$PATCHES" ]; then
  67. call_patches "$PATCHES" "$SQ_HOME"
  68. fi
  69. "$SQ_EXEC" start
  70. sleep 1
  71. doTail "$LOG"