summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2016-02-21 13:57:11 -0600
committerTristan Sloughter <t@crashfast.com>2016-02-21 13:57:11 -0600
commitcb0263667c84ed2b4cf58a16e8de5769a395e394 (patch)
tree1b9bf062292ce3e342564f37379d9b71d7166c0b
parentada08b88d7ce1112633ebc397719e9f35d0de2a9 (diff)
parente95e935eafee19cff65fc87af3f5ec9dce322a7b (diff)
Merge pull request #1073 from ferd/shell-cookies
Support --setcookie option
-rw-r--r--src/rebar_prv_shell.erl16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/rebar_prv_shell.erl b/src/rebar_prv_shell.erl
index ea759fc..430d1e8 100644
--- a/src/rebar_prv_shell.erl
+++ b/src/rebar_prv_shell.erl
@@ -64,6 +64,8 @@ init(State) ->
"Gives a long name to the node."},
{sname, undefined, "sname", atom,
"Gives a short name to the node."},
+ {setcookie, undefined, "setcookie", atom,
+ "Sets the cookie if the node is distributed."},
{script_file, undefined, "script", string,
"Path to an escript file to run before "
"starting the project apps. Defaults to "
@@ -258,9 +260,11 @@ setup_name(State) ->
{undefined, undefined} ->
ok;
{Name, undefined} ->
- check_epmd(net_kernel:start([Name, longnames]));
+ check_epmd(net_kernel:start([Name, longnames])),
+ setup_cookie(Opts);
{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", [])
end.
@@ -271,6 +275,14 @@ check_epmd({error,{{shutdown, {_,net_kernel,{'EXIT',nodistribution}}},_}}) ->
check_epmd(_) ->
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) ->
%% Try the shell_apps option
case first_value([fun find_apps_option/1,