diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2016-02-21 14:29:51 -0500 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2016-02-21 14:29:51 -0500 |
commit | e95e935eafee19cff65fc87af3f5ec9dce322a7b (patch) | |
tree | 1b9bf062292ce3e342564f37379d9b71d7166c0b /src | |
parent | ada08b88d7ce1112633ebc397719e9f35d0de2a9 (diff) |
Support --setcookie option
Replicates `erl` behaviour.
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_prv_shell.erl | 16 |
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, |