aboutsummaryrefslogtreecommitdiffstats
path: root/priv/templates
diff options
context:
space:
mode:
Diffstat (limited to 'priv/templates')
-rw-r--r--priv/templates/install_upgrade_escript23
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])