aboutsummaryrefslogtreecommitdiffstats
path: root/priv/templates/install_upgrade_escript
diff options
context:
space:
mode:
authorpaul <[email protected]>2015-11-06 22:55:09 +0800
committerpaul <[email protected]>2015-11-06 22:55:09 +0800
commitcf3172953540beed80f24acd64bf91c86e4a3430 (patch)
tree5fb580c90adb22daae7de6ade086359735730835 /priv/templates/install_upgrade_escript
parent9ec6e72acc6d22d227b18dd7cb9cdbe97435791f (diff)
downloadrelx-cf3172953540beed80f24acd64bf91c86e4a3430.tar.gz
relx-cf3172953540beed80f24acd64bf91c86e4a3430.tar.bz2
relx-cf3172953540beed80f24acd64bf91c86e4a3430.zip
fix upgrade/install/unpack command bug
bug description: if vm.arg use '-sname xxx' option, When exec upgrade/install/unpack command, it will report "Hostname yyy is illegal" error.
Diffstat (limited to 'priv/templates/install_upgrade_escript')
-rw-r--r--priv/templates/install_upgrade_escript21
1 files changed, 15 insertions, 6 deletions
diff --git a/priv/templates/install_upgrade_escript b/priv/templates/install_upgrade_escript
index 3fb9d04..4abce85 100644
--- a/priv/templates/install_upgrade_escript
+++ b/priv/templates/install_upgrade_escript
@@ -7,8 +7,8 @@
-define(INFO(Fmt,Args), io:format(Fmt,Args)).
%% Unpack or upgrade to a new tar.gz release
-main(["unpack", RelName, NodeName, Cookie, VersionArg]) ->
- TargetNode = start_distribution(NodeName, Cookie),
+main(["unpack", RelName, NameTypeArg, NodeName, Cookie, VersionArg]) ->
+ TargetNode = start_distribution(NodeName, NameTypeArg, Cookie),
WhichReleases = which_releases(TargetNode),
Version = parse_version(VersionArg),
case proplists:get_value(Version, WhichReleases) of
@@ -35,8 +35,8 @@ main(["unpack", RelName, NodeName, Cookie, VersionArg]) ->
permanent ->
?INFO("Release ~s is already installed, and set permanent.~n",[Version])
end;
-main(["install", RelName, NodeName, Cookie, VersionArg]) ->
- TargetNode = start_distribution(NodeName, Cookie),
+main(["install", RelName, NameTypeArg, NodeName, Cookie, VersionArg]) ->
+ TargetNode = start_distribution(NodeName, NameTypeArg, Cookie),
WhichReleases = which_releases(TargetNode),
Version = parse_version(VersionArg),
case proplists:get_value(Version, WhichReleases) of
@@ -112,9 +112,9 @@ print_existing_versions(TargetNode) ->
|| {V,S} <- which_releases(TargetNode) ]),
?INFO("Installed versions:~n~s", [VerList]).
-start_distribution(NodeName, Cookie) ->
+start_distribution(NodeName, NameTypeArg, Cookie) ->
MyNode = make_script_node(NodeName),
- {ok, _Pid} = net_kernel:start([MyNode, longnames]),
+ {ok, _Pid} = net_kernel:start([MyNode, get_name_type(NameTypeArg)]),
erlang:set_cookie(node(), list_to_atom(Cookie)),
TargetNode = list_to_atom(NodeName),
case {net_kernel:connect_node(TargetNode),
@@ -132,3 +132,12 @@ start_distribution(NodeName, Cookie) ->
make_script_node(Node) ->
[Name, Host] = string:tokens(Node, "@"),
list_to_atom(lists:concat([Name, "_upgrader_", os:getpid(), "@", Host])).
+
+%% get name type from arg
+get_name_type(NameTypeArg) ->
+ case NameTypeArg of
+ "-sname" ->
+ shortnames;
+ _ ->
+ longnames
+ end.