diff --git a/bin/bmodel b/bin/bmodel index 99cee3c6..d97983b2 100755 --- a/bin/bmodel +++ b/bin/bmodel @@ -21,7 +21,7 @@ SCRIPT_DIR=$(cd $(dirname ${SCRIPT}) && pwd) . ${SCRIPT_DIR}/bubble_common UPDATE_OPT="" -if [[ ! -z "${1}" && ( "${1}" == "-u" || "${1}" == "--update-all" ) ]] ; then +if [[ -n "${1}" && ( "${1}" == "-u" || "${1}" == "--update-all" ) ]] ; then UPDATE_OPT="--update-all" shift fi diff --git a/bin/bpatch b/bin/bpatch index a01a537d..b0ee85fd 100755 --- a/bin/bpatch +++ b/bin/bpatch @@ -54,7 +54,7 @@ else scp -P ${BUBBLE_SSH_PORT} "$(find "./target" -type f -name "bubble*.jar" | grep -v full | head -1)" ${HOST}:/tmp/bubble.jar || die "Error copying file to remote host ${HOST}" fi -if [[ ! -z "${NO_RESTART}" && "${NO_RESTART}" == "norestart" ]] ; then +if [[ -n "${NO_RESTART}" && "${NO_RESTART}" == "norestart" ]] ; then echo "Patching but not restarting: ${HOST} ..." ssh -p ${BUBBLE_SSH_PORT} ${HOST} "cat /tmp/bubble.jar > ~bubble/api/bubble.jar" else diff --git a/bin/bpyvenv.sh b/bin/bpyvenv.sh index 591ad631..d91ccf30 100755 --- a/bin/bpyvenv.sh +++ b/bin/bpyvenv.sh @@ -19,7 +19,7 @@ fi . ${BUBBLE_HOME}/.venv/bin/activate || die "Error activating bubble venv" python3 -m pip install requests || die "Error installing pip packages" -if [[ ! -z "${1}" ]] ; then +if [[ -n "${1}" ]] ; then script=${1} shift echo python3 "${script}" "${@}" diff --git a/bin/bscript b/bin/bscript index cce96a64..20857037 100755 --- a/bin/bscript +++ b/bin/bscript @@ -40,7 +40,7 @@ if [[ -z "${BUBBLE_INCLUDE}" ]] ; then fi done fi -if [[ ! -z "${BUBBLE_INCLUDE}" ]] ; then +if [[ -n "${BUBBLE_INCLUDE}" ]] ; then BUBBLE_INCLUDE="-I ${BUBBLE_INCLUDE}" fi diff --git a/bin/bubble b/bin/bubble index 8b8ebfe4..34a8c577 100755 --- a/bin/bubble +++ b/bin/bubble @@ -54,7 +54,7 @@ fi # always send help commands through last_arg="$(echo "${@}" | awk '{print $NF}')" is_help=0 -if [[ ! -z "${last_arg}" && ( "${last_arg}" == "-h" || "${last_arg}" == "--help" ) ]] ; then +if [[ -n "${last_arg}" && ( "${last_arg}" == "-h" || "${last_arg}" == "--help" ) ]] ; then is_help=1 fi diff --git a/bin/bubble_common b/bin/bubble_common index d0c98db0..70a23864 100755 --- a/bin/bubble_common +++ b/bin/bubble_common @@ -106,10 +106,10 @@ if [[ -z "${BUBBLE_JAR}" ]] ; then BUBBLE_JAR="${BUBBLE_SCRIPTS}/../bubble.jar" else BUBBLE_JAR="$(find "${BUBBLE_SCRIPTS}/../bubble-server/target" -type f -name "bubble*.jar" | head -1)" - if [[ ! -z "${BUBBLE_JAR}" ]] ; then + if [[ -n "${BUBBLE_JAR}" ]] ; then # Use full jar if available. Client libraries like to have the JS engine for example. This is stripped from the server. BUBBLE_FULL_JAR="$(find "${BUBBLE_SCRIPTS}/../bubble-server/target" -type f -name "bubble*-full.jar" | head -1)" - if [[ ! -z "${BUBBLE_FULL_JAR}" ]] ; then + if [[ -n "${BUBBLE_FULL_JAR}" ]] ; then BUBBLE_JAR="${BUBBLE_FULL_JAR}" fi fi diff --git a/bin/build_dist b/bin/build_dist index a2684ad8..e8b30ac6 100755 --- a/bin/build_dist +++ b/bin/build_dist @@ -64,7 +64,7 @@ cd "${DIST}/.." && zip -r "${ZIP}" "$(basename ${DIST})" echo "Distribution created: " ls -lh "${ZIP}" -if [[ ! -z "${BUBBLE_DIST_HOME}" ]] ; then +if [[ -n "${BUBBLE_DIST_HOME}" ]] ; then IS_DEV=0 if [[ -z ${BUILD_NUMBER} ]] ; then BUILD_NUMBER="dev" diff --git a/bin/cleanup_bubble_databases b/bin/cleanup_bubble_databases index 84717ee3..5f3acdb9 100755 --- a/bin/cleanup_bubble_databases +++ b/bin/cleanup_bubble_databases @@ -37,7 +37,7 @@ if [[ ${DATABASE_COUNT} -gt 0 ]] ; then echo "Cleaning up ${DATABASE_COUNT} databases..." DATABASES="$(echo "select datname from pg_database" | psql -qt -U ${DB_USER} template1 | grep ${DB_MATCH} | tr -d ' ')" - if [[ ! -z "${DATABASES}" ]] ; then + if [[ -n "${DATABASES}" ]] ; then for db in ${DATABASES} ; do if [[ "${db}" == "bubble" ]] ; then echo "Not dropping bubble default database" diff --git a/bin/git_update_bubble.sh b/bin/git_update_bubble.sh index 38efd7b7..383f4f68 100755 --- a/bin/git_update_bubble.sh +++ b/bin/git_update_bubble.sh @@ -20,7 +20,7 @@ function die { } FAST=${1} -if [[ ! -z "${FAST}" && "${FAST}" == "fast" ]] ; then +if [[ -n "${FAST}" && "${FAST}" == "fast" ]] ; then FAST=1 else FAST=0 diff --git a/bin/godaddy/gdcurl b/bin/godaddy/gdcurl index 0be1abff..d91602a6 100755 --- a/bin/godaddy/gdcurl +++ b/bin/godaddy/gdcurl @@ -17,7 +17,7 @@ HTTP_METHOD=${3} API_BASE=https://api.godaddy.com/v1/domains/ -if [[ ! -z "${POST_FILE}" ]] ; then +if [[ -n "${POST_FILE}" ]] ; then if [[ -z "${HTTP_METHOD}" ]] ; then curl -d @${POST_FILE} -s -H 'Content-Type: application/json' -H "Authorization: sso-key ${GODADDY_API_KEY}:${GODADDY_API_SECRET}" ${API_BASE}${URI} else diff --git a/bin/install_packer.sh b/bin/install_packer.sh index 0c36860b..0d712a68 100755 --- a/bin/install_packer.sh +++ b/bin/install_packer.sh @@ -13,6 +13,15 @@ function die { PLATFORM="$(uname -s)" +CURL="" +if [[ -z "$(which curl)" ]] ; then + if [[ -f /usr/bin/curl ]] ; then + CURL=/usr/bin/curl + fi +else + CURL="$(which curl)" +fi + # Install packer if [[ ! -f ${HOME}/packer/packer ]] ; then PACKER_VERSION=1.6.5 @@ -24,7 +33,7 @@ if [[ ! -f ${HOME}/packer/packer ]] ; then die "Add packer support to script ${0} for platform ${PLATFORM}" fi PACKER_URL=https://releases.hashicorp.com/packer/${PACKER_VERSION}/${PACKER_FILE} - mkdir -p ${HOME}/packer && cd ${HOME}/packer && curl -L ${PACKER_URL} -o ${PACKER_FILE} && unzip ${PACKER_FILE} || die "Error installing packer" + mkdir -p ${HOME}/packer && cd ${HOME}/packer && "${CURL}" -L ${PACKER_URL} -o ${PACKER_FILE} && unzip ${PACKER_FILE} || die "Error installing packer" echo "Packer successfully installed" else echo "Packer already installed" @@ -41,7 +50,7 @@ if [[ ! -f ${HOME}/.packer.d/plugins/packer-builder-vultr ]] ; then die "Add packer vultr support to script ${0} for platform ${PLATFORM}" fi PACKER_VULTR_URL=https://github.com/vultr/packer-builder-vultr/releases/download/v${PACKER_VULTR_VERSION}/${PACKER_VULTR_FILE} - mkdir -p ${HOME}/.packer.d/plugins && cd ${HOME}/.packer.d/plugins && curl -L ${PACKER_VULTR_URL} -o ${PACKER_VULTR_FILE} && tar xzf ${PACKER_VULTR_FILE} || die "Error installing packer vultr plugin" + mkdir -p ${HOME}/.packer.d/plugins && cd ${HOME}/.packer.d/plugins && "${CURL}" -L ${PACKER_VULTR_URL} -o ${PACKER_VULTR_FILE} && tar xzf ${PACKER_VULTR_FILE} || die "Error installing packer vultr plugin" echo "Packer Vultr plugin successfully installed" else echo "Packer vultr plugin already installed" diff --git a/bin/mailgun/mgcurl b/bin/mailgun/mgcurl index 1a8bfeae..01e1c649 100755 --- a/bin/mailgun/mgcurl +++ b/bin/mailgun/mgcurl @@ -17,7 +17,7 @@ function auth () { echo -n "Authorization: Basic $(echo -n "api:${BUBBLE_MAILGUN_API_KEY}" | base64)" } -if [[ ! -z "${POST_FILE}" ]] ; then +if [[ -n "${POST_FILE}" ]] ; then if [[ -z "${HTTP_METHOD}" ]] ; then curl -d @${POST_FILE} -s -H 'Content-Type: multipart/form-data' -H "$(auth)" ${API_BASE}${URI} else diff --git a/bin/prep_bubble_jar b/bin/prep_bubble_jar index b4ba96ff..0a24e988 100755 --- a/bin/prep_bubble_jar +++ b/bin/prep_bubble_jar @@ -23,7 +23,7 @@ SCRIPT="${0}" SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)" . "${SCRIPT_DIR}/bubble_common" -if [[ ! -z "${DEBUG_BUILD}" && "${DEBUG_BUILD}" == "debug" ]] ; then +if [[ -n "${DEBUG_BUILD}" && "${DEBUG_BUILD}" == "debug" ]] ; then echo "DEBUG_BUILD is set, not doing anything further" exit 0 fi @@ -42,10 +42,10 @@ done cd "${CLASSES_DIR}" && zip -u -r "${BUBBLE_JAR}" scripts || die "Error updating ${BUBBLE_JAR} with scripts" -if [[ ! -z "${BUBBLE_PRODUCTION}" || ( ! -z "${INSTALL_WEB}" && "${INSTALL_WEB}" == "web" ) ]] ; then +if [[ -n "${BUBBLE_PRODUCTION}" || ( -n "${INSTALL_WEB}" && "${INSTALL_WEB}" == "web" ) ]] ; then mkdir -p "${CLASSES_DIR}/site" BUBBLE_WEB="$(cd "${SCRIPT_DIR}/../bubble-web" && pwd)" - if [[ ! -z "${BUBBLE_PRODUCTION}" ]] ; then + if [[ -n "${BUBBLE_PRODUCTION}" ]] ; then WEBPACK_OPTIONS="--mode=production" else WEBPACK_OPTIONS="" diff --git a/bin/reset_bubble_db b/bin/reset_bubble_db index 8d0a01c2..be811911 100755 --- a/bin/reset_bubble_db +++ b/bin/reset_bubble_db @@ -13,7 +13,7 @@ SCRIPT_DIR="$(cd "$(dirname "${SCRIPT}")" && pwd)" . "${SCRIPT_DIR}/bubble_common" DEBUG=${1} -if [[ ! -z "${DEBUG}" && "${DEBUG}" == "debug" ]] ; then +if [[ -n "${DEBUG}" && "${DEBUG}" == "debug" ]] ; then DEBUG=1 else DEBUG=0 diff --git a/bin/run.sh b/bin/run.sh index a5c52923..93096579 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -46,7 +46,7 @@ fi # save explicitly set key, if we have one SAVED_DB_KEY="" -if [[ ! -z "${BUBBLE_DB_ENCRYPTION_KEY}" ]] ; then +if [[ -n "${BUBBLE_DB_ENCRYPTION_KEY}" ]] ; then SAVED_DB_KEY="${BUBBLE_DB_ENCRYPTION_KEY}" fi @@ -63,7 +63,7 @@ if [[ -f ${BUBBLE_ENV} ]] ; then . ${BUBBLE_ENV} fi -if [[ ! -z "${SAVED_DB_KEY}" ]] ; then +if [[ -n "${SAVED_DB_KEY}" ]] ; then export BUBBLE_DB_ENCRYPTION_KEY="${SAVED_DB_KEY}" fi @@ -72,7 +72,7 @@ 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 [[ ! -z "${ARG_NUMERIC_LEN}" && ${ARG_LEN} -eq ${ARG_NUMERIC_LEN} ]] ; then + if [[ -n "${ARG_NUMERIC_LEN}" && ${ARG_LEN} -eq ${ARG_NUMERIC_LEN} ]] ; then # Second arg is the debug port DEBUG_PORT="${1}" shift || : @@ -126,7 +126,7 @@ fi # Default user if none set if [[ -z "${BUBBLE_USER}" ]] ; then - if [[ ! -z "${REQUIRE_BUBBLE_USER}" ]] ; then + if [[ -n "${REQUIRE_BUBBLE_USER}" ]] ; then die "No BUBBLE_USER env var defined" fi BUBBLE_USER=root@local.local @@ -137,13 +137,13 @@ 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 [[ -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 [[ ! -z "${BUBBLE_USER}" && -f "${PASS_FILE}" ]] ; then + 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 @@ -155,7 +155,7 @@ if [[ -z "${BUBBLE_PASS}" ]] ; then fi fi - if [[ ! -z "${REQUIRE_BUBBLE_PASS}" ]] ; then + 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)" diff --git a/bin/sendgrid/sgcurl b/bin/sendgrid/sgcurl index 799d5460..af5d81ba 100755 --- a/bin/sendgrid/sgcurl +++ b/bin/sendgrid/sgcurl @@ -13,7 +13,7 @@ URI="${1:?no uri}" POST_FILE="${2}" HTTP_METHOD=${3} -if [[ ! -z "${POST_FILE}" ]] ; then +if [[ -n "${POST_FILE}" ]] ; then if [[ -z "${HTTP_METHOD}" ]] ; then curl -d @${POST_FILE} -s -H 'Content-Type: application/json' -H "Authorization: Bearer ${BUBBLE_SMTP_PASS}" ${API_BASE}${URI} else diff --git a/bin/ubuntu_connect_bubble b/bin/ubuntu_connect_bubble index 251ea17e..ae1dd744 100755 --- a/bin/ubuntu_connect_bubble +++ b/bin/ubuntu_connect_bubble @@ -82,7 +82,7 @@ if [[ -z "$(which resolvconf)" ]] ; then INSTALL_PACKAGES="${INSTALL_PACKAGES} resolvconf" fi -if [[ ! -z "${INSTALL_PACKAGES}" ]] ; then +if [[ -n "${INSTALL_PACKAGES}" ]] ; then echo " The following apt packages will be installed: @@ -141,7 +141,7 @@ export BUBBLE_SKIP_PATH_WARNING=true bget me | jq .email > /dev/null || die "Error logging into Bubble with API: ${BUBBLE_API}" # Ensure WireGuard is not running -if [[ ! -z "$(sudo wg show)" ]] ; then +if [[ -n "$(sudo wg show)" ]] ; then echo "Stopping WireGuard VPN ..." sudo wg-quick down wg0 fi @@ -334,7 +334,7 @@ VPN Config : ${WG_CONF} Public IP : $(curl -s http://checkip.amazonaws.com/) " -if [[ ! -z "$(which firefox)" ]] ; then +if [[ -n "$(which firefox)" ]] ; then echo " =========================================================== ===================== Firefox Warning ===================== diff --git a/bin/ubuntu_disconnect_bubble b/bin/ubuntu_disconnect_bubble index 0e2faa5d..567673db 100755 --- a/bin/ubuntu_disconnect_bubble +++ b/bin/ubuntu_disconnect_bubble @@ -31,7 +31,7 @@ function die() { SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)" DO_DELETE=0 -if [[ ! -z "${1}" ]] ; then +if [[ -n "${1}" ]] ; then if [[ "${1}" == "delete" ]] ; then DO_DELETE=1 else @@ -47,7 +47,7 @@ if [[ -z "$(which wg-quick)" ]] ; then fi # Ensure WireGuard is not running -if [[ ! -z "$(sudo wg show)" ]] ; then +if [[ -n "$(sudo wg show)" ]] ; then echo "Stopping WireGuard VPN ..." sudo wg-quick down wg0 else @@ -162,7 +162,7 @@ Bubble Host : ${BUBBLE_HOST} Public IP : $(curl -s http://checkip.amazonaws.com/) " -if [[ ! -z "$(which firefox)" ]] ; then +if [[ -n "$(which firefox)" ]] ; then echo " =========================================================== ===================== Firefox Warning =====================