diff options
author | Tristan Sloughter <[email protected]> | 2016-11-26 11:09:08 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2016-11-26 11:09:08 -0800 |
commit | 7df9a08daa96a686f783414b7fc845bb345d0c46 (patch) | |
tree | 20313426aa103cf25b29961fb4526fbf71367021 /priv/templates | |
parent | 1014374d82f783c9da82eecf424c34bceb9fc293 (diff) | |
parent | 5b59fab481d2d4c72b391ea24bb1db8363ce25df (diff) | |
download | relx-7df9a08daa96a686f783414b7fc845bb345d0c46.tar.gz relx-7df9a08daa96a686f783414b7fc845bb345d0c46.tar.bz2 relx-7df9a08daa96a686f783414b7fc845bb345d0c46.zip |
Merge pull request #536 from lrascao/fix/downgrade_non_permanent_version
Allow upgrade/downgrade from non-permanent versions
Diffstat (limited to 'priv/templates')
-rw-r--r-- | priv/templates/install_upgrade_escript | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/priv/templates/install_upgrade_escript b/priv/templates/install_upgrade_escript index dc09f9c..c2aa06c 100644 --- a/priv/templates/install_upgrade_escript +++ b/priv/templates/install_upgrade_escript @@ -79,7 +79,18 @@ install({RelName, NameTypeArg, NodeName, Cookie}, Opts) -> [Version]) end; permanent -> - ?INFO("Release ~s is already installed and set permanent.~n",[Version]); + %% this release is marked permanent, however it might not the + %% one currently running + case current_release_version(TargetNode) of + Version -> + ?INFO("Release ~s is already installed, running and set permanent.~n", + [Version]); + CurrentVersion -> + ?INFO("Release ~s is the currently running version.~n", + [CurrentVersion]), + check_and_install(TargetNode, Version), + maybe_permafy(TargetNode, RelName, Version, Opts) + end; {error, Reason} -> ?INFO("Unpack failed: ~p~n",[Reason]), print_existing_versions(TargetNode), @@ -277,6 +288,16 @@ which_releases(TargetNode) -> R = rpc:call(TargetNode, release_handler, which_releases, [], ?TIMEOUT), [ {V, S} || {_,V,_, S} <- R ]. +%% the running release version is either the only one marked `current´ +%% or, if none exists, the one marked `permanent` +current_release_version(TargetNode) -> + R = rpc:call(TargetNode, release_handler, which_releases, + [], ?TIMEOUT), + Versions = [ {S, V} || {_,V,_, S} <- R ], + %% current version takes priority over the permanent + proplists:get_value(current, Versions, + proplists:get_value(permanent, Versions)). + print_existing_versions(TargetNode) -> VerList = iolist_to_binary([ io_lib:format("* ~s\t~s~n",[V,S]) |