From cb0352cd4f4748ee6e33bc64d2e2b09d09fe20eb Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Tue, 7 Sep 2010 04:03:31 +0000 Subject: cli: add script mode for gluster Signed-off-by: Pranith Kumar K Signed-off-by: Vijay Bellur BUG: 1554 (add script mode for gluster) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1554 --- cli/src/input.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'cli/src/input.c') diff --git a/cli/src/input.c b/cli/src/input.c index e762fbd13..2c67b354d 100644 --- a/cli/src/input.c +++ b/cli/src/input.c @@ -41,7 +41,11 @@ cli_batch (void *d) state = d; - ret = cli_cmd_process (state, state->argc, state->argv); + if (state->mode == GLUSTER_MODE_SCRIPT) + ret = cli_cmd_process (state, state->argc - 2, state->argv + 2); + else + ret = cli_cmd_process (state, state->argc, state->argv); + gf_log ("", GF_LOG_NORMAL, "Exiting with: %d", ret); exit (ret); @@ -82,8 +86,22 @@ int cli_input_init (struct cli_state *state) { int ret = 0; + gf_boolean_t is_batch = _gf_false; + + if (1 < state->argc) { + if (!strcmp ("mode", state->argv[0]) && + !strcmp ("script", state->argv[1])) { + state->mode = GLUSTER_MODE_SCRIPT; + if (2 < state->argc) + is_batch = _gf_true; + } else { + is_batch = _gf_true; + } + } else if (1 == state->argc) { + is_batch = _gf_true; + } - if (state->argc) { + if (is_batch) { ret = pthread_create (&state->input, NULL, cli_batch, state); return ret; } -- cgit