From 4e03e6d4cc4cedaa30e182829ebfde04ad6469a6 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Tue, 24 Nov 2020 05:10:10 -0500 Subject: [PATCH] update user/pass env var docs and default handling in run.sh --- bin/bactivate | 4 ++-- bin/bconst | 4 ++-- bin/bdelete | 4 ++-- bin/bget | 4 ++-- bin/bgeti | 4 ++-- bin/bgeti1 | 4 ++-- bin/bgetn | 4 ++-- bin/bgetn1 | 4 ++-- bin/bmodel | 4 ++-- bin/bpost | 4 ++-- bin/bposte | 4 ++-- bin/bput | 4 ++-- bin/bpute | 4 ++-- bin/bscript | 4 ++-- bin/bubble | 4 ++-- bin/bunlock | 4 ++-- bin/run.sh | 65 +++++++++++++++++++++++---------------------------- 17 files changed, 61 insertions(+), 68 deletions(-) diff --git a/bin/bactivate b/bin/bactivate index 6a49b2a1..5594d2b6 100755 --- a/bin/bactivate +++ b/bin/bactivate @@ -12,8 +12,8 @@ # Environment variables # # 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 -# BUBBLE_PASS : password for account. Default is root +# 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) diff --git a/bin/bconst b/bin/bconst index 4675bb4f..a59c6be9 100755 --- a/bin/bconst +++ b/bin/bconst @@ -22,8 +22,8 @@ # Environment variables # # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model. # diff --git a/bin/bdelete b/bin/bdelete index 29f81ae9..710b7fad 100755 --- a/bin/bdelete +++ b/bin/bdelete @@ -14,8 +14,8 @@ # Environment variables # # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model. # diff --git a/bin/bget b/bin/bget index e82183cd..2d598ed7 100755 --- a/bin/bget +++ b/bin/bget @@ -14,8 +14,8 @@ # Environment variables # # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model. # diff --git a/bin/bgeti b/bin/bgeti index e6213c4b..730b02a5 100755 --- a/bin/bgeti +++ b/bin/bgeti @@ -14,8 +14,8 @@ # Environment variables # # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model. # diff --git a/bin/bgeti1 b/bin/bgeti1 index 77215036..c4688b3e 100755 --- a/bin/bgeti1 +++ b/bin/bgeti1 @@ -14,8 +14,8 @@ # Environment variables # # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model. # diff --git a/bin/bgetn b/bin/bgetn index 12b70880..8877aa51 100755 --- a/bin/bgetn +++ b/bin/bgetn @@ -14,8 +14,8 @@ # Environment variables # # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model. # diff --git a/bin/bgetn1 b/bin/bgetn1 index 7f591d38..d43e32f7 100755 --- a/bin/bgetn1 +++ b/bin/bgetn1 @@ -14,8 +14,8 @@ # Environment variables # # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model. # diff --git a/bin/bmodel b/bin/bmodel index 097212bc..99cee3c6 100755 --- a/bin/bmodel +++ b/bin/bmodel @@ -12,8 +12,8 @@ # Environment variables # # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_SCRIPTS : location of run.sh script. Default is to assume it is in the same directory containing this script # SCRIPT="${0}" diff --git a/bin/bpost b/bin/bpost index 220b9b3e..85a4af58 100755 --- a/bin/bpost +++ b/bin/bpost @@ -16,8 +16,8 @@ # # BUBBLE_ENTITY : the filename that contains the JSON to send in the POST. If empty, entity is read from stdin # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model. # diff --git a/bin/bposte b/bin/bposte index e1f50f4f..b8f8515a 100755 --- a/bin/bposte +++ b/bin/bposte @@ -15,8 +15,8 @@ # # BUBBLE_ENTITY : the filename that contains the JSON to send in the POST. If empty, entity is read from stdin # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model. # diff --git a/bin/bput b/bin/bput index 66c2737e..1046e5a3 100755 --- a/bin/bput +++ b/bin/bput @@ -16,8 +16,8 @@ # # BUBBLE_ENTITY : the filename that contains the JSON to send in the PUT. If empty, entity is read from stdin # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model. # diff --git a/bin/bpute b/bin/bpute index 6918ae50..ca11508e 100755 --- a/bin/bpute +++ b/bin/bpute @@ -15,8 +15,8 @@ # # BUBBLE_ENTITY : the filename that contains the JSON to send in the PUT. If empty, entity is read from stdi # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model. # diff --git a/bin/bscript b/bin/bscript index 41080e7e..cce96a64 100755 --- a/bin/bscript +++ b/bin/bscript @@ -15,8 +15,8 @@ # Environment variables # # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model. # diff --git a/bin/bubble b/bin/bubble index e2b899e4..8b8ebfe4 100755 --- a/bin/bubble +++ b/bin/bubble @@ -14,8 +14,8 @@ # Environment variables # # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local@local.local +# BUBBLE_PASS : password for account. Default is password # BUBBLE_ENV : env file to load. Default is ~/.bubble.env or /home/bubble/api/bubble.env (whichever is found first) # DEBUG_PORT : if set, this is the port number the client will wait for a debugger to attach before starting # BUBBLE_INCLUDE : when using the sync-model and run-script commands, this is the directory to find included files diff --git a/bin/bunlock b/bin/bunlock index fc735513..f56fb198 100755 --- a/bin/bunlock +++ b/bin/bunlock @@ -13,8 +13,8 @@ # Environment variables # # 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 -# BUBBLE_PASS : password for account. Default is root +# 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) diff --git a/bin/run.sh b/bin/run.sh index 58cdf9ab..36e2a389 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -25,8 +25,8 @@ # 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 -# BUBBLE_PASS : password for account. Default is root +# BUBBLE_USER : account to use. Default is root@local.local +# BUBBLE_PASS : password for account. Default is password # # SCRIPT="${0}" @@ -124,50 +124,43 @@ else BUBBLE_CP="${BUBBLE_JAR}:${BUBBLE_ADDITIONAL_CLASSPATH}" fi -# If BUBBLE_API is defined, we may have cached credentials -BUBBLE_AUTH="${HOME}/.bubble_auth" -if [[ ! -z "${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}" - USER_FILE="${AUTH_DIR}/user" - PASS_FILE="${AUTH_DIR}/pass" - - if [[ ! -z "${BUBBLE_USER}" && -f "${AUTH_DIR}/${BUBBLE_USER}" ]] ; 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 BUBBLE_QUIET_AUTH_CACHE=true to hide this warning" - fi - BUBBLE_PASS="$(cat "${AUTH_DIR}/${BUBBLE_USER}" | tr -d '[:space:]')" - - elif [[ -f ${USER_FILE} && -f ${PASS_FILE} ]] ; then - if [[ -z "${BUBBLE_QUIET_AUTH_CACHE}" || "${BUBBLE_QUIET_AUTH_CACHE}" != "true" ]] ; then - echo 1>&2 "Using cached user/pass from ${USER_FILE} and ${PASS_FILE} -Set env var BUBBLE_DISABLE_AUTH_CACHE=true to disable this behavior -Set BUBBLE_QUIET_AUTH_CACHE=true to hide this warning" - fi - BUBBLE_USER="$(cat "${USER_FILE}" | tr -d '[:space:]')" - BUBBLE_PASS="$(cat "${PASS_FILE}" | tr -d '[:space:]')" - fi +# Default user if none set +if [[ -z "${BUBBLE_USER}" ]] ; then + if [[ ! -z "${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 [[ ! -z "${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 [[ ! -z "${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 [[ ! -z "${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 -# Default user if none set -if [[ -z "${BUBBLE_USER}" ]] ; then - if [[ ! -z "${REQUIRE_BUBBLE_USER}" ]] ; then - die "No BUBBLE_USER env var defined" - fi - BUBBLE_USER=root@local.local -fi - # Run! BUBBLE_JAR="${BUBBLE_JAR}" java ${LOG_CONFIG} ${BUBBLE_JVM_OPTS} ${debug} -server -cp "${BUBBLE_CP}" ${CLASS} ${command} "${@}"