1 Index: src/dird/dird_conf.c
2 ===================================================================
3 --- src/dird/dird_conf.c (révision 6586)
4 +++ src/dird/dird_conf.c (copie de travail)
6 lex_get_token(lc, T_STRING);
9 - ((RUNSCRIPT*)item->value)->set_command(lc->str, item->code);
10 + Dmsg2(1, "runscript cmd=%s type=%c\n", lc->str, item->code);
11 + POOLMEM *c = get_pool_memory(PM_FNAME);
12 + pm_strcpy(c, lc->str);
13 + ((RUNSCRIPT*) item->value)->commands->prepend(c);
14 + ((RUNSCRIPT*) item->value)->commands->prepend((void *)item->code);
20 static void store_runscript(LEX *lc, RES_ITEM *item, int index, int pass)
25 alist **runscripts = (alist **)(item->value) ;
27 Dmsg1(200, "store_runscript: begin store_runscript pass=%i\n", pass);
28 @@ -1887,6 +1892,10 @@
29 scan_err1(lc, _("Expecting open brace. Got %s"), lc->str);
33 + res_runscript.commands = New(alist(10, not_owned_by_alist));
36 while ((token = lex_get_token(lc, T_SKIP_EOL)) != T_EOF) {
39 @@ -1914,26 +1923,25 @@
43 - if (res_runscript.command == NULL) {
44 - scan_err2(lc, _("%s item is required in %s resource, but not found.\n"),
45 - "command", "runscript");
48 /* run on client by default */
49 if (res_runscript.target == NULL) {
50 res_runscript.set_target("%c");
53 - RUNSCRIPT *script = new_runscript();
54 - memcpy(script, &res_runscript, sizeof(RUNSCRIPT));
55 - script->set_job_code_callback(job_code_callback_filesetname);
57 if (*runscripts == NULL) {
58 - *runscripts = New(alist(10, not_owned_by_alist));
59 + *runscripts = New(alist(10, not_owned_by_alist));
62 - (*runscripts)->append(script);
64 + while ((c=(char*)res_runscript.commands->pop()) != NULL) {
65 + t = (int) res_runscript.commands->pop();
66 + RUNSCRIPT *script = new_runscript();
67 + memcpy(script, &res_runscript, sizeof(RUNSCRIPT));
68 + script->set_job_code_callback(job_code_callback_filesetname);
69 + script->set_command(c, t);
71 + (*runscripts)->append(script);
74 + delete res_runscript.commands;
75 + res_runscript.commands = NULL;
79 Index: src/lib/runscript.h
80 ===================================================================
81 --- src/lib/runscript.h (révision 6586)
82 +++ src/lib/runscript.h (copie de travail)
95 bool old_proto; /* used by old 1.3X protocol */
96 job_code_callback_t job_code_callback;
97 /* Optional callback function passed to edit_job_code */
99 + alist *commands; /* Use during parsing */
100 bool run(JCR *job, const char *name=""); /* name must contain "Before" or "After" keyword */
101 bool can_run_at_level(int JobLevel) { return true;}; /* TODO */
102 void set_command(const POOLMEM *cmd, int cmd_type = SHELL_CMD);