aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Uhlig <[email protected]>2017-10-05 16:17:09 +0200
committerGitHub <[email protected]>2017-10-05 16:17:09 +0200
commit56b366441d2e5f8046e2fe967987fe03958542f6 (patch)
tree5f4bc5717f8a70b801159a0a6e6b23f5d61ff0e8
parent0715c2fca256e0b9e5e85b03c61a065de6ce81af (diff)
downloadrelx-56b366441d2e5f8046e2fe967987fe03958542f6.tar.gz
relx-56b366441d2e5f8046e2fe967987fe03958542f6.tar.bz2
relx-56b366441d2e5f8046e2fe967987fe03958542f6.zip
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.
-rwxr-xr-xpriv/templates/extended_bin18
1 files 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 line<file)>0) {
+ 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}")