Browse Source

Merge pull request #1073 from ferd/shell-cookies

Support --setcookie option
pull/1070/head
Tristan Sloughter 9 years ago
parent
commit
cb0263667c
1 changed files with 14 additions and 2 deletions
  1. +14
    -2
      src/rebar_prv_shell.erl

+ 14
- 2
src/rebar_prv_shell.erl View File

@ -64,6 +64,8 @@ init(State) ->
"Gives a long name to the node."}, "Gives a long name to the node."},
{sname, undefined, "sname", atom, {sname, undefined, "sname", atom,
"Gives a short name to the node."}, "Gives a short name to the node."},
{setcookie, undefined, "setcookie", atom,
"Sets the cookie if the node is distributed."},
{script_file, undefined, "script", string, {script_file, undefined, "script", string,
"Path to an escript file to run before " "Path to an escript file to run before "
"starting the project apps. Defaults to " "starting the project apps. Defaults to "
@ -258,9 +260,11 @@ setup_name(State) ->
{undefined, undefined} -> {undefined, undefined} ->
ok; ok;
{Name, undefined} -> {Name, undefined} ->
check_epmd(net_kernel:start([Name, longnames]));
check_epmd(net_kernel:start([Name, longnames])),
setup_cookie(Opts);
{undefined, SName} -> {undefined, SName} ->
check_epmd(net_kernel:start([SName, shortnames]));
check_epmd(net_kernel:start([SName, shortnames])),
setup_cookie(Opts);
{_, _} -> {_, _} ->
?ABORT("Cannot have both short and long node names defined", []) ?ABORT("Cannot have both short and long node names defined", [])
end. end.
@ -271,6 +275,14 @@ check_epmd({error,{{shutdown, {_,net_kernel,{'EXIT',nodistribution}}},_}}) ->
check_epmd(_) -> check_epmd(_) ->
ok. ok.
setup_cookie(Opts) ->
case {node(), proplists:get_value(setcookie, Opts, nocookie)} of
{'nonode@nohost', _} -> nocookie;
{_, nocookie} -> nocookie;
{Node, Name} -> erlang:set_cookie(Node, Name)
end.
find_apps_to_boot(State) -> find_apps_to_boot(State) ->
%% Try the shell_apps option %% Try the shell_apps option
case first_value([fun find_apps_option/1, case first_value([fun find_apps_option/1,

Loading…
Cancel
Save