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. #!/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. source "$ROOT/scripts/os.sh"
  25. PATCHES=""
  26. EDITION="$DEFAULT_EDITION"
  27. LOG="$DEFAULT_LOG"
  28. while getopts ":e:p:l:" opt; do
  29. case "$opt" in
  30. e) EDITION=${OPTARG:=$DEFAULT_EDITION}
  31. ;;
  32. p) PATCHES="$OPTARG"
  33. ;;
  34. l) LOG=${OPTARG:=$DEFAULT_LOG}
  35. ;;
  36. \?)
  37. echo "Unsupported option $OPTARG" >&2
  38. exit 1
  39. ;;
  40. esac
  41. done
  42. EDITION=$(resolveAliases "$EDITION")
  43. checkEdition "$EDITION"
  44. checkLogArgument "$LOG"
  45. OSS_ZIP="$(distributionDirOf "community")/$(baseFileNameOf "community")-*.zip"
  46. if ! ls ${OSS_ZIP} &> /dev/null; then
  47. echo 'Sources are not built'
  48. "$ROOT"/build.sh
  49. fi
  50. # stop SQ running in any instance
  51. stopAny
  52. cd "$(distributionDirOf "$EDITION")"
  53. SH_FILE_DIR="sonarqube-*/bin/$OS_DIR/"
  54. if ! ls $SH_FILE_DIR &> /dev/null; then
  55. BASE_FILE_NAME="$(baseFileNameOf "$EDITION")"
  56. echo "Unpacking ${BASE_FILE_NAME}..."
  57. ZIP_FILE="${BASE_FILE_NAME}-*.zip"
  58. unzip -qq ${ZIP_FILE}
  59. fi
  60. cd $(find sonarqube-* -type d | head -1)
  61. SQ_HOME=$(pwd)
  62. cd "$ROOT"
  63. source "$ROOT"/scripts/patches_utils.sh
  64. SQ_EXEC="$SQ_HOME/bin/$OS_DIR/$SH_FILE"
  65. # invoke patches if at least one was specified
  66. # each patch is passed the path to the SQ instance home directory as first and only argument
  67. if [ "$PATCHES" ]; then
  68. call_patches "$PATCHES" "$SQ_HOME"
  69. fi
  70. runSQ $SQ_EXEC
  71. sleep 1
  72. doTail "$LOG"