From 4ee0dbdea44e19b9a0c4e07264f74dda4750e2e2 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Wed, 24 Mar 2021 11:55:58 +0100 Subject: [PATCH] fix(scripts): Finds node name and cookie from vm.args For node name and cookie overriden from environment variable the only way to find it from another shell is to inspect the vm.args file. For node boot commands, the vm.args file may not have been created yet, so we need to inspect node name in emqx.conf --- bin/emqx | 61 ++++++++++++++++++++++++++++++++++++++-------------- bin/emqx_ctl | 28 +++++++++++------------- 2 files changed, 57 insertions(+), 32 deletions(-) diff --git a/bin/emqx b/bin/emqx index 167cd5cf1..69994389b 100755 --- a/bin/emqx +++ b/bin/emqx @@ -260,15 +260,43 @@ if [ -z "$RELX_CONFIG_PATH" ]; then fi fi +IS_BOOT_COMMAND='no' +case "$1" in + start|start_boot) + IS_BOOT_COMMAND='yes' + ;; + console|console_clean|console_boot) + IS_BOOT_COMMAND='yes' + ;; + foreground) + IS_BOOT_COMMAND='yes' + ;; +esac + + if [ -z "$NAME_ARG" ]; then NODENAME="${EMQX_NODE_NAME:-}" # compatible with docker entrypoint [ -z "$NODENAME" ] && [ -n "$EMQX_NAME" ] && [ -n "$EMQX_HOST" ] && NODENAME="${EMQX_NAME}@${EMQX_HOST}" - [ -z "$NODENAME" ] && NODENAME=$(grep -E '^[ \t]*node.name[ \t]*=[ \t]*' "$RUNNER_ETC_DIR/emqx.conf" 2> /dev/null | tail -1 | cut -d = -f 2-) + if [ -z "$NODENAME" ] && [ "$IS_BOOT_COMMAND" = 'no' ]; then + # for non-boot commands, inspect vm.