diff options
author | konyaris <[email protected]> | 2018-03-22 12:47:33 +0100 |
---|---|---|
committer | konyaris <[email protected]> | 2018-03-22 12:47:33 +0100 |
commit | 8f565ebe647370d413da07dc366ee10565358959 (patch) | |
tree | ceebe6827e674e6a4234f2c63b1a5f1210bb6d8f | |
parent | 86d415f33c500d432d6c9fa2fcbff3bb2fff3e8f (diff) | |
download | relx-8f565ebe647370d413da07dc366ee10565358959.tar.gz relx-8f565ebe647370d413da07dc366ee10565358959.tar.bz2 relx-8f565ebe647370d413da07dc366ee10565358959.zip |
Extend adding extra args from vm.args to install_upgrade.escript
-rwxr-xr-x | priv/templates/extended_bin | 8 | ||||
-rw-r--r-- | test/rlx_extended_bin_SUITE.erl | 43 |
2 files changed, 49 insertions, 2 deletions
diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index 1e8aa63..daa071b 100755 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -233,7 +233,9 @@ replace_os_vars() { escript_emulator_args() { if [ -n "${VM_ARGS}" ]; then if grep -q '%%!' $1; then - cmd=$(echo sed -i"' '" "'s|%%!.*|%%! ${VM_ARGS}|'" $1) + cmd=$(echo sed -i"' '" "'/%%!.*/ s| ${VM_ARGS}||'" $1) + eval "$cmd" + cmd=$(echo sed -i"' '" "'/%%!.*/ s|$| ${VM_ARGS}|'" $1) eval "$cmd" else cmd=$(echo sed -i"' '" "'/#!.*/ a \\ @@ -579,6 +581,8 @@ case "$1" in relx_run_hooks "$PRE_INSTALL_UPGRADE_HOOKS" + escript_emulator_args $ROOTDIR/bin/install_upgrade.escript + exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \ "$COMMAND" "{'$REL_NAME', \"$NAME_TYPE\", '$NAME', '$COOKIE'}" "$@" @@ -593,6 +597,8 @@ case "$1" in fi COMMAND="$1"; shift + + escript_emulator_args $ROOTDIR/bin/install_upgrade.escript exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \ "versions" "{'$REL_NAME', \"$NAME_TYPE\", '$NAME', '$COOKIE'}" "$@" diff --git a/test/rlx_extended_bin_SUITE.erl b/test/rlx_extended_bin_SUITE.erl index 1177ede..38ac48c 100644 --- a/test/rlx_extended_bin_SUITE.erl +++ b/test/rlx_extended_bin_SUITE.erl @@ -25,6 +25,7 @@ start_sname_in_other_argsfile/1, start_preserves_arguments/1, start_nodetool_with_data_from_argsfile/1, + start_upgrade_escript_with_argsfile_data/1, start_fail_when_no_name/1, start_fail_when_multiple_names/1, start_fail_when_missing_argsfile/1, @@ -80,7 +81,7 @@ init_per_testcase(_, Config) -> all() -> [start_sname_in_other_argsfile, start_preserves_arguments, start_nodetool_with_data_from_argsfile, - start_fail_when_no_name, start_fail_when_multiple_names, + start_upgrade_escript_with_argsfile_data, start_fail_when_no_name, start_fail_when_multiple_names, start_fail_when_missing_argsfile, start_fail_when_nonreadable_argsfile, start_fail_when_relative_argsfile, start_fail_when_circular_argsfiles, ping, shortname_ping, longname_ping, attach, pid, restart, reboot, escript, @@ -1530,6 +1531,46 @@ start_nodetool_with_data_from_argsfile(Config) -> %% a ping should fail after stopping a node {error, 1, _} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])). +start_upgrade_escript_with_argsfile_data(Config) -> + LibDir1 = proplists:get_value(lib1, Config), + + rlx_test_utils:create_app(LibDir1, "goal_app", "0.0.1", [stdlib,kernel], []), + + ConfigFile = filename:join([LibDir1, "relx.config"]), + VmArgs = filename:join([LibDir1, "vm.args"]), + + rlx_test_utils:write_config(ConfigFile, + [{release, {foo, "0.0.1"}, + [goal_app, sasl]}, + {lib_dirs, [filename:join(LibDir1, "*")]}, + {vm_args, VmArgs}, + {generate_start_script, true}, + {extended_start_script, true} + ]), + + ec_file:write(VmArgs, "-setcookie cookie\n" + "-sname foo\n\n" + "-proto_dist inet_tcp\n\n"), + + OutputDir = filename:join([proplists:get_value(priv_dir, Config), + rlx_test_utils:create_random_name("relx-output")]), + + {ok, _State} = relx:do([{relname, foo}, + {relvsn, "0.0.1"}, + {goals, []}, + {lib_dirs, [LibDir1]}, + {log_level, 3}, + {output_dir, OutputDir}, + {config, ConfigFile}], ["release"]), + + %% now start/stop the release to make sure the extended script is working + {ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])), + timer:sleep(2000), + {ok, _Ver} = sh(filename:join([OutputDir, "foo", "bin", "foo versions"])), + {ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo stop"])), + %% a ping should fail after stopping a node + {error, 1, _} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])). + start_fail_when_no_name(Config) -> LibDir1 = proplists:get_value(lib1, Config), VmArgs = filename:join([LibDir1, "vm.args"]), |