From d5ab079fb1b880b4d8467acc0fe3514ef4fc00d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Wed, 20 Feb 2019 15:08:00 +0100 Subject: rabbitmq-env: Pass remote node name ro child rabbitmqctl(8) We use rabbitmqctl(8) inside `rabbitmq-env` to query the settings of the remote nodes (path to plugins, feature flags file, the database, etc). However, before this patch, we didn't pass the name of the remote node as specified by the user with `-n`. Therefore, the default node name was used (`rabbit@$hostname`) and that node may not exist at all. This caused the executed script to run with possibly incorrect settings. In particular, this prevented rabbitmq-plugins(8) from working properly on a node started with `gmake run-broker`. This should now be fixed because we extract the remote node name from the command line arguments and pass it to the child rabbitmqctl(8). (cherry picked from commit d32660c5fc2abc6250ff9df2393eef2d407e7351) --- scripts/rabbitmq-env | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/rabbitmq-env b/scripts/rabbitmq-env index 8cc3af56ae..3890a3a316 100755 --- a/scripts/rabbitmq-env +++ b/scripts/rabbitmq-env @@ -263,7 +263,22 @@ if [ "${RABBITMQ_DEV_ENV}" ]; then "$RABBITMQ_ENABLED_PLUGINS_FILE_source" != 'environment' \) ]; then # We need to query the running node for the plugins directory # and the "enabled plugins" file. - eval $( (${RABBITMQ_SCRIPTS_DIR}/rabbitmqctl eval \ + for arg in "$@"; do + case "$arg" in + -n) + next_is_node=1 + ;; + *) + if test "$next_is_node"; then + # If the executed script is being passed a remote node + # name, use it here to query the remote node. + node_arg="-n $arg" + break + fi + ;; + esac + done + eval $( (${RABBITMQ_SCRIPTS_DIR}/rabbitmqctl $node_arg eval \ '{ok, P} = application:get_env(rabbit, plugins_dir), {ok, E} = application:get_env(rabbit, enabled_plugins_file), io:format( -- cgit v1.2.1