* Version $Id$
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
static int add_cmd(UAContext *ua, const char *cmd);
static int create_cmd(UAContext *ua, const char *cmd);
static int cancel_cmd(UAContext *ua, const char *cmd);
+static int enable_cmd(UAContext *ua, const char *cmd);
+static int disable_cmd(UAContext *ua, const char *cmd);
static int setdebug_cmd(UAContext *ua, const char *cmd);
static int trace_cmd(UAContext *ua, const char *cmd);
static int var_cmd(UAContext *ua, const char *cmd);
{ N_("cancel"), cancel_cmd, _("cancel [<jobid=nnn> | <job=name>] -- cancel a job")},
{ N_("create"), create_cmd, _("create DB Pool from resource")},
{ N_("delete"), delete_cmd, _("delete [pool=<pool-name> | media volume=<volume-name>]")},
+ { N_("disable"), disable_cmd, _("disable <job=name> -- disable a job")},
+ { N_("enable"), enable_cmd, _("enable <job=name> -- enable a job")},
{ N_("estimate"), estimate_cmd, _("performs FileSet estimate, listing gives full listing")},
{ N_("exit"), quit_cmd, _("exit = quit")},
{ N_("gui"), gui_cmd, _("gui [on|off] -- non-interactive gui mode")},
pr.MaxVols, pr.PoolType);
while (pr.MaxVols > 0 && pr.NumVols >= pr.MaxVols) {
- bsendmsg(ua, _("Pool already has maximum volumes = %d\n"), pr.MaxVols);
+ bsendmsg(ua, _("Pool already has maximum volumes=%d\n"), pr.MaxVols);
for (;;) {
if (!get_pint(ua, _("Enter new maximum (zero for unlimited): "))) {
return 1;
/* Count Jobs running */
foreach_jcr(jcr) {
if (jcr->JobId == 0) { /* this is us */
- free_jcr(jcr);
continue;
}
- free_jcr(jcr);
njobs++;
}
+ endeach_jcr(jcr);
if (njobs == 0) {
bsendmsg(ua, _("No Jobs running.\n"));
foreach_jcr(jcr) {
char ed1[50];
if (jcr->JobId == 0) { /* this is us */
- free_jcr(jcr);
continue;
}
bsnprintf(buf, sizeof(buf), _("JobId=%s Job=%s"), edit_int64(jcr->JobId, ed1), jcr->Job);
add_prompt(ua, buf);
- free_jcr(jcr);
}
+ endeach_jcr(jcr);
if (do_prompt(ua, _("Job"), _("Choose Job to cancel"), buf, sizeof(buf)) < 0) {
return 1;
}
+static void do_en_disable_cmd(UAContext *ua, bool setting)
+{
+ JOB *job;
+ int i;
+
+ i = find_arg_with_value(ua, N_("job"));
+ if (i < 0) {
+ job = select_job_resource(ua);
+ if (!job) {
+ return;
+ }
+ } else {
+ LockRes();
+ job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
+ UnlockRes();
+ }
+ if (!job) {
+ bsendmsg(ua, _("Job \"%s\" not found.\n"), ua->argv[i]);
+ return;
+ }
+
+ if (!acl_access_ok(ua, Job_ACL, job->hdr.name)) {
+ bsendmsg(ua, _("Illegal command from this console.\n"));
+ return;
+ }
+ job->enabled = setting;
+ bsendmsg(ua, _("Job \"%s\" %sabled\n"), job->hdr.name, setting?"en":"dis");
+ return;
+}
+
+static int enable_cmd(UAContext *ua, const char *cmd)
+{
+ do_en_disable_cmd(ua, true);
+ return 1;
+}
+
+static int disable_cmd(UAContext *ua, const char *cmd)
+{
+ do_en_disable_cmd(ua, false);
+ return 1;
+}
+
+
static void do_storage_setdebug(UAContext *ua, STORE *store, int level, int trace_flag)
{
BSOCK *sd;
Mmsg(query, "DELETE FROM Job WHERE JobId=%s", edit_int64(JobId, ed1));
db_sql_query(ua->db, query, NULL, (void *)NULL);
- Mmsg(query, "DELETE FROM File WHERE JobId=%s", edit_int64(JobId, ed1));
+ Mmsg(query, "DELETE FROM MAC WHERE JobId=%s", ed1);
db_sql_query(ua->db, query, NULL, (void *)NULL);
- Mmsg(query, "DELETE FROM JobMedia WHERE JobId=%s", edit_int64(JobId, ed1));
+ Mmsg(query, "DELETE FROM File WHERE JobId=%s", ed1);
+ db_sql_query(ua->db, query, NULL, (void *)NULL);
+ Mmsg(query, "DELETE FROM JobMedia WHERE JobId=%s", ed1);
db_sql_query(ua->db, query, NULL, (void *)NULL);
free_pool_memory(query);
bsendmsg(ua, _("Job %s and associated records deleted from the catalog.\n"), edit_int64(JobId, ed1));
if (!store) {
return;
}
+ set_storage(jcr, store);
drive = get_storage_drive(ua, store);
Dmsg3(120, "Found storage, MediaType=%s DevName=%s drive=%d\n",
store->media_type, store->dev_name(), drive);
- set_storage(jcr, store);
if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) {
bsendmsg(ua, _("Failed to connect to Storage daemon.\n"));
return;
foreach_jcr(jcr) {
if (jcr->JobId != 0) {
running = true;
- free_jcr(jcr);
break;
}
- free_jcr(jcr);
}
+ endeach_jcr(jcr);
+
if (running) {
bmicrosleep(1, 0);
}
* a "use catalog xxx" command, we simply find the first
* catalog resource and open it.
*/
-int open_db(UAContext *ua)
+bool open_db(UAContext *ua)
{
if (ua->db) {
- return 1;
+ return true;
}
if (!ua->catalog) {
LockRes();
UnlockRes();
if (!ua->catalog) {
bsendmsg(ua, _("Could not find a Catalog resource\n"));
- return 0;
+ return false;
+ } else if (!acl_access_ok(ua, Catalog_ACL, ua->catalog->hdr.name)) {
+ bsendmsg(ua, _("You must specify a \"use <catalog-name>\" command before continuing.\n"));
+ ua->catalog = NULL;
+ return false;
} else {
bsendmsg(ua, _("Using default Catalog name=%s DB=%s\n"),
ua->catalog->hdr.name, ua->catalog->db_name);
bsendmsg(ua, "%s", db_strerror(ua->db));
}
close_db(ua);
- return 0;
+ return false;
}
ua->jcr->db = ua->db;
Dmsg1(150, "DB %s opened\n", ua->catalog->db_name);
- return 1;
+ return true;
}
void close_db(UAContext *ua)