2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2016 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 * Bacula RUNSCRIPT Structure definition for FileDaemon and Director
21 * Eric Bollengier May 2006
25 #ifndef __RUNSCRIPT_H_
26 #define __RUNSCRIPT_H_ 1
32 * #define USE_RUNSCRIPT
33 * #include "lib/runscript.h"
35 * RUNSCRIPT *script = new_runscript();
36 * script->set_command("/bin/sleep 20");
37 * script->on_failure = true;
38 * script->when = SCRIPT_After;
40 * script->run("LabelBefore"); // the label must contain "Before" or "After" special keyword
41 * free_runscript(script);
45 * RUNSCRIPT->when can take following bit values:
49 SCRIPT_After = (1<<0), /* AfterJob */
50 SCRIPT_Before = (1<<1), /* BeforeJob */
51 SCRIPT_AfterVSS = (1<<2), /* BeforeJob and After VSS */
52 SCRIPT_Any = SCRIPT_Before | SCRIPT_After
61 * Structure for RunScript ressource
65 POOLMEM *command; /* command string */
66 POOLMEM *target; /* host target */
67 int when; /* SCRIPT_Before|Script_After BEFORE/AFTER JOB*/
68 int cmd_type; /* Command type -- Shell, Console */
69 char level; /* Base|Full|Incr...|All (NYI) */
70 bool on_success; /* execute command on job success (After) */
71 bool on_failure; /* execute command on job failure (After) */
72 bool fail_on_error; /* abort job on error (Before) */
73 /* TODO : drop this with bacula 1.42 */
74 bool old_proto; /* used by old 1.3X protocol */
75 job_code_callback_t job_code_callback;
76 /* Optional callback function passed to edit_job_code */
77 alist *commands; /* Use during parsing */
78 bool run(JCR *job, const char *name=""); /* name must contain "Before" or "After" keyword */
79 bool can_run_at_level(int JobLevel) { return true;}; /* TODO */
80 void set_command(const char *cmd, int cmd_type = SHELL_CMD);
81 void set_target(const char *client_name);
82 void reset_default(bool free_string = false);
83 bool is_local(); /* true if running on local host */
86 void set_job_code_callback(job_code_callback_t job_code_callback);
89 /* create new RUNSCRIPT (set all value to 0) */
90 RUNSCRIPT *new_runscript();
92 /* create new RUNSCRIPT from an other */
93 RUNSCRIPT *copy_runscript(RUNSCRIPT *src);
95 /* launch each script from runscripts*/
96 int run_scripts(JCR *jcr, alist *runscripts, const char *name);
98 /* free RUNSCRIPT (and all POOLMEM) */
99 void free_runscript(RUNSCRIPT *script);
101 /* foreach_alist free RUNSCRIPT */
102 void free_runscripts(alist *runscripts); /* you have to free alist */
104 extern DLL_IMP_EXP bool (*console_command)(JCR *jcr, const char *cmd);
106 #endif /* __RUNSCRIPT_H_ */