chore(bin/emqx): add default values for bash vars

This commit is contained in:
Zaiming Shi 2021-11-09 21:30:40 +01:00
parent 1480bb6158
commit 9b9a070168
1 changed files with 18 additions and 16 deletions

View File

@ -225,7 +225,7 @@ relx_gen_id() {
# Control a node # Control a node
relx_nodetool() { relx_nodetool() {
command="$1"; shift command="$1"; shift
ERL_FLAGS="$ERL_FLAGS $EPMD_ARG" \ ERL_FLAGS="${ERL_FLAGS:-} $EPMD_ARG" \
"$ERTS_DIR/bin/escript" "$ROOTDIR/bin/nodetool" "$NAME_TYPE" "$NAME" \ "$ERTS_DIR/bin/escript" "$ROOTDIR/bin/nodetool" "$NAME_TYPE" "$NAME" \
-setcookie "$COOKIE" "$command" "$@" -setcookie "$COOKIE" "$command" "$@"
} }
@ -356,7 +356,7 @@ wait_for() {
} }
IS_BOOT_COMMAND='no' IS_BOOT_COMMAND='no'
case "$1" in case "${1:-}" in
start|start_boot) start|start_boot)
IS_BOOT_COMMAND='yes' IS_BOOT_COMMAND='yes'
;; ;;
@ -366,6 +366,8 @@ case "$1" in
foreground) foreground)
IS_BOOT_COMMAND='yes' IS_BOOT_COMMAND='yes'
;; ;;
*)
;;
esac esac
## Possible ways to configure emqx node name: ## Possible ways to configure emqx node name:
@ -419,7 +421,9 @@ fi
cd "$ROOTDIR" cd "$ROOTDIR"
case "$1" in COMMAND="${1:-}"
case "${COMMAND}" in
start|start_boot) start|start_boot)
# Make sure a node IS not running # Make sure a node IS not running
if relx_nodetool "ping" >/dev/null 2>&1; then if relx_nodetool "ping" >/dev/null 2>&1; then
@ -430,11 +434,9 @@ case "$1" in
# this flag passes down to console mode # this flag passes down to console mode
# so we know it's intended to be run in daemon mode # so we know it's intended to be run in daemon mode
export _EMQX_START_MODE="$1" export _EMQX_START_MODE="$COMMAND"
# Save this for later. case "$COMMAND" in
CMD=$1
case "$1" in
start) start)
shift shift
START_OPTION="console" START_OPTION="console"
@ -453,7 +455,7 @@ case "$1" in
[ "$RUN_PARAM" ] && set -- "$@" "$RUN_PARAM" [ "$RUN_PARAM" ] && set -- "$@" "$RUN_PARAM"
# Export the HEART_COMMAND # Export the HEART_COMMAND
HEART_COMMAND="$RUNNER_SCRIPT $CMD" HEART_COMMAND="$RUNNER_SCRIPT $COMMAND"
export HEART_COMMAND export HEART_COMMAND
## See: http://erlang.org/doc/man/run_erl.html ## See: http://erlang.org/doc/man/run_erl.html
@ -546,17 +548,17 @@ case "$1" in
;; ;;
upgrade|downgrade|install|unpack|uninstall) upgrade|downgrade|install|unpack|uninstall)
if [ -z "$2" ]; then if [ -z "${2:-}" ]; then
echo "Missing version argument" echo "Missing version argument"
echo "Usage: $REL_NAME $1 {version}" echo "Usage: $REL_NAME $COMMAND {version}"
exit 1 exit 1
fi fi
COMMAND="$1"; shift shift
assert_node_alive assert_node_alive
ERL_FLAGS="$ERL_FLAGS $EPMD_ARG" \ ERL_FLAGS="${ERL_FLAGS:-} $EPMD_ARG" \
exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \ exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \
"$COMMAND" "{'$REL_NAME', \"$NAME_TYPE\", '$NAME', '$COOKIE'}" "$@" "$COMMAND" "{'$REL_NAME', \"$NAME_TYPE\", '$NAME', '$COOKIE'}" "$@"
;; ;;
@ -564,9 +566,9 @@ case "$1" in
versions) versions)
assert_node_alive assert_node_alive
COMMAND="$1"; shift shift
ERL_FLAGS="$ERL_FLAGS $EPMD_ARG" \ ERL_FLAGS="${ERL_FLAGS:-} $EPMD_ARG" \
exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \ exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \
"versions" "{'$REL_NAME', \"$NAME_TYPE\", '$NAME', '$COOKIE'}" "$@" "versions" "{'$REL_NAME', \"$NAME_TYPE\", '$NAME', '$COOKIE'}" "$@"
;; ;;
@ -578,7 +580,7 @@ case "$1" in
# .boot file typically just $REL_NAME (ie, the app name) # .boot file typically just $REL_NAME (ie, the app name)
# however, for debugging, sometimes start_clean.boot is useful. # however, for debugging, sometimes start_clean.boot is useful.
# For e.g. 'setup', one may even want to name another boot script. # For e.g. 'setup', one may even want to name another boot script.
case "$1" in case "$COMMAND" in
console) console)
if [ -f "$REL_DIR/$REL_NAME.boot" ]; then if [ -f "$REL_DIR/$REL_NAME.boot" ]; then
BOOTFILE="$REL_DIR/$REL_NAME" BOOTFILE="$REL_DIR/$REL_NAME"
@ -707,7 +709,7 @@ case "$1" in
relx_nodetool "eval" "$@" relx_nodetool "eval" "$@"
;; ;;
*) *)
relx_usage "$1" relx_usage "$COMMAND"
exit 1 exit 1
;; ;;
esac esac