The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

4 年前
Introduce packer support (#18) cleanups and fixes, packer is ready to roll add errorApi endpoint initialize mitmproxy dependencies packer deployments finally working fix virtualenv call for ubuntu 20.04 WIP. update to ubuntu 20.04. fixing algo installation WIP. packer fixes remove unused constant WIP. packer basics working for ec2 Merge branch 'master' of git.bubblev.org:bubblev/bubble into cobbzilla/introduce_packer remove automation dir, all moved to resources log pg autovacuum if longer than 250ms touch install marker for algo set mitmproxy as owner of all mitmproxy files add hostname to packer image name avoid closing progress meter prematurely WIP. parallelize node startup, fix packer bugs clarify docs add missing vars, algo tweaks add missing vars, update algo hash WIP. improving algo/mitmproxy packer stuff install packer for sage, call packer from proper location Use compute driver to get regions improve comments wait longer before polling new vultr server, avoid spurious ok status unquote simple filenames WIP. Use packer key, no more instance ssh key. Change API installation. Simplify packer/ansible. rename bubble_finalizer to just finalizer, remove default_roles filter servers/images based on installType for now, consider packer image OK if bubble version matches add algo/mitm roles to packer. add installType to BubbleNode fix NODE_ROLES file templatize packer file and playbook, use same template for sage and node WIP: refactor addAllRegions WIP: do not re-create identical images WIP: packer build for vultr now working Merge branch 'master' of git.bubblev.org:bubblev/bubble into cobbzilla/introduce_packer WIP. working on vultr packer builds WIP: packer image creation working for digitalocean WIP: packer basics working for digitalocean add packer endpoints, introduce packer support to cloud compute drivers remove roles endpoints AnsibleRole is no longer an model entity. Introduce Packer. Merge branch 'sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService' of git.bubblev.org:bubblev/bubble into sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService Merge branch 'master' of git.bubblev.org:bubblev/bubble into sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService Merge branch 'master' into sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService Merge branch 'master' into sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService Merge branch 'master' into sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService Merge branch 'master' into sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService Add instance count to script Co-authored-by: Jonathan Cobb <jonathan@kyuss.org> Co-authored-by: Svitlana <sfedoriv@itekako.com> Reviewed-on: https://git.bubblev.org/bubblev/bubble/pulls/18
4 年前
Introduce packer support (#18) cleanups and fixes, packer is ready to roll add errorApi endpoint initialize mitmproxy dependencies packer deployments finally working fix virtualenv call for ubuntu 20.04 WIP. update to ubuntu 20.04. fixing algo installation WIP. packer fixes remove unused constant WIP. packer basics working for ec2 Merge branch 'master' of git.bubblev.org:bubblev/bubble into cobbzilla/introduce_packer remove automation dir, all moved to resources log pg autovacuum if longer than 250ms touch install marker for algo set mitmproxy as owner of all mitmproxy files add hostname to packer image name avoid closing progress meter prematurely WIP. parallelize node startup, fix packer bugs clarify docs add missing vars, algo tweaks add missing vars, update algo hash WIP. improving algo/mitmproxy packer stuff install packer for sage, call packer from proper location Use compute driver to get regions improve comments wait longer before polling new vultr server, avoid spurious ok status unquote simple filenames WIP. Use packer key, no more instance ssh key. Change API installation. Simplify packer/ansible. rename bubble_finalizer to just finalizer, remove default_roles filter servers/images based on installType for now, consider packer image OK if bubble version matches add algo/mitm roles to packer. add installType to BubbleNode fix NODE_ROLES file templatize packer file and playbook, use same template for sage and node WIP: refactor addAllRegions WIP: do not re-create identical images WIP: packer build for vultr now working Merge branch 'master' of git.bubblev.org:bubblev/bubble into cobbzilla/introduce_packer WIP. working on vultr packer builds WIP: packer image creation working for digitalocean WIP: packer basics working for digitalocean add packer endpoints, introduce packer support to cloud compute drivers remove roles endpoints AnsibleRole is no longer an model entity. Introduce Packer. Merge branch 'sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService' of git.bubblev.org:bubblev/bubble into sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService Merge branch 'master' of git.bubblev.org:bubblev/bubble into sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService Merge branch 'master' into sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService Merge branch 'master' into sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService Merge branch 'master' into sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService Merge branch 'master' into sfedoriv/APIAddSupportForAmazonEC2ComputeCloudService Add instance count to script Co-authored-by: Jonathan Cobb <jonathan@kyuss.org> Co-authored-by: Svitlana <sfedoriv@itekako.com> Reviewed-on: https://git.bubblev.org/bubblev/bubble/pulls/18
4 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #!/bin/bash
  2. #
  3. # Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
  4. #
  5. # Run Bubble server or CLI commands. A wrapper for starting a JVM to run Bubble programs.
  6. #
  7. # Usage: run.sh [debug [debug-port]] [command] [args]
  8. #
  9. # All arguments are optional:
  10. #
  11. # debug : if the first argument is the literal string 'debug' then immediately after starting,
  12. # the Java process will wait for a debugger to attach. Default is not to enable debugging.
  13. # debug-port : the port that will be listened on for the debugger. Default port is 5005
  14. # command : the CLI command to run, or 'server' to run BUBBLE API server. Default is to run Bubble API server
  15. # args : depends on the command. Use '-h' to request help for a command
  16. #
  17. # Environment variables
  18. #
  19. # BUBBLE_LISTEN_ALL : if set to true and running a Bubble server, listen on all addresses (bind to 0.0.0.0)
  20. # if not set, server will only listen on 127.0.0.1
  21. # BUBBLE_ENV : env file to load, used when performing handlebars substitutions on entities marked
  22. # with `"_subst": true` JSON attribute. Default is ~/.bubble.env
  23. # BUBBLE_JVM_OPTS : Java options. Defaults to either "-Xmx512m -Xms512m" when no command is set, else "-Xmx64m -Xms2m"
  24. # BUBBLE_JAR : location of bubble uberjar. Default is to assume there is exactly one bubble-server*.jar file in a
  25. # directory named "target" that is in the same directory as this script
  26. #
  27. # Environment variables for API commands
  28. #
  29. # BUBBLE_API : which API to use. Default is local (http://127.0.0.1:PORT, where PORT is found in .bubble.env)
  30. # BUBBLE_USER : account to use. Default is root@local.local
  31. # BUBBLE_PASS : password for account. Default is password
  32. #
  33. #
  34. SCRIPT="${0}"
  35. SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)"
  36. . "${SCRIPT_DIR}"/bubble_common
  37. # fail on any command error
  38. set -e
  39. BASE=$(cd $(dirname $0) && pwd)
  40. if [[ $(basename ${BASE}) != "bubble-server" && -d "${BASE}/bubble-server" ]] ; then
  41. BASE="${BASE}/bubble-server"
  42. fi
  43. if [[ $(basename ${BASE}) == "bin" && -d "${BASE}/../bubble-server" ]] ; then
  44. BASE="$(cd ${BASE}/../bubble-server && pwd)"
  45. fi
  46. # save explicitly set key, if we have one
  47. SAVED_DB_KEY=""
  48. if [[ -n "${BUBBLE_DB_ENCRYPTION_KEY}" ]] ; then
  49. SAVED_DB_KEY="${BUBBLE_DB_ENCRYPTION_KEY}"
  50. fi
  51. if [[ -z "${BUBBLE_ENV}" ]] ; then
  52. BUBBLE_ENV="${HOME}/.bubble.env"
  53. if [[ ! -f "${BUBBLE_ENV}" ]] ; then
  54. BUBBLE_ENV="/home/bubble/api/bubble.env"
  55. fi
  56. fi
  57. if [[ -f ${BUBBLE_ENV} ]] ; then
  58. if [[ -z "${BUBBLE_QUIET}" || ${BUBBLE_QUIET} != 1 ]] ; then
  59. echo 1>&2 "Loading env: ${BUBBLE_ENV}"
  60. fi
  61. . ${BUBBLE_ENV}
  62. fi
  63. if [[ -n "${SAVED_DB_KEY}" ]] ; then
  64. export BUBBLE_DB_ENCRYPTION_KEY="${SAVED_DB_KEY}"
  65. fi
  66. debug="${1}"
  67. if [[ "x${debug}" == "xdebug" ]] ; then
  68. shift
  69. ARG_LEN=$(echo -n "${1}" | wc -c)
  70. ARG_NUMERIC_LEN=$(echo -n "${1}" | tr -dc [:digit:] | wc -c) # strip all non-digits
  71. if [[ -n "${ARG_NUMERIC_LEN}" && ${ARG_LEN} -eq ${ARG_NUMERIC_LEN} ]] ; then
  72. # Second arg is the debug port
  73. DEBUG_PORT="${1}"
  74. shift || :
  75. fi
  76. if [[ -z "${DEBUG_PORT}" ]] ; then
  77. DEBUG_PORT=5005
  78. fi
  79. debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${DEBUG_PORT}"
  80. else
  81. debug=""
  82. fi
  83. command="${1}"
  84. server=0
  85. DEFAULT_JVM_OPTS=""
  86. if [[ -z "${command}" ]] ; then
  87. server=1
  88. CLASS=bubble.server.BubbleServer
  89. DEFAULT_JVM_OPTS="-Xmx512m -Xms512m"
  90. else
  91. CLASS=bubble.main.BubbleMain
  92. DEFAULT_JVM_OPTS="-Xmx64m -Xms2m"
  93. shift
  94. fi
  95. if [[ -z "${BUBBLE_JAR}" ]] ; then
  96. die "API jar file not found"
  97. fi
  98. if [[ -z "${BUBBLE_JVM_OPTS}" ]] ; then
  99. BUBBLE_JVM_OPTS="${DEFAULT_JVM_OPTS}"
  100. fi
  101. BUBBLE_JVM_OPTS="${BUBBLE_JVM_OPTS} -Djava.net.preferIPv4Stack=true"
  102. # Choose appropriate log config
  103. if [[ ${server} -eq 1 ]] ; then
  104. LOG_CONFIG="-Dlogback.configurationFile=logback.xml"
  105. if [[ -f ${BUBBLE_ENV} ]] ; then
  106. command="${BUBBLE_ENV}"
  107. fi
  108. else
  109. LOG_CONFIG="-Dlogback.configurationFile=logback-client.xml"
  110. fi
  111. if [[ -z "${BUBBLE_ADDITIONAL_CLASSPATH}" ]] ; then
  112. BUBBLE_CP="${BUBBLE_JAR}"
  113. else
  114. BUBBLE_CP="${BUBBLE_JAR}:${BUBBLE_ADDITIONAL_CLASSPATH}"
  115. fi
  116. # Default user if none set
  117. if [[ -z "${BUBBLE_USER}" ]] ; then
  118. if [[ -n "${REQUIRE_BUBBLE_USER}" ]] ; then
  119. die "No BUBBLE_USER env var defined"
  120. fi
  121. BUBBLE_USER=root@local.local
  122. fi
  123. # Default password if none set
  124. if [[ -z "${BUBBLE_PASS}" ]] ; then
  125. # If BUBBLE_API is defined, we may have cached credentials
  126. BUBBLE_AUTH="${HOME}/.bubble_auth"
  127. if [[ -n "${BUBBLE_API}" && -d "${BUBBLE_AUTH}" ]] ; then
  128. if [[ -z "${BUBBLE_DISABLE_AUTH_CACHE}" || "${BUBBLE_DISABLE_AUTH_CACHE}" == "false" ]] ; then
  129. API_HOST="$(echo -n "${BUBBLE_API}" | awk -F '/' '{print $3}')"
  130. AUTH_DIR="${BUBBLE_AUTH}/${API_HOST}"
  131. PASS_FILE="${AUTH_DIR}/${BUBBLE_USER}"
  132. if [[ -n "${BUBBLE_USER}" && -f "${PASS_FILE}" ]] ; then
  133. if [[ -z "${BUBBLE_QUIET_AUTH_CACHE}" || "${BUBBLE_QUIET_AUTH_CACHE}" != "true" ]] ; then
  134. echo 1>&2 "Using cached password for user ${BUBBLE_USER} from ${AUTH_DIR}/${BUBBLE_USER}
  135. - Set env var BUBBLE_DISABLE_AUTH_CACHE=true to disable this behavior
  136. - Set env var BUBBLE_QUIET_AUTH_CACHE=true to hide this warning
  137. "
  138. fi
  139. BUBBLE_PASS="$(cat "${PASS_FILE}" | tr -d '[:space:]')"
  140. fi
  141. fi
  142. fi
  143. if [[ -n "${REQUIRE_BUBBLE_PASS}" ]] ; then
  144. die "No BUBBLE_PASS env var defined"
  145. fi
  146. echo 1>&2 "*** Warning: BUBBLE_PASS env var was not defined, using default password (probable authentication failure)"
  147. BUBBLE_PASS=password
  148. fi
  149. LISTEN_ALL=""
  150. if [[ -n "${BUBBLE_LISTEN_ALL}" && "${BUBBLE_LISTEN_ALL}" == "true" ]] ; then
  151. LISTEN_ALL="-Dbubble.listenAll=true"
  152. fi
  153. # Run!
  154. BUBBLE_JAR="${BUBBLE_JAR}" java ${LOG_CONFIG} ${BUBBLE_JVM_OPTS} \
  155. -Xlog:class+load=info:/tmp/bubble_classes_$(date +%s).txt \
  156. ${debug} -server -cp "${BUBBLE_CP}" ${LISTEN_ALL} ${CLASS} ${command} "${@}"