if (pass == 2) {
RUNSCRIPT *script = new_runscript();
- script->set_job_code_callback(job_code_callback_filesetname);
+ script->set_job_code_callback(job_code_callback_director);
script->set_command(lc->str);
* - POOLMEM command string (ex: /bin/true)
* - int command type (ex: SHELL_CMD)
*/
- res_runscript.set_job_code_callback(job_code_callback_filesetname);
+ res_runscript.set_job_code_callback(job_code_callback_director);
while ((c=(char*)res_runscript.commands->pop()) != NULL) {
t = (intptr_t)res_runscript.commands->pop();
RUNSCRIPT *script = new_runscript();
}
/* callback function for edit_job_codes */
-extern "C" char *job_code_callback_filesetname(JCR *jcr, const char* param)
+/* See ../lib/util.c, function edit_job_codes, for more remaining codes */
+extern "C" char *job_code_callback_director(JCR *jcr, const char* param)
{
- if (param[0] == 'f' && jcr->fileset) {
- return jcr->fileset->name();
-
- } else if (param[0] == 'h' && jcr->client) {
- return jcr->client->address;
- }
+ static char yes[] = "yes";
+ static char no[] = "no";
+ switch (param[0]) {
+ case 'f':
+ if (jcr->fileset) {
+ return jcr->fileset->name();
+ }
+ break;
+ case 'h':
+ if (jcr->client) {
+ return jcr->client->address;
+ }
+ break;
+ case 'p':
+ if (jcr->pool) {
+ return jcr->pool->name();
+ }
+ break;
+ case 'w':
+ if (jcr->wstore) {
+ return jcr->wstore->name();
+ }
+ break;
+ case 'x':
+ return jcr->spool_data ? yes : no;
+ break;
+ case 'D':
+ return my_name;
+ break;
+ }
return NULL;
}
jcr->wstore = NULL;
}
-char *job_code_callback_clones(JCR *jcr, const char* param)
-{
- if (param[0] == 'p') {
- return jcr->pool->name();
- }
- return NULL;
-}
-
void create_clones(JCR *jcr)
{
/*
UAContext *ua = new_ua_context(jcr);
ua->batch = true;
foreach_alist(runcmd, job->run_cmds) {
- cmd = edit_job_codes(jcr, cmd, runcmd, "", job_code_callback_clones);
+ cmd = edit_job_codes(jcr, cmd, runcmd, "", job_code_callback_director);
Mmsg(ua->cmd, "run %s cloned=yes", cmd);
Dmsg1(900, "=============== Clone cmd=%s\n", ua->cmd);
parse_ua_args(ua); /* parse command */
/* dird_conf.c */
extern const char *level_to_str(int level);
-extern "C" char *job_code_callback_filesetname(JCR *jcr, const char*);
+extern "C" char *job_code_callback_director(JCR *jcr, const char*);
/* expand.c */
int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp);
#endif
}
+extern "C" char *job_code_callback_filed(JCR *jcr, const char* param)
+{
+ switch (param[0]) {
+ case 'D':
+ if (jcr->director) {
+ return jcr->director->hdr.name;
+ }
+ break;
+ }
+ return NULL;
+
+}
+
static int runbefore_cmd(JCR *jcr)
{
bool ok;
/* Run the command now */
script = new_runscript();
+ script->set_job_code_callback(job_code_callback_filed);
script->set_command(cmd);
script->when = SCRIPT_Before;
ok = script->run(jcr, "ClientRunBeforeJob");
unbash_spaces(msg);
cmd = new_runscript();
+ cmd->set_job_code_callback(job_code_callback_filed);
cmd->set_command(msg);
cmd->on_success = true;
cmd->on_failure = false;
int on_success, on_failure, fail_on_error;
RUNSCRIPT *cmd = new_runscript() ;
+ cmd->set_job_code_callback(job_code_callback_filed);
Dmsg1(100, "runscript_cmd: '%s'\n", dir->msg);
/* Note, we cannot sscanf into bools */
case '|':
p++; /* skip over | */
fn = get_pool_memory(PM_FNAME);
- fn = edit_job_codes(jcr, fn, p, "");
+ fn = edit_job_codes(jcr, fn, p, "", job_code_callback_filed);
bpipe = open_bpipe(fn, 0, "r");
if (!bpipe) {
berrno be;