From: Eric Bollengier Date: Wed, 24 Feb 2010 16:32:15 +0000 (+0100) Subject: Add bconsole -l and tweak behavior of -D X-Git-Tag: Release-5.2.1~1680 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7fae7e3567d3cedc259e030f972d2e7ed0cadaef;p=bacula%2Fbacula Add bconsole -l and tweak behavior of -D --- diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index 10b9ebcae9..761c21a561 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -127,6 +127,7 @@ PROG_COPYRIGHT "\nVersion: " VERSION " (" BDATE ") %s %s %s\n\n" "Usage: bconsole [-s] [-c config_file] [-d debug_level]\n" " -D select a Director\n" +" -l list Directors defined\n" " -c set configuration file to file\n" " -d set debug level to \n" " -dt print timestamp in debug output\n" @@ -905,8 +906,9 @@ bool select_director(const char *director, DIRRES **ret_dir, CONRES **ret_cons) if (numdir == 1) { /* No choose */ dir = (DIRRES *)GetNextRes(R_DIRECTOR, NULL); - - } else if (director) { /* Command line choice */ + } + + if (director) { /* Command line choice overwrite the no choose option */ LockRes(); foreach_res(dir, R_DIRECTOR) { if (bstrcmp(dir->hdr.name, director)) { @@ -914,6 +916,10 @@ bool select_director(const char *director, DIRRES **ret_dir, CONRES **ret_cons) } } UnlockRes(); + if (!dir) { /* Can't find Director used as argument */ + senditf(_("Can't find %s in Director list\n"), director); + return 0; + } } if (!dir) { /* prompt for director */ @@ -991,6 +997,7 @@ int main(int argc, char *argv[]) { int ch; char *director=NULL; + bool list_directors=false; bool no_signals = false; bool test_config = false; JCR jcr; @@ -1007,7 +1014,7 @@ int main(int argc, char *argv[]) working_directory = "/tmp"; args = get_pool_memory(PM_FNAME); - while ((ch = getopt(argc, argv, "bc:d:nstu:D:?")) != -1) { + while ((ch = getopt(argc, argv, "D:lbc:d:nstu:?")) != -1) { switch (ch) { case 'D': /* Director */ if (director) { @@ -1016,6 +1023,11 @@ int main(int argc, char *argv[]) director = bstrdup(optarg); break; + case 'l': + list_directors = true; + test_config = true; + break; + case 'c': /* configuration file */ if (configfile != NULL) { free(configfile); @@ -1100,6 +1112,14 @@ int main(int argc, char *argv[]) con_init(stdin); } + if (list_directors) { + LockRes(); + foreach_res(dir, R_DIRECTOR) { + senditf("%s\n", dir->hdr.name); + } + UnlockRes(); + } + if (test_config) { terminate_console(0); exit(0);