]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/console/console.c
First cut of bat rerun a Job from Jobs Run
[bacula/bacula] / bacula / src / console / console.c
index c92f9e5b8d56036e53c90dc64acc0543eb33d63e..04e51abf81eed58a65228689977ad227b3cf12fe 100644 (file)
@@ -6,7 +6,7 @@
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -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 <dir>    select a Director\n"
+"       -l          list Directors defined\n"
 "       -c <file>   set configuration file to file\n"
 "       -d <nn>     set debug level to <nn>\n"
 "       -dt         print timestamp in debug output\n"
@@ -323,7 +324,7 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock)
       if (is_bnet_stop(UA_sock)) {
          break;                       /* error or term */
       } else if (stat == BNET_SIGNAL) {
-         if (UA_sock->msglen == BNET_PROMPT) {
+         if (UA_sock->msglen == BNET_SUB_PROMPT) {
             at_prompt = true;
          }
          Dmsg1(100, "Got poll %s\n", bnet_sig_to_ascii(UA_sock));
@@ -873,6 +874,7 @@ static int console_init_history(const char *histfile)
    rl_completion_entry_function = dummy_completion_function;
    rl_attempted_completion_function = readline_completion;
    rl_filename_completion_desired = 0;
+   stifle_history(100);
 #endif
 
    return ret;
@@ -904,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)) {
@@ -913,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 */
@@ -990,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;
@@ -1006,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) {
@@ -1015,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);
@@ -1099,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);
@@ -1111,7 +1132,7 @@ int main(int argc, char *argv[])
    start_watchdog();                        /* Start socket watchdog */
 
    if(!select_director(director, &dir, &cons)) {
-      return 0;
+      return 1;
    }
 
    senditf(_("Connecting to Director %s:%d\n"), dir->address,dir->DIRport);