RUNSCRIPT *script;
bool runit;
- bool ok;
int when;
}
if (!script->is_local()) {
- runit=false;
+ runit = false;
}
/* we execute it */
if (runit) {
- ok = script->run(jcr, label);
-
- /* cancel running job properly */
- if (script->fail_on_error && !ok) {
- set_jcr_job_status(jcr, JS_ErrorTerminated);
- }
+ script->run(jcr, label);
}
}
return 1;
pm_strcpy(target, client_name);
}
-int RUNSCRIPT::run(JCR *jcr, const char *name)
+bool RUNSCRIPT::run(JCR *jcr, const char *name)
{
Dmsg0(200, "runscript: running a RUNSCRIPT object\n");
POOLMEM *ecmd = get_pool_memory(PM_FNAME);
berrno be;
Jmsg(jcr, M_ERROR, 0, _("Runscript: %s could not execute. ERR=%s\n"), name,
be.bstrerror());
- return false;
+ goto bail_out;
}
while (fgets(line, sizeof(line), bpipe->rfd)) {
int len = strlen(line);
berrno be;
Jmsg(jcr, M_ERROR, 0, _("Runscript: %s returned non-zero status=%d. ERR=%s\n"), name,
be.code(status), be.bstrerror(status));
- return false;
+ goto bail_out;
}
return true;
+
+bail_out:
+ /* cancel running job properly */
+ if (fail_on_error) {
+ set_jcr_job_status(jcr, JS_ErrorTerminated);
+ }
+ return false;
}
void free_runscripts(alist *runscripts)
/* TODO : drop this with bacula 1.42 */
bool old_proto; /* used by old 1.3X protocol */
- int run(JCR *job, const char *name=""); /* name must contain "Before" or "After" keyword */
+ bool run(JCR *job, const char *name=""); /* name must contain "Before" or "After" keyword */
bool can_run_at_level(int JobLevel) { return true;}; /* TODO */
void set_command(const POOLMEM *cmd);
void set_target(const POOLMEM *client_name);