Skip to content

Commit

Permalink
filed: removed RunBeforeJob and RunAfterCmd ...
Browse files Browse the repository at this point in the history
... from filed/dir_cmd as they were developed to only be compatible
 with old versions
  • Loading branch information
alaaeddineelamri committed Mar 24, 2023
1 parent 1e58751 commit 6cb5b09
Showing 1 changed file with 0 additions and 80 deletions.
80 changes: 0 additions & 80 deletions core/src/filed/dir_cmd.cc
Expand Up @@ -109,9 +109,7 @@ static bool FilesetCmd(JobControlRecord* jcr);
static bool job_cmd(JobControlRecord* jcr);
static bool LevelCmd(JobControlRecord* jcr);
static bool PluginoptionsCmd(JobControlRecord* jcr);
static bool RunafterCmd(JobControlRecord* jcr);
static bool RunbeforenowCmd(JobControlRecord* jcr);
static bool RunbeforeCmd(JobControlRecord* jcr);
static bool RunscriptCmd(JobControlRecord* jcr);
static bool ResolveCmd(JobControlRecord* jcr);
static bool RestoreObjectCmd(JobControlRecord* jcr);
Expand Down Expand Up @@ -165,9 +163,7 @@ static struct s_fd_dir_cmds cmds[] = {
{"JobId=", job_cmd, false},
{"level = ", LevelCmd, false},
{"pluginoptions", PluginoptionsCmd, false},
{"RunAfterJob", RunafterCmd, false},
{"RunBeforeNow", RunbeforenowCmd, false},
{"RunBeforeJob", RunbeforeCmd, false},
{"Run", RunscriptCmd, false},
{"restoreobject", RestoreObjectCmd, false},
{"restore ", RestoreCmd, false},
Expand Down Expand Up @@ -209,8 +205,6 @@ static char endrestoreobjectcmd[] = "restoreobject end\n";
static char pluginoptionscmd[] = "pluginoptions %s";
static char verifycmd[] = "verify level=%30s";
static char Estimatecmd[] = "estimate listing=%d";
static char runbeforecmd[] = "RunBeforeJob %s";
static char runaftercmd[] = "RunAfterJob %s";
static char runscriptcmd[]
= "Run OnSuccess=%d OnFailure=%d AbortOnError=%d When=%d Command=%s";
static char resolvecmd[] = "resolve %s";
Expand Down Expand Up @@ -241,13 +235,9 @@ static char BADjob[] = "2901 Bad Job\n";
static char EndJob[]
= "2800 End Job TermCode=%d JobFiles=%u ReadBytes=%s"
" JobBytes=%s Errors=%u VSS=%d Encrypt=%d\n";
static char OKRunBefore[] = "2000 OK RunBefore\n";
static char OKRunBeforeNow[] = "2000 OK RunBeforeNow\n";
static char OKRunAfter[] = "2000 OK RunAfter\n";
static char OKRunScript[] = "2000 OK RunScript\n";
static char BadRunBeforeJob[] = "2905 Bad RunBeforeJob command.\n";
static char FailedRunScript[] = "2905 Failed RunScript\n";
static char BadRunAfterJob[] = "2905 Bad RunAfterJob command.\n";
static char BADcmd[] = "2902 Bad %s\n";
static char OKRestoreObject[] = "2000 OK ObjectRestored\n";
static char OKPluginOptions[] = "2000 OK PluginOptions\n";
Expand Down Expand Up @@ -941,45 +931,6 @@ static bool job_cmd(JobControlRecord* jcr)
kBareosVersionStrings.GetOsInfo(), BAREOS_PLATFORM);
}

static bool RunbeforeCmd(JobControlRecord* jcr)
{
bool ok;
POOLMEM* cmd;
RunScript* script;
BareosSocket* dir = jcr->dir_bsock;

Dmsg1(100, "RunbeforeCmd: %s", dir->msg);
cmd = GetMemory(dir->message_length + 1);
if (sscanf(dir->msg, runbeforecmd, cmd) != 1) {
PmStrcpy(jcr->errmsg, dir->msg);
Jmsg1(jcr, M_FATAL, 0, _("Bad RunBeforeJob command: %s\n"), jcr->errmsg);
dir->fsend(BadRunBeforeJob);
FreeMemory(cmd);
return false;
}
UnbashSpaces(cmd);

// Run the command now

Dmsg0(500, "runscript: creating new RunScript object\n");
script = new RunScript;
script->SetJobCodeCallback(job_code_callback_filed);
script->SetCommand(cmd);
script->when = SCRIPT_Before;
FreeMemory(cmd);

ok = script->Run(jcr, "ClientRunBeforeJob");
FreeRunscript(script);

if (ok) {
dir->fsend(OKRunBefore);
return true;
} else {
dir->fsend(BadRunBeforeJob);
return false;
}
}

static bool RunbeforenowCmd(JobControlRecord* jcr)
{
BareosSocket* dir = jcr->dir_bsock;
Expand All @@ -1001,37 +952,6 @@ static bool RunbeforenowCmd(JobControlRecord* jcr)
}
}

static bool RunafterCmd(JobControlRecord* jcr)
{
BareosSocket* dir = jcr->dir_bsock;
POOLMEM* cmd;
RunScript* script;

Dmsg1(100, "RunafterCmd: %s", dir->msg);
cmd = GetMemory(dir->message_length + 1);
if (sscanf(dir->msg, runaftercmd, cmd) != 1) {
PmStrcpy(jcr->errmsg, dir->msg);
Jmsg1(jcr, M_FATAL, 0, _("Bad RunAfter command: %s\n"), jcr->errmsg);
dir->fsend(BadRunAfterJob);
FreeMemory(cmd);
return false;
}
UnbashSpaces(cmd);

Dmsg0(500, "runscript: creating new RunScript object\n");
script = new RunScript;
script->SetJobCodeCallback(job_code_callback_filed);
script->SetCommand(cmd);
script->on_success = true;
script->on_failure = false;
script->when = SCRIPT_After;
FreeMemory(cmd);

jcr->fd_impl->RunScripts->append(script);

return dir->fsend(OKRunAfter);
}

static bool RunscriptCmd(JobControlRecord* jcr)
{
POOLMEM* msg;
Expand Down

0 comments on commit 6cb5b09

Please sign in to comment.