anchor.diff:              _ -> ok
           end,
   
  -        "0" = os:cmd("riak-admin cluster join " ++ ?DB_NAME ++ "@" ++ ClusterHost
  -            ++ " 1>/dev/null 2>&1 ; echo -n $?"),
  -        ok = wait_until("riak-admin ring_status", "Ring Ready:\s*true"),
  +        JoinCommand = "/opt/couchbase/couchbase-cli rebalance -c " ++ ClusterHost ++ ":8091 -u admin -p " ++ ?COUCHBASE_PASSWORD ++
  +            " --server-add=" ++ Host ++ ":8091 --server-add-username=admin --server-add-password=" ++ ?COUCHBASE_PASSWORD
  +            ++ " 1>/dev/null 2>&1 ; echo -n $?",
  +        ?info("Running couchbase command ~p", [JoinCommand]),
  +        "0" = os:cmd(JoinCommand),
   
           {ok, Host}
       catch
  
positive.code: %% ====================================================================
  local_commit() ->
      try
          ok = wait_until("riak-admin ring_status", "Ring Ready:\s*true"),
          "0" = os:cmd("riak-admin cluster plan 1>/dev/null 2>&1 ; echo -n $?"),
          "0" = os:cmd("riak-admin cluster commit 1>/dev/null 2>&1 ; echo -n $?"),
          CreateMaps = "riak-admin bucket-type create maps '{\"props\":{\"n_val\":2,"
          " \"datatype\":\"map\"}}'",
          case os:cmd(CreateMaps ++ " | grep already_active") of
              "already_active\n" ->
                  ok;
              _ ->
                  "0" = os:cmd(CreateMaps ++ " 1>/dev/null 2>&1 ; echo -n $?"),
                  ok = wait_until("riak-admin bucket-type status maps", "maps has been created and may be activated"),
                  "0" = os:cmd("riak-admin bucket-type activate maps 1>/dev/null 2>&1 ; echo -n $?")
          end,
  
          ok
      catch
          _:Reason ->
  
negative.code: -include("onepanel_modules/installer/internals.hrl").
  -include_lib("ctool/include/logging.hrl").
  
  -define(COUCHBASE_PASSWORD, "lkj4n2klfsd90uchn1kadk290").
  
  %% install_behaviour callbacks
  -export([install/1, uninstall/1, start/1, stop/1, restart/1, commit/1]).
  
  %% API
  -export([local_start/0, local_stop/0, join_cluster/1, local_commit/0, init_cluster/1]).
  
  %% Defines how many times onepanel will try to verify database node start
  -define(FINALIZE_START_ATTEMPTS, 10).
  