Browse Source

use -n instead of ! -z

tags/v1.5.4
Jonathan Cobb 4 years ago
parent
commit
2fafc2a7b0
18 changed files with 41 additions and 32 deletions
  1. +1
    -1
      bin/bmodel
  2. +1
    -1
      bin/bpatch
  3. +1
    -1
      bin/bpyvenv.sh
  4. +1
    -1
      bin/bscript
  5. +1
    -1
      bin/bubble
  6. +2
    -2
      bin/bubble_common
  7. +1
    -1
      bin/build_dist
  8. +1
    -1
      bin/cleanup_bubble_databases
  9. +1
    -1
      bin/git_update_bubble.sh
  10. +1
    -1
      bin/godaddy/gdcurl
  11. +11
    -2
      bin/install_packer.sh
  12. +1
    -1
      bin/mailgun/mgcurl
  13. +3
    -3
      bin/prep_bubble_jar
  14. +1
    -1
      bin/reset_bubble_db
  15. +7
    -7
      bin/run.sh
  16. +1
    -1
      bin/sendgrid/sgcurl
  17. +3
    -3
      bin/ubuntu_connect_bubble
  18. +3
    -3
      bin/ubuntu_disconnect_bubble

+ 1
- 1
bin/bmodel View File

@@ -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


+ 1
- 1
bin/bpatch View File

@@ -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


+ 1
- 1
bin/bpyvenv.sh View File

@@ -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}" "${@}"


+ 1
- 1
bin/bscript View File

@@ -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



+ 1
- 1
bin/bubble View File

@@ -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



+ 2
- 2
bin/bubble_common View File

@@ -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


+ 1
- 1
bin/build_dist View File

@@ -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"


+ 1
- 1
bin/cleanup_bubble_databases View File

@@ -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"


+ 1
- 1
bin/git_update_bubble.sh View File

@@ -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


+ 1
- 1
bin/godaddy/gdcurl View File

@@ -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


+ 11
- 2
bin/install_packer.sh View File

@@ -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"


+ 1
- 1
bin/mailgun/mgcurl View File

@@ -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


+ 3
- 3
bin/prep_bubble_jar View File

@@ -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=""


+ 1
- 1
bin/reset_bubble_db View File

@@ -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


+ 7
- 7
bin/run.sh View File

@@ -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)"


+ 1
- 1
bin/sendgrid/sgcurl View File

@@ -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


+ 3
- 3
bin/ubuntu_connect_bubble View File

@@ -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 =====================


+ 3
- 3
bin/ubuntu_disconnect_bubble View File

@@ -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 =====================


Loading…
Cancel
Save