chore(scripts): boot commands also need node name and cookie
This commit is contained in:
parent
6476a5ea92
commit
a898f6be1e
57
bin/emqx
57
bin/emqx
|
@ -278,18 +278,20 @@ if [ -z "$NAME_ARG" ]; then
|
||||||
NODENAME="${EMQX_NODE_NAME:-}"
|
NODENAME="${EMQX_NODE_NAME:-}"
|
||||||
# compatible with docker entrypoint
|
# compatible with docker entrypoint
|
||||||
[ -z "$NODENAME" ] && [ -n "$EMQX_NAME" ] && [ -n "$EMQX_HOST" ] && NODENAME="${EMQX_NAME}@${EMQX_HOST}"
|
[ -z "$NODENAME" ] && [ -n "$EMQX_NAME" ] && [ -n "$EMQX_HOST" ] && NODENAME="${EMQX_NAME}@${EMQX_HOST}"
|
||||||
if [ -z "$NODENAME" ] && [ "$IS_BOOT_COMMAND" = 'no' ]; then
|
if [ -z "$NODENAME" ]; then
|
||||||
# for non-boot commands, inspect vm.<time>.args for node name
|
if [ "$IS_BOOT_COMMAND" = 'no' ]; then
|
||||||
# shellcheck disable=SC2012,SC2086
|
# for non-boot commands, inspect vm.<time>.args for node name
|
||||||
LATEST_VM_ARGS="$(ls -t $RUNNER_DATA_DIR/configs/vm.*.args | head -1)"
|
# shellcheck disable=SC2012,SC2086
|
||||||
if [ -z "$LATEST_VM_ARGS" ]; then
|
LATEST_VM_ARGS="$(ls -t $RUNNER_DATA_DIR/configs/vm.*.args | head -1)"
|
||||||
echo "For command $1, there is no vm.*.args config file found in $RUNNER_DATA_DIR/configs/"
|
if [ -z "$LATEST_VM_ARGS" ]; then
|
||||||
exit 1
|
echo "For command $1, there is no vm.*.args config file found in $RUNNER_DATA_DIR/configs/"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
NODENAME="$(grep -E '^-name' "$LATEST_VM_ARGS" | awk '{print $2}')"
|
||||||
|
else
|
||||||
|
# for boot commands, inspect emqx.conf for node name
|
||||||
|
NODENAME=$(grep -E '^[ \t]*node.name[ \t]*=[ \t]*' "$RUNNER_ETC_DIR/emqx.conf" 2> /dev/null | tail -1 | cut -d = -f 2-)
|
||||||
fi
|
fi
|
||||||
NODENAME="$(grep -E '^-name' "$LATEST_VM_ARGS" | awk '{print $2}')"
|
|
||||||
else
|
|
||||||
# for boot commands, inspect emqx.conf for node name
|
|
||||||
NODENAME=$(grep -E '^[ \t]*node.name[ \t]*=[ \t]*' "$RUNNER_ETC_DIR/emqx.conf" 2> /dev/null | tail -1 | cut -d = -f 2-)
|
|
||||||
fi
|
fi
|
||||||
if [ -z "$NODENAME" ]; then
|
if [ -z "$NODENAME" ]; then
|
||||||
echoerr "Failed to resolve emqx node name"
|
echoerr "Failed to resolve emqx node name"
|
||||||
|
@ -299,9 +301,8 @@ if [ -z "$NAME_ARG" ]; then
|
||||||
echoerr "Maybe set environment variable ENQX_NODE_NAME='name@host.name'"
|
echoerr "Maybe set environment variable ENQX_NODE_NAME='name@host.name'"
|
||||||
echoerr "or set EMQX_NAME='name' EMQX_HOST='host.name'"
|
echoerr "or set EMQX_NAME='name' EMQX_HOST='host.name'"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
|
||||||
NAME_ARG="-name ${NODENAME# *}"
|
|
||||||
fi
|
fi
|
||||||
|
NAME_ARG="-name ${NODENAME# *}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract the name type and name from the NAME_ARG for REMSH
|
# Extract the name type and name from the NAME_ARG for REMSH
|
||||||
|
@ -312,24 +313,26 @@ export ESCRIPT_NAME="$NODENAME"
|
||||||
|
|
||||||
PIPE_DIR="${PIPE_DIR:-/$RUNNER_DATA_DIR/${WHOAMI}_erl_pipes/$NAME/}"
|
PIPE_DIR="${PIPE_DIR:-/$RUNNER_DATA_DIR/${WHOAMI}_erl_pipes/$NAME/}"
|
||||||
|
|
||||||
# COOKIE is only needed for non-boot commands
|
|
||||||
# so, either read environment variable override
|
|
||||||
# or inspect vm.<time>.args
|
|
||||||
COOKIE="${EMQX_NODE_COOKIE:-}"
|
COOKIE="${EMQX_NODE_COOKIE:-}"
|
||||||
if [ -z "$COOKIE" ] && [ "$IS_BOOT_COMMAND" = 'no' ]; then
|
if [ -z "$COOKIE" ]; then
|
||||||
# shellcheck disable=SC2012,SC2086
|
if [ "$IS_BOOT_COMMAND" = 'yes' ]; then
|
||||||
LATEST_VM_ARGS="$(ls -t $RUNNER_DATA_DIR/configs/vm.*.args | head -1)"
|
COOKIE=$(grep -E '^[ \t]*node.cookie[ \t]*=[ \t]*' "$RUNNER_ETC_DIR/emqx.conf" 2> /dev/null | tail -1 | cut -d = -f 2-)
|
||||||
if [ -z "$LATEST_VM_ARGS" ]; then
|
else
|
||||||
echo "For command $1, there is no vm.*.args config file found in $RUNNER_DATA_DIR/configs/"
|
# shellcheck disable=SC2012,SC2086
|
||||||
exit 1
|
LATEST_VM_ARGS="$(ls -t $RUNNER_DATA_DIR/configs/vm.*.args | head -1)"
|
||||||
fi
|
if [ -z "$LATEST_VM_ARGS" ]; then
|
||||||
COOKIE="$(grep -E '^-setcookie' "$LATEST_VM_ARGS" | awk '{print $2}')"
|
echo "For command $1, there is no vm.*.args config file found in $RUNNER_DATA_DIR/configs/"
|
||||||
if [ -z "$COOKIE" ]; then
|
exit 1
|
||||||
echoerr "Please set node.cookie in $RUNNER_ETC_DIR/emqx.conf or override from environment variable EMQX_NODE_COOKIE"
|
fi
|
||||||
exit 1
|
COOKIE="$(grep -E '^-setcookie' "$LATEST_VM_ARGS" | awk '{print $2}')"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$COOKIE" ]; then
|
||||||
|
echoerr "Please set node.cookie in $RUNNER_ETC_DIR/emqx.conf or override from environment variable EMQX_NODE_COOKIE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Support for IPv6 Dist. See: https://github.com/emqtt/emqttd/issues/1460
|
# Support for IPv6 Dist. See: https://github.com/emqtt/emqttd/issues/1460
|
||||||
PROTO_DIST=$(grep -E '^[ \t]*cluster.proto_dist[ \t]*=[ \t]*' "$RUNNER_ETC_DIR/emqx.conf" 2> /dev/null | tail -1 | cut -d = -f 2-)
|
PROTO_DIST=$(grep -E '^[ \t]*cluster.proto_dist[ \t]*=[ \t]*' "$RUNNER_ETC_DIR/emqx.conf" 2> /dev/null | tail -1 | cut -d = -f 2-)
|
||||||
if [ -z "$PROTO_DIST" ]; then
|
if [ -z "$PROTO_DIST" ]; then
|
||||||
|
|
Loading…
Reference in New Issue