]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/runscript.h
crypto: remove most of OpenSSL initcallbacks for 1.1
[bacula/bacula] / bacula / src / lib / runscript.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2016 Kern Sibbald
5
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.
8
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.
13
14    This notice must be preserved when any source code is 
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19 /*
20  * Bacula RUNSCRIPT Structure definition for FileDaemon and Director
21  * Eric Bollengier May 2006
22  */
23
24
25 #ifndef __RUNSCRIPT_H_
26 #define __RUNSCRIPT_H_ 1
27
28 #include "protos.h"
29
30 /* Usage:
31  *
32  * #define USE_RUNSCRIPT
33  * #include "lib/runscript.h"
34  *
35  * RUNSCRIPT *script = new_runscript();
36  * script->set_command("/bin/sleep 20");
37  * script->on_failure = true;
38  * script->when = SCRIPT_After;
39  *
40  * script->run("LabelBefore");  // the label must contain "Before" or "After" special keyword
41  * free_runscript(script);
42  */
43
44 /*
45  * RUNSCRIPT->when can take following bit values:
46  */
47 enum {
48    SCRIPT_Never  = 0,
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
53 };
54
55 enum {
56    SHELL_CMD   = '|',
57    CONSOLE_CMD = '@'
58 };
59
60 /*
61  * Structure for RunScript ressource
62  */
63 class RUNSCRIPT {
64 public:
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 */
84    void debug();
85
86    void set_job_code_callback(job_code_callback_t job_code_callback);
87 };
88
89 /* create new RUNSCRIPT (set all value to 0) */
90 RUNSCRIPT *new_runscript();
91
92 /* create new RUNSCRIPT from an other */
93 RUNSCRIPT *copy_runscript(RUNSCRIPT *src);
94
95 /* launch each script from runscripts*/
96 int run_scripts(JCR *jcr, alist *runscripts, const char *name);
97
98 /* free RUNSCRIPT (and all POOLMEM) */
99 void free_runscript(RUNSCRIPT *script);
100
101 /* foreach_alist free RUNSCRIPT */
102 void free_runscripts(alist *runscripts); /* you have to free alist */
103
104 extern DLL_IMP_EXP bool (*console_command)(JCR *jcr, const char *cmd);
105
106 #endif /* __RUNSCRIPT_H_ */