aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLuis Rascao <[email protected]>2016-10-23 23:47:39 +0100
committerLuis Rascao <[email protected]>2016-10-27 18:57:39 +0100
commitf0e0d1acc7e4b645e9dac38e8323bbc1cb8fb03c (patch)
tree9c418e34ca331ca3ab63eaa723e7406ba77a5515 /src
parent42dcb2a4c2ca74eec5c756767d53317ad8e0c227 (diff)
downloadrelx-f0e0d1acc7e4b645e9dac38e8323bbc1cb8fb03c.tar.gz
relx-f0e0d1acc7e4b645e9dac38e8323bbc1cb8fb03c.tar.bz2
relx-f0e0d1acc7e4b645e9dac38e8323bbc1cb8fb03c.zip
Fix replace os vars functionality
The first run would correctly replace the environment variables, however it would also overwrite the original vm.args and sys.config thus preventing any further substitution in subsequent runs. Dev mode runs were also broken, all runs after the first were required to also define the RELX_REPLACE_OS_VARS variable in order not to overwrite the current vm.args with the original one, this prevented simply attaching to an already running node that was started this way. Add tests to exercise this functionality.
Diffstat (limited to 'src')
-rw-r--r--src/rlx_prv_assembler.erl2
-rw-r--r--src/rlx_prv_overlay.erl8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl
index 0eac379..7ff1d61 100644
--- a/src/rlx_prv_assembler.erl
+++ b/src/rlx_prv_assembler.erl
@@ -453,7 +453,7 @@ copy_or_symlink_config_file(State, ConfigPath, RelConfPath) ->
ensure_not_exist(RelConfPath),
case rlx_state:dev_mode(State) of
true ->
- ok = rlx_util:symlink_or_copy(ConfigPath, RelConfPath ++ ".orig");
+ ok = rlx_util:symlink_or_copy(ConfigPath, RelConfPath);
_ ->
ok = ec_file:copy(ConfigPath, RelConfPath)
end.
diff --git a/src/rlx_prv_overlay.erl b/src/rlx_prv_overlay.erl
index 71aca97..a4c0fa4 100644
--- a/src/rlx_prv_overlay.erl
+++ b/src/rlx_prv_overlay.erl
@@ -461,6 +461,14 @@ write_template(OverlayVars, FromFile, ToFile) ->
{ok, IoData} ->
case filelib:ensure_dir(ToFile) of
ok ->
+ %% we were asked to render a template
+ %% onto a symlink, this would cause an overwrite
+ %% of the original file, so we delete the symlink
+ %% and go ahead with the template render
+ case ec_file:is_symlink(ToFile) of
+ true -> ec_file:remove(ToFile);
+ false -> ok
+ end,
case file:write_file(ToFile, IoData) of
ok ->
{ok, FileInfo} = file:read_file_info(FromFile),