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 |
- #!/bin/bash
- #
- # Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
- #
- # Run Bubble server or CLI commands. A wrapper for starting a JVM to run Bubble programs.
- #
- # Usage: run.sh [debug [debug-port]] [command] [args]
- #
- # All arguments are optional:
- #
- # debug : if the first argument is the literal string 'debug' then immediately after starting,
- # the Java process will wait for a debugger to attach. Default is not to enable debugging.
- # debug-port : the port that will be listened on for the debugger. Default port is 5005
- # command : the CLI command to run, or 'server' to run BUBBLE API server. Default is to run Bubble API server
- # args : depends on the command. Use '-h' to request help for a command
- #
- # Environment variables
- #
- # BUBBLE_LISTEN_ALL : if set to true and running a Bubble server, listen on all addresses (bind to 0.0.0.0)
- # if not set, server will only listen on 127.0.0.1
- # BUBBLE_ENV : env file to load, used when performing handlebars substitutions on entities marked
- # with `"_subst": true` JSON attribute. Default is ~/.bubble.env
- # BUBBLE_JVM_OPTS : Java options. Defaults to either "-Xmx512m -Xms512m" when no command is set, else "-Xmx64m -Xms2m"
- # BUBBLE_JAR : location of bubble uberjar. Default is to assume there is exactly one bubble-server*.jar file in a
- # directory named "target" that is in the same directory as this script
- #
- # Environment variables for API commands
- #
- # BUBBLE_API : which API to use. Default is local (http://127.0.0.1:PORT, where PORT is found in .bubble.env)
- # BUBBLE_USER : account to use. Default is root@local.local
- # BUBBLE_PASS : password for account. Default is password
- #
- #
- SCRIPT="${0}"
- SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)"
- . "${SCRIPT_DIR}"/bubble_common
-
- # fail on any command error
- set -e
-
- BASE=$(cd $(dirname $0) && pwd)
- if [[ $(basename ${BASE}) != "bubble-server" && -d "${BASE}/bubble-server" ]] ; then
- BASE="${BASE}/bubble-server"
- fi
- if [[ $(basename ${BASE}) == "bin" && -d "${BASE}/../bubble-server" ]] ; then
- BASE="$(cd ${BASE}/../bubble-server && pwd)"
- fi
-
- # save explicitly set key, if we have one
- SAVED_DB_KEY=""
- if [[ -n "${BUBBLE_DB_ENCRYPTION_KEY}" ]] ; then
- SAVED_DB_KEY="${BUBBLE_DB_ENCRYPTION_KEY}"
- fi
-
- if [[ -z "${BUBBLE_ENV}" ]] ; then
- BUBBLE_ENV="${HOME}/.bubble.env"
- if [[ ! -f "${BUBBLE_ENV}" ]] ; then
- BUBBLE_ENV="/home/bubble/api/bubble.env"
- fi
- fi
- if [[ -f ${BUBBLE_ENV} ]] ; then
- if [[ -z "${BUBBLE_QUIET}" || ${BUBBLE_QUIET} != 1 ]] ; then
- echo 1>&2 "Loading env: ${BUBBLE_ENV}"
- fi
- . ${BUBBLE_ENV}
- fi
-
- if [[ -n "${SAVED_DB_KEY}" ]] ; then
- export BUBBLE_DB_ENCRYPTION_KEY="${SAVED_DB_KEY}"
- fi
-
- debug="${1}"
- if [[ "x${debug}" == "xdebug" ]] ; then
- shift
- ARG_LEN=$(echo -n "${1}" | wc -c)
- ARG_NUMERIC_LEN=$(echo -n "${1}" | tr -dc [:digit:] | wc -c) # strip all non-digits
- if [[ -n "${ARG_NUMERIC_LEN}" && ${ARG_LEN} -eq ${ARG_NUMERIC_LEN} ]] ; then
- # Second arg is the debug port
- DEBUG_PORT="${1}"
- shift || :
- fi
- if [[ -z "${DEBUG_PORT}" ]] ; then
- DEBUG_PORT=5005
- fi
- debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${DEBUG_PORT}"
- else
- debug=""
- fi
-
- command="${1}"
- server=0
- DEFAULT_JVM_OPTS=""
- if [[ -z "${command}" ]] ; then
- server=1
- CLASS=bubble.server.BubbleServer
- DEFAULT_JVM_OPTS="-Xmx512m -Xms512m"
-
- else
- CLASS=bubble.main.BubbleMain
- DEFAULT_JVM_OPTS="-Xmx64m -Xms2m"
- shift
- fi
-
- if [[ -z "${BUBBLE_JAR}" ]] ; then
- die "API jar file not found"
- fi
-
- if [[ -z "${BUBBLE_JVM_OPTS}" ]] ; then
- BUBBLE_JVM_OPTS="${DEFAULT_JVM_OPTS}"
- fi
- BUBBLE_JVM_OPTS="${BUBBLE_JVM_OPTS} -Djava.net.preferIPv4Stack=true"
-
- # Choose appropriate log config
- if [[ ${server} -eq 1 ]] ; then
- LOG_CONFIG="-Dlogback.configurationFile=logback.xml"
- if [[ -f ${BUBBLE_ENV} ]] ; then
- command="${BUBBLE_ENV}"
- fi
- else
- LOG_CONFIG="-Dlogback.configurationFile=logback-client.xml"
- fi
-
- if [[ -z "${BUBBLE_ADDITIONAL_CLASSPATH}" ]] ; then
- BUBBLE_CP="${BUBBLE_JAR}"
- else
- BUBBLE_CP="${BUBBLE_JAR}:${BUBBLE_ADDITIONAL_CLASSPATH}"
- fi
-
- # Default user if none set
- if [[ -z "${BUBBLE_USER}" ]] ; then
- if [[ -n "${REQUIRE_BUBBLE_USER}" ]] ; then
- die "No BUBBLE_USER env var defined"
- fi
- BUBBLE_USER=root@local.local
- fi
-
- # Default password if none set
- if [[ -z "${BUBBLE_PASS}" ]] ; then
-
- # If BUBBLE_API is defined, we may have cached credentials
- BUBBLE_AUTH="${HOME}/.bubble_auth"
- if [[ -n "${BUBBLE_API}" && -d "${BUBBLE_AUTH}" ]] ; then
- if [[ -z "${BUBBLE_DISABLE_AUTH_CACHE}" || "${BUBBLE_DISABLE_AUTH_CACHE}" == "false" ]] ; then
- API_HOST="$(echo -n "${BUBBLE_API}" | awk -F '/' '{print $3}')"
- AUTH_DIR="${BUBBLE_AUTH}/${API_HOST}"
- PASS_FILE="${AUTH_DIR}/${BUBBLE_USER}"
-
- if [[ -n "${BUBBLE_USER}" && -f "${PASS_FILE}" ]] ; then
- if [[ -z "${BUBBLE_QUIET_AUTH_CACHE}" || "${BUBBLE_QUIET_AUTH_CACHE}" != "true" ]] ; then
- echo 1>&2 "Using cached password for user ${BUBBLE_USER} from ${AUTH_DIR}/${BUBBLE_USER}
- - Set env var BUBBLE_DISABLE_AUTH_CACHE=true to disable this behavior
- - Set env var BUBBLE_QUIET_AUTH_CACHE=true to hide this warning
- "
- fi
- BUBBLE_PASS="$(cat "${PASS_FILE}" | tr -d '[:space:]')"
- fi
- fi
- fi
-
- if [[ -n "${REQUIRE_BUBBLE_PASS}" ]] ; then
- die "No BUBBLE_PASS env var defined"
- fi
- echo 1>&2 "*** Warning: BUBBLE_PASS env var was not defined, using default password (probable authentication failure)"
- BUBBLE_PASS=password
- fi
-
- LISTEN_ALL=""
- if [[ -n "${BUBBLE_LISTEN_ALL}" && "${BUBBLE_LISTEN_ALL}" == "true" ]] ; then
- LISTEN_ALL="-Dbubble.listenAll=true"
- fi
-
- # Run!
- BUBBLE_JAR="${BUBBLE_JAR}" java ${LOG_CONFIG} ${BUBBLE_JVM_OPTS} \
- -Xlog:class+load=info:/tmp/bubble_classes_$(date +%s).txt \
- ${debug} -server -cp "${BUBBLE_CP}" ${LISTEN_ALL} ${CLASS} ${command} "${@}"
|