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.

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