From 56b366441d2e5f8046e2fe967987fe03958542f6 Mon Sep 17 00:00:00 2001 From: Jan Uhlig Date: Thu, 5 Oct 2017 16:17:09 +0200 Subject: vm.args check for name/sname parameter The current version of extended_bin checks if there is a name or sname parameter in vm.args and refuses to start if there is none. However, it is allowed that the vm.args file (more abstract, any -args_file that is given to erl/erlexec etc) itself may contain -args_file parameters (see http://erlang.org/doc/man/erl.html), which may contain the name/sname parameters. This change will recursively scan the files mentioned in -args_file parameters in vm.args as well as -args_file parameters in the mentioned files etcetc, and return the first occurence of a name/sname parameter. Two points are worth mentioning, though: - The name/sname check works only with absolute paths in the args_file parameters. Relative paths are probably a bad idea there, anyway, since it would make any setup rather fragile. - There is no check for circular dependencies. There was none before, and this change does not add any. --- priv/templates/extended_bin | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index 2580dcc..e3b8f1a 100755 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -294,8 +294,22 @@ export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH" ERTS_LIB_DIR="$(dirname "$ERTS_DIR")/lib" VMARGS_PATH=$(add_path vm.args $VMARGS_PATH) -# Extract the target node name from node.args -NAME_ARG=$(egrep '^-s?name' "$VMARGS_PATH" || true) +# Extract the target node name from vm.args or referenced args_files +NAME_ARG=$(awk 'function find_name(file) { + while ((getline line0) { + if (line~/^-args_file\s+/) { + gsub(/^-args_file\s+/, "", line) + find_name(line) + } + else if (line~/^-s?name\s+/) { + print line + exit + } + } +} +{ + find_name(FILENAME) +}' "$VMARGS_PATH") # Perform replacement of variables in ${NAME_ARG} NAME_ARG=$(eval echo "${NAME_ARG}") -- cgit v1.2.3