The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

85 linhas
3.1 KiB

  1. #!/bin/bash
  2. #
  3. # Initial activation of a bubble server
  4. #
  5. # Usage: activate [domain] [dns] [storage]
  6. #
  7. # domain : a domain name. Must be listed in bubble-server/src/test/resources/models/system/bubbleDomain.json
  8. # default value is bubblev.org
  9. # dns : name of a CloudService of type 'dns'. Must be listed in bubble-server/src/test/resources/models/system/cloudService.json
  10. # default is GoDaddyDns
  11. # storage : name of a CloudService of type 'storage'. Must be listed in cloudService.json
  12. # default is S3_US_Standard
  13. #
  14. # Environment variables
  15. #
  16. # BUBBLE_API : which API to use. Default is local (http://127.0.0.1:PORT, where PORT is found in .bubble.env)
  17. # BUBBLE_USER : account to use. Default is root
  18. # BUBBLE_PASS : password for account. Default is root
  19. #
  20. SCRIPT="${0}"
  21. SCRIPT_DIR=$(cd $(dirname ${SCRIPT}) && pwd)
  22. . ${SCRIPT_DIR}/bubble_common
  23. if [[ -z "${BUBBLE_JAR}" ]] ; then
  24. die "BUBBLE_JAR env var not set and no jar file found"
  25. fi
  26. MODELS_DIR="${SCRIPT_DIR}/../bubble-server/src/test/resources/models/system"
  27. if [[ ! -d ${MODELS_DIR} ]] ; then
  28. die "Models directory not found: ${MODELS_DIR}"
  29. fi
  30. ENV_FILE="${HOME}/.bubble.env"
  31. if [[ ! -f ${ENV_FILE} ]] ; then
  32. die "env file not found: ${ENV_FILE}"
  33. fi
  34. # Source env vars
  35. . ${ENV_FILE}
  36. DOMAIN=${1:-bubblev.org}
  37. DOMAINS_FILE="${MODELS_DIR}/bubbleDomain.json"
  38. DOMAIN_JSON=$(cat ${DOMAINS_FILE} | sed -e 's,// .*,,g' | grep -v "_subst" | java -cp ${BUBBLE_JAR} bubble.main.BubbleMain handlebars | jq ".[] | select(.name==\"${DOMAIN}\")")
  39. if [[ -z "${DOMAIN_JSON}" ]] ; then
  40. die "Domain ${DOMAIN} not found in ${DOMAINS_FILE}"
  41. fi
  42. DNS_CLOUD=${2:-GoDaddyDns}
  43. CLOUDS_FILE="${MODELS_DIR}/cloudService.json"
  44. DNS_JSON=$(cat ${CLOUDS_FILE} | sed -e 's,// .*,,g' | grep -v "_subst" | java -cp ${BUBBLE_JAR} bubble.main.BubbleMain handlebars | jq ".[] | select(.name==\"${DNS_CLOUD}\")")
  45. if [[ -z "${DNS_JSON}" ]] ; then
  46. die "DNS CloudService ${DNS_CLOUD} not found in ${CLOUDS_FILE}"
  47. fi
  48. CLOUD_TYPE="$(echo ${DNS_JSON} | jq -r .type)"
  49. if [[ -z "${CLOUD_TYPE}" ]] ; then
  50. die "DNS service ${DNS_CLOUD} has no type"
  51. fi
  52. if [[ "${CLOUD_TYPE}" != 'dns' ]] ; then
  53. die "DNS service ${DNS_CLOUD} has wrong type (${CLOUD_TYPE}), expected: dns"
  54. fi
  55. STORAGE_CLOUD=${2:-S3_US_Standard}
  56. STORAGE_JSON=$(cat ${CLOUDS_FILE} | sed -e 's,// .*,,g' | grep -v "_subst" | java -cp ${BUBBLE_JAR} bubble.main.BubbleMain handlebars | jq ".[] | select(.name==\"${STORAGE_CLOUD}\")")
  57. if [[ -z "${STORAGE_JSON}" ]] ; then
  58. die "Storage CloudService ${STORAGE_CLOUD} not found in ${CLOUDS_FILE}"
  59. fi
  60. CLOUD_TYPE="$(echo ${STORAGE_JSON} | jq -r .type)"
  61. if [[ -z "${CLOUD_TYPE}" ]] ; then
  62. die "Storage service ${DNS_CLOUD} has no type"
  63. fi
  64. if [[ "${CLOUD_TYPE}" != 'storage' ]] ; then
  65. die "Storage service ${DNS_CLOUD} has wrong type (${CLOUD_TYPE}), expected: storage"
  66. fi
  67. exec ${SCRIPT_DIR}/bput auth/activate - --no-login <<EOF
  68. {
  69. "name": "${BUBBLE_USER}",
  70. "password": "${BUBBLE_PASS}",
  71. "networkName": "$(hostname -s)",
  72. "domain": ${DOMAIN_JSON},
  73. "dns": ${DNS_JSON},
  74. "storage": ${STORAGE_JSON}
  75. }
  76. EOF