diff --git a/rel/files/riak-admin b/rel/files/riak-admin index 7a4188f9d..8ee36727b 100755 --- a/rel/files/riak-admin +++ b/rel/files/riak-admin @@ -16,10 +16,23 @@ ERTS_PATH=$BINDIR NAME_PARAM="-name" BOOT_FILE="start_clean" +run_rpc() { + MOD=$1; FUN=$2; shift 2 + if [ $# -eq 0 ]; then + # Pass through a list with an empty list - nodetool now demands that args + # are passed in a list, and the CLI functions in riak expect a list (empty) + # if no args are required. Thus, we pass a list of an empty list. + USE_NODETOOL=1 relx_nodetool rpc riak_kv_console run_command [$MOD, $FUN, [[]]] + else + # Form the remaining args into a comma delimited list of quoted args. + ARGS=$(awk '{$1=$1; gsub(/^/,"[\""); gsub(/$/,"\"]")}'1 OFS='","' <<< $@) + USE_NODETOOL=1 relx_nodetool rpc riak_kv_console run_command [$MOD, $FUN, [$ARGS]] + fi +} + usage() { - echo "Usage: $SCRIPT { cluster | join | leave | backup | restore | test | " - echo " reip | js-reload | erl-reload | wait-for-service | " - echo " ringready | transfers | force-remove | down |" + echo "Usage: $SCRIPT { cluster | backup | restore | test | down | transfers |" + echo " reip | js-reload | erl-reload | wait-for-service | ringready |" echo " cluster-info | member-status | ring-status | vnode-status |" echo " aae-status | diag | stat | status | transfer-limit | reformat-indexes |" echo " top [-interval N] [-sort reductions|memory|msg_q] [-lines N] |" @@ -33,23 +46,23 @@ stat_admin() case "$1" in show) shift - relx_nodetool rpc riak_core_console stat_show "$*" + run_rpc riak_core_console stat_show "$*" ;; info) shift - relx_nodetool rpc riak_core_console stat_info "$*" + run_rpc riak_core_console stat_info "$*" ;; enable) shift - relx_nodetool rpc riak_core_console stat_enable "$*" + run_rpc riak_core_console stat_enable "$*" ;; disable) shift - relx_nodetool rpc riak_core_console stat_disable "$*" + run_rpc riak_core_console stat_disable "$*" ;; reset) shift - relx_nodetool rpc riak_core_console stat_reset "$*" + run_rpc riak_core_console stat_reset "$*" ;; help) shift @@ -235,13 +248,13 @@ cluster_admin() echo "Usage: $SCRIPT cluster join " exit 1 fi - relx_nodetool rpc riak_kv_console staged_join "$2" + run_rpc riak_kv_console staged_join "$2" ;; leave) if [ $# -eq 1 ]; then - relx_nodetool rpc riak_core_console stage_leave + run_rpc riak_core_console stage_leave elif [ $# -eq 2 ]; then - relx_nodetool rpc riak_core_console stage_leave "$2" + run_rpc riak_core_console stage_leave "$2" else echo "Usage: $SCRIPT cluster leave []" exit 1 @@ -252,21 +265,21 @@ cluster_admin() echo "Usage: $SCRIPT cluster force-remove " exit 1 fi - relx_nodetool rpc riak_core_console stage_remove "$2" + run_rpc riak_core_console stage_remove "$2" ;; replace) if [ $# -ne 3 ]; then echo "Usage: $SCRIPT cluster replace " exit 1 fi - relx_nodetool rpc riak_core_console stage_replace "$2" "$3" + run_rpc riak_core_console stage_replace "$2" "$3" ;; force-replace) if [ $# -ne 3 ]; then echo "Usage: $SCRIPT cluster force-replace " exit 1 fi - relx_nodetool rpc riak_core_console stage_force_replace "$2" "$3" + run_rpc riak_core_console stage_force_replace "$2" "$3" ;; resize-ring) if [ $# -ne 2 ]; then @@ -274,30 +287,30 @@ cluster_admin() echo " $SCRIPT cluster resize-ring abort" exit 1 fi - relx_nodetool rpc riak_core_console stage_resize_ring "$2" + run_rpc riak_core_console stage_resize_ring "$2" ;; plan) - relx_nodetool rpc riak_core_console print_staged + run_rpc riak_core_console print_staged ;; commit) - relx_nodetool rpc riak_core_console commit_staged + run_rpc riak_core_console commit_staged ;; clear) - relx_nodetool rpc riak_core_console clear_staged + run_rpc riak_core_console clear_staged ;; status) - relx_nodetool rpc riak_core_console command $SCRIPT cluster $@ + run_rpc riak_core_console command $SCRIPT cluster $@ ;; partitions|partition) - relx_nodetool rpc riak_core_console command $SCRIPT cluster $@ + run_rpc riak_core_console command $SCRIPT cluster $@ ;; partition[_-]count) shift - relx_nodetool rpc riak_core_console command $SCRIPT cluster partition-count $@ + run_rpc riak_core_console command $SCRIPT cluster partition-count $@ ;; location) shift - relx_nodetool rpc riak_core_console command $SCRIPT cluster location $@ + run_rpc riak_core_console command $SCRIPT cluster location $@ ;; *) echo "\ @@ -360,9 +373,9 @@ security_admin() echo "Usage: $SCRIPT security add-user [