From 78b0221a86395da706383b1b57027a9c2379caa8 Mon Sep 17 00:00:00 2001 From: Kelly McLaughlin Date: Mon, 21 Jul 2014 16:41:48 -0600 Subject: [PATCH 1/8] Change nodetool to permit zero parameter rpc calls Change nodetool so that functions of zero arity may be called using the supplied rpc facility. This is done by making a distinction between the case when rpc parameters are present and when they are not. Previously calling zero arity functions has not been possible because even submitting no rpc parameters is treated the same as submitting the request with a single parameter of an empty list. Nodetool encapsulates any parameters as a list and the result of attempting to call a function that takes no parameters was the rpc function calling the supplied function with a single parameter of an empty list. This change does not preclude calling functions with a single parameter of an empty list. It just now makes that decision explicit on the part of the caller. --- priv/base/nodetool | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/priv/base/nodetool b/priv/base/nodetool index 23503d7..df964e1 100755 --- a/priv/base/nodetool +++ b/priv/base/nodetool @@ -63,6 +63,17 @@ main(Args) -> io:format("~p\n", [rpc:call(TargetNode, init, restart, [], RpcTimeout)]); ["reboot"] -> io:format("~p\n", [rpc:call(TargetNode, init, reboot, [], RpcTimeout)]); + ["rpc", Module, Function] -> + case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function), + [], RpcTimeout) of + ok -> + ok; + {badrpc, Reason} -> + io:format(standard_error, "RPC to ~p failed: ~p\n", [TargetNode, Reason]), + halt(1); + _ -> + halt(1) + end; ["rpc", Module, Function | RpcArgs] -> case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function), [RpcArgs], RpcTimeout) of @@ -74,6 +85,16 @@ main(Args) -> _ -> halt(1) end; + ["rpc_infinity", Module, Function] -> + case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function), [], infinity) of + ok -> + ok; + {badrpc, Reason} -> + io:format(standard_error, "RPC to ~p failed: ~p\n", [TargetNode, Reason]), + halt(1); + _ -> + halt(1) + end; ["rpc_infinity", Module, Function | RpcArgs] -> case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function), [RpcArgs], infinity) of ok -> @@ -167,13 +188,13 @@ chkconfig(File) -> io:format("ok\n"), halt(0); {error, {Line, Mod, Term}} -> - io:format(standard_error, - ["Error on line ", + io:format(standard_error, + ["Error on line ", file:format_error({Line, Mod, Term}), "\n"], []), halt(1); {error, R} -> io:format(standard_error, - ["Error reading config file: ", + ["Error reading config file: ", file:format_error(R), "\n"], []), halt(1) end. From 5b4023aaecd0d2676dff5c267ae322fc0f6c02e3 Mon Sep 17 00:00:00 2001 From: Kelly McLaughlin Date: Mon, 28 Jul 2014 12:05:03 -0600 Subject: [PATCH 2/8] Revert "Merge branch 'feature/nodetool-zero-arg-rpc' into develop" This reverts commit 93db72ef65d714e5e8d849fff558be3940992f2a, reversing changes made to a56fe9b021e3543a24fdfc98f1c16704b41e62c6. --- priv/base/nodetool | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/priv/base/nodetool b/priv/base/nodetool index df964e1..23503d7 100755 --- a/priv/base/nodetool +++ b/priv/base/nodetool @@ -63,17 +63,6 @@ main(Args) -> io:format("~p\n", [rpc:call(TargetNode, init, restart, [], RpcTimeout)]); ["reboot"] -> io:format("~p\n", [rpc:call(TargetNode, init, reboot, [], RpcTimeout)]); - ["rpc", Module, Function] -> - case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function), - [], RpcTimeout) of - ok -> - ok; - {badrpc, Reason} -> - io:format(standard_error, "RPC to ~p failed: ~p\n", [TargetNode, Reason]), - halt(1); - _ -> - halt(1) - end; ["rpc", Module, Function | RpcArgs] -> case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function), [RpcArgs], RpcTimeout) of @@ -85,16 +74,6 @@ main(Args) -> _ -> halt(1) end; - ["rpc_infinity", Module, Function] -> - case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function), [], infinity) of - ok -> - ok; - {badrpc, Reason} -> - io:format(standard_error, "RPC to ~p failed: ~p\n", [TargetNode, Reason]), - halt(1); - _ -> - halt(1) - end; ["rpc_infinity", Module, Function | RpcArgs] -> case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function), [RpcArgs], infinity) of ok -> @@ -188,13 +167,13 @@ chkconfig(File) -> io:format("ok\n"), halt(0); {error, {Line, Mod, Term}} -> - io:format(standard_error, - ["Error on line ", + io:format(standard_error, + ["Error on line ", file:format_error({Line, Mod, Term}), "\n"], []), halt(1); {error, R} -> io:format(standard_error, - ["Error reading config file: ", + ["Error reading config file: ", file:format_error(R), "\n"], []), halt(1) end. From d2a5de43ae5c931f05265e4ab59ceaf8fd9e4fee Mon Sep 17 00:00:00 2001 From: Jared Morrow Date: Mon, 18 Aug 2014 11:38:38 -0600 Subject: [PATCH 3/8] Fix typo in README for package_patch_dir --- README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.org b/README.org index d6f9ec3..88afaaf 100644 --- a/README.org +++ b/README.org @@ -92,7 +92,7 @@ your application's =vars.config=. **** Optional Variables - =runner_ulimit_warn= - The runner script will warn if `ulimit -n` is less than this value. This defaults to 4096 in all packages. - - =platform_patch_dir= - Directory to include in erlang's load path to allow for + - =package_patch_dir= - Directory to include in erlang's load path to allow for patches to be hotloaded. By default this will be in the =platform_lib_dir= (ex: "basho-patches") - =runner_user= - The username to run the application as From a829631eccebe3c1d7657a0075584f55bf342977 Mon Sep 17 00:00:00 2001 From: Jared Morrow Date: Wed, 20 Aug 2014 13:51:46 -0600 Subject: [PATCH 4/8] Add example app to help with documentation --- README.org | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.org b/README.org index 88afaaf..8816b62 100644 --- a/README.org +++ b/README.org @@ -124,3 +124,15 @@ So, if you want to have a variable persist all the way through to the final reltool step, the variable needs to be set in pkg.vars.config (or defaulted in .template) AND be present in the vars.config, so it can be applied to the reltool templates. + +*** Example App + +The easiest app that uses =node_package= is [[https://github.com/basho/stanchion][stanchion]] a small application that Basho uses along side Riak CS. + +In particular, see: + + - [[https://github.com/basho/stanchion/blob/develop/pkg.vars.config][pkg.vars.config]] + - [[https://github.com/basho/stanchion/blob/develop/Makefile#L73][makefile]] + - [[https://github.com/basho/stanchion/blob/develop/rel/reltool.config#L46][reltool.config]] + +It also has custom settings in its [[https://github.com/basho/stanchion/blob/develop/rel/vars.config#L31][vars.config]] for adjusting settings in the =bin/stanchion= that comes from node_package's =runner= script. From e69f98d0b0d444a8b21a1c54a426c840a6d67fca Mon Sep 17 00:00:00 2001 From: drewkerrigan Date: Sun, 12 Jul 2015 22:13:10 -0400 Subject: [PATCH 5/8] Setting HOME env variable when unset due to downstream failures --- priv/base/env.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/priv/base/env.sh b/priv/base/env.sh index bcaf475..f30947d 100755 --- a/priv/base/env.sh +++ b/priv/base/env.sh @@ -46,6 +46,13 @@ WAIT_FOR_PROCESS={{runner_wait_process}} WHOAMI=`whoami` +# erlexec requires HOME to be set. The username needs to be a +# unquoted literal because of the tilde expansion, hence the +# usage of eval. +if [ -z "$HOME" ]; then + export HOME=`eval echo "~$WHOAMI"` +fi + # Echo to stderr on errors echoerr() { echo "$@" 1>&2; } From 8d556bf0860fc628d273822dcf5fb063b107b3a1 Mon Sep 17 00:00:00 2001 From: drewkerrigan Date: Mon, 13 Jul 2015 17:02:46 -0400 Subject: [PATCH 6/8] Replacing whoami with id -un to be more POSIX.2 compliant --- priv/base/env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/base/env.sh b/priv/base/env.sh index bcaf475..2803b28 100755 --- a/priv/base/env.sh +++ b/priv/base/env.sh @@ -44,7 +44,7 @@ fi # Registered process to wait for to consider start a success WAIT_FOR_PROCESS={{runner_wait_process}} -WHOAMI=`whoami` +WHOAMI=`id -un` # Echo to stderr on errors echoerr() { echo "$@" 1>&2; } From fea5bd25bc65df7def56d40bc49332a16524e104 Mon Sep 17 00:00:00 2001 From: Sargun Dhillon Date: Thu, 6 Aug 2015 16:55:08 -0700 Subject: [PATCH 7/8] Add code to disable EPMd via env variable --- priv/base/nodetool | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/priv/base/nodetool b/priv/base/nodetool index 3239325..51b8f9d 100755 --- a/priv/base/nodetool +++ b/priv/base/nodetool @@ -154,8 +154,13 @@ process_args([Arg | Rest], Acc, Opts) -> start_epmd() -> - [] = os:cmd(epmd_path() ++ " -daemon"), - ok. + case os:getenv("NO_EPMD") of + false -> + [] = os:cmd(epmd_path() ++ " -daemon"), + ok; + _ -> + ok + end. epmd_path() -> ErtsBinDir = filename:dirname(escript:script_name()), From f956b465c570d6b5cba456b0b605fc581d7f579a Mon Sep 17 00:00:00 2001 From: Greg Cymbalski Date: Thu, 3 Dec 2015 12:44:31 -0800 Subject: [PATCH 8/8] fixes #192 on at least linux and osx --- priv/base/env.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/priv/base/env.sh b/priv/base/env.sh index d05bb66..4ec9231 100755 --- a/priv/base/env.sh +++ b/priv/base/env.sh @@ -238,8 +238,8 @@ check_user() { # riak-admin bucket-type create mytype {props: {n_val: 4}} # after the arguments were passed into the new shell during exec su # - # So this regex finds any '"', '{', or '}' and prepends with a '\' - ESCAPED_ARGS=`echo "$@" | sed -e 's/\([{}"]\)/\\\\\1/g'` + # So this regex finds any '(', ')', "'" , '"', '{', or '}' and prepends with a '\' + ESCAPED_ARGS=$(echo "$@" | sed -e "s/\([\\\(\\\){}\"']\)/\\\\\1/g") # This will drop priviledges into the runner user # It exec's in a new shell and the current shell will exit