]> git.sur5r.net Git - bacula/bacula/commitdiff
Merge branch 'master' into readline-bconsole-restore
authorEric Bollengier <eric@eb.homelinux.org>
Mon, 16 Nov 2009 10:00:34 +0000 (11:00 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 16 Nov 2009 10:00:34 +0000 (11:00 +0100)
Conflicts:
bacula/technotes

bacula/src/console/console.c
bacula/src/dird/ua_dotcmds.c
bacula/src/dird/ua_tree.c
bacula/technotes
gui/bweb/lib/Bconsole.pm
gui/bweb/lib/Bweb.pm
gui/bweb/technotes-3.0

index f8cb0cd1c511c018ffba5ada16f51fd93818ef81..304bc04053ce7116d189c761e99b5238b183d0d6 100644 (file)
@@ -604,6 +604,11 @@ static struct cpl_keywords_t cpl_keywords[] = {
    {"volume=",    ".media"         },
    {"oldvolume=", ".media"         },
    {"volstatus=", ".volstatus"     },
+   {"ls",         ".ls"            },
+   {"cd",         ".lsdir"         },
+   {"mark",       ".ls"            },
+   {"m",          ".ls"            },
+   {"unmark",     ".lsmark"        },
    {"actiononpurge=", ".actiononpurge" }
 };
 #define key_size ((int)(sizeof(cpl_keywords)/sizeof(struct cpl_keywords_t)))
index 0e37efc6d11e39bd7d2b15e9295cd02fbccc60ff..62c8cf500e41d7a984abc3c9f60ff86a4d716c08 100644 (file)
@@ -510,13 +510,24 @@ static bool diecmd(UAContext *ua, const char *cmd)
 
 #endif
 
+/* 
+ * Can use an argument to filter on JobType
+ * .jobs [type=B]
+ */
 static bool jobscmd(UAContext *ua, const char *cmd)
 {
    JOB *job;
+   uint32_t type = 0;
+   int pos;
+   if ((pos = find_arg_with_value(ua, "type")) >= 0) {
+      type = ua->argv[pos][0];
+   }
    LockRes();
    foreach_res(job, R_JOB) {
-      if (acl_access_ok(ua, Job_ACL, job->name())) {
-         ua->send_msg("%s\n", job->name());
+      if (!type || type == job->JobType) {
+         if (acl_access_ok(ua, Job_ACL, job->name())) {
+            ua->send_msg("%s\n", job->name());
+         }
       }
    }
    UnlockRes();
index b07a5d5a5d3f1a39e38bfd33d8b86a1892e2b876..064a9f0cb2585838c4cc3e392c032ab2eaa6aa98 100644 (file)
@@ -65,7 +65,10 @@ static int unmarkcmd(UAContext *ua, TREE_CTX *tree);
 static int unmarkdircmd(UAContext *ua, TREE_CTX *tree);
 static int quitcmd(UAContext *ua, TREE_CTX *tree);
 static int donecmd(UAContext *ua, TREE_CTX *tree);
-
+static int dot_lsdircmd(UAContext *ua, TREE_CTX *tree);
+static int dot_lscmd(UAContext *ua, TREE_CTX *tree);
+static int dot_helpcmd(UAContext *ua, TREE_CTX *tree);
+static int dot_lsmarkcmd(UAContext *ua, TREE_CTX *tree);
 
 struct cmdstruct { const char *key; int (*func)(UAContext *ua, TREE_CTX *tree); const char *help; };
 static struct cmdstruct commands[] = {
@@ -81,7 +84,10 @@ static struct cmdstruct commands[] = {
  { NT_("find"),       findcmd,      _("find files, wildcards allowed")},
  { NT_("help"),       helpcmd,      _("print help")},
  { NT_("ls"),         lscmd,        _("list current directory, wildcards allowed")},
+ { NT_(".ls"),        dot_lscmd,    _("list current directory, wildcards allowed")},
+ { NT_(".lsdir"),     dot_lsdircmd, _("list subdir in current directory, wildcards allowed")},
  { NT_("lsmark"),     lsmarkcmd,    _("list the marked files in and below the cd")},
+ { NT_(".lsmark"),    dot_lsmarkcmd,_("list the marked files in")},
  { NT_("mark"),       markcmd,      _("mark dir/file to be restored recursively, wildcards allowed")},
  { NT_("markdir"),    markdircmd,   _("mark directory name to be restored (no files)")},
  { NT_("pwd"),        pwdcmd,       _("print current working directory")},
@@ -89,6 +95,7 @@ static struct cmdstruct commands[] = {
  { NT_("unmark"),     unmarkcmd,    _("unmark dir/file to be restored recursively in dir")},
  { NT_("unmarkdir"),  unmarkdircmd, _("unmark directory name only no recursion")},
  { NT_("quit"),       quitcmd,      _("quit and do not do restore")},
+ { NT_(".help"),      dot_helpcmd,  _("print help")},
  { NT_("?"),          helpcmd,      _("print help")},
              };
 #define comsize ((int)(sizeof(commands)/sizeof(struct cmdstruct)))
@@ -138,7 +145,7 @@ bool user_select_files_from_tree(TREE_CTX *tree)
       found = 0;
       stat = false;
       for (i=0; i<comsize; i++)       /* search for command */
-         if (strncasecmp(ua->argk[0],  _(commands[i].key), len) == 0) {
+         if (strncasecmp(ua->argk[0],  commands[i].key, len) == 0) {
             stat = (*commands[i].func)(ua, tree);   /* go execute command */
             found = 1;
             break;
@@ -436,7 +443,52 @@ static int findcmd(UAContext *ua, TREE_CTX *tree)
    return 1;
 }
 
+static int dot_lsdircmd(UAContext *ua, TREE_CTX *tree)
+{
+   TREE_NODE *node;
 
+   if (!tree_node_has_child(tree->node)) {
+      return 1;
+   }
+
+   foreach_child(node, tree->node) {
+      if (ua->argc == 1 || fnmatch(ua->argk[1], node->fname, 0) == 0) {
+         if (tree_node_has_child(node)) {
+            ua->send_msg("%s/\n", node->fname);
+         }
+      }
+   }
+   return 1;
+}
+
+static int dot_helpcmd(UAContext *ua, TREE_CTX *tree)
+{
+   for (int i=0; i<comsize; i++) {
+      /* List only non-dot commands */
+      if (commands[i].key[0] != '.') {
+         ua->send_msg("%s\n", commands[i].key);
+      }
+   }
+   return 1;
+}
+
+static int dot_lscmd(UAContext *ua, TREE_CTX *tree)
+{
+   TREE_NODE *node;
+
+   if (!tree_node_has_child(tree->node)) {
+      return 1;
+   }
+
+   foreach_child(node, tree->node) {
+      if (ua->argc == 1 || fnmatch(ua->argk[1], node->fname, 0) == 0) {
+         ua->send_msg("%s%s\n", node->fname, tree_node_has_child(node)?"/":"");
+      }
+   }
+   return 1;
+}
 
 static int lscmd(UAContext *ua, TREE_CTX *tree)
 {
@@ -461,6 +513,24 @@ static int lscmd(UAContext *ua, TREE_CTX *tree)
    return 1;
 }
 
+/*
+ * Ls command that lists only the marked files
+ */
+static int dot_lsmarkcmd(UAContext *ua, TREE_CTX *tree)
+{
+   TREE_NODE *node;
+   if (!tree_node_has_child(tree->node)) {
+      return 1;
+   }
+   foreach_child(node, tree->node) {
+      if ((ua->argc == 1 || fnmatch(ua->argk[1], node->fname, 0) == 0) &&
+          (node->extract || node->extract_dir)) {
+         ua->send_msg("%s%s\n", node->fname, tree_node_has_child(node)?"/":"");
+      }
+   }
+   return 1;
+}
+
 /*
  * Ls command that lists only the marked files
  */
index 85814a0aaa8b9443d47fcdfd38e8738807d7faff..4702e751ea9fa0540278cdbf8d102f8c88f07374 100644 (file)
@@ -2,9 +2,13 @@
           
 General:
 
+16Nov09
+ebl  Add basic completion for restore mode 
 14Nov09
 kes  Fix bug #1367 buy creating an empty query.sql file. The old query.sql
      file is now in exmaples/sample-query.sql, but is unsupported.
+13Nov09
+ebl  Add .jobs type=B/C/R command to filter jobs listing
 11Nov09
 ebl  Fix basejob code for Mysql
 ebl  Fix segfault in basejob code
index 6f8d2ffa11c2f0cefda7f4549f714ea27de9f87e..91bd06567e3903e3959b5e45460c43d53fd40772 100644 (file)
@@ -338,6 +338,18 @@ sub get_fileset
     return $ret;
 }
 
+sub list_backup
+{
+    my ($self) = @_;
+    return sort split(/\r?\n/, $self->send_cmd(".jobs type=B"));
+}
+
+sub list_restore
+{
+    my ($self) = @_;
+    return sort split(/\r?\n/, $self->send_cmd(".jobs type=R"));
+}
+
 sub list_job
 {
     my ($self) = @_;
index d2123721436869751a240abb15ba23eef11ce87e..7c3f5dde2dfb8bba889de0a8cb39cecca3b3d445 100644 (file)
@@ -4904,7 +4904,7 @@ sub run_job_select
 
     my $b = $self->get_bconsole();
 
-    my $joblist = [ map { { name => $_ } } $b->list_job() ];
+    my $joblist = [ map { { name => $_ } } $b->list_backup() ];
 
     $self->display({ Jobs => $joblist }, "run_job.tpl");
 }
index e8d38529f1d48ef79c9936b368c42abab2ea9797..55c998b64eb3eef967765ca62bf4acfd71362e4c 100644 (file)
@@ -1,3 +1,5 @@
+13Nob09
+ebl  Display only Backups in "run new job"
 10Nov09
 ebl  Optimize SQL for ascii and encoded path
 09Nov09