]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/runscript.h
Update copyright
[bacula/bacula] / bacula / src / lib / runscript.h
1 /*
2  * Bacula RUNSCRIPT Structure definition for FileDaemon and Director
3  * Eric Bollengier May 2006
4  * Version $Id$
5  */
6 /*
7    Bacula® - The Network Backup Solution
8
9    Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
10
11    The main author of Bacula is Kern Sibbald, with contributions from
12    many others, a complete list can be found in the file AUTHORS.
13    This program is Free Software; you can redistribute it and/or
14    modify it under the terms of version two of the GNU General Public
15    License as published by the Free Software Foundation plus additions
16    that are listed in the file LICENSE.
17
18    This program is distributed in the hope that it will be useful, but
19    WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21    General Public License for more details.
22
23    You should have received a copy of the GNU General Public License
24    along with this program; if not, write to the Free Software
25    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26    02110-1301, USA.
27
28    Bacula® is a registered trademark of John Walker.
29    The licensor of Bacula is the Free Software Foundation Europe
30    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
31    Switzerland, email:ftf@fsfeurope.org.
32 */
33
34
35 #ifndef __RUNSCRIPT_H_
36 #define __RUNSCRIPT_H_ 1
37
38 /* Usage:
39  *
40  * #define USE_RUNSCRIPT
41  * #include "lib/runscript.h"
42  * 
43  * RUNSCRIPT *script = new_runscript();
44  * script->set_command("/bin/sleep 20");
45  * script->on_failure = true;
46  * script->when = SCRIPT_After;
47  * 
48  * script->run("Label");
49  * free_runscript(script);
50  */
51
52 /* 
53  * RUNSCRIPT->when can take following bit values:
54  */
55 enum {
56    SCRIPT_Never  = 0,
57    SCRIPT_After  = (1<<0),      /* AfterJob */
58    SCRIPT_Before = (1<<1),      /* BeforeJob */
59    SCRIPT_Any    = SCRIPT_Before | SCRIPT_After
60 };
61
62 /*
63  * Structure for RunScript ressource
64  */
65 class RUNSCRIPT {
66 public:
67    POOLMEM *command;            /* command string */
68    POOLMEM *target;             /* host target */
69    char level;                  /* Base|Full|Incr...|All (NYI) */
70    bool on_success;             /* executre command on job success (After) */
71    bool on_failure;             /* executre command on job failure (After) */
72    bool abort_on_error;         /* abort job on error (Before) */
73    int  when;                   /* SCRIPT_Before|Script_After BEFORE/AFTER JOB*/
74    /* TODO : drop this with bacula 1.42 */
75    bool old_proto;              /* used by old 1.3X protocol */
76
77    int run(JCR *job, const char *name="");
78    bool can_run_at_level(int JobLevel) { return true;};        /* TODO */
79    void set_command(const POOLMEM *cmd);
80    void set_target(const POOLMEM *client_name);
81    void reset_default(bool free_string = false);
82    bool is_local();             /* true if running on local host */
83    void debug();
84 };
85
86 /* create new RUNSCRIPT (set all value to 0) */
87 RUNSCRIPT *new_runscript();           
88
89 /* create new RUNSCRIPT from an other */
90 RUNSCRIPT *copy_runscript(RUNSCRIPT *src);
91
92 /* launch each script from runscripts*/
93 int run_scripts(JCR *jcr, alist *runscripts, const char *name); 
94
95 /* free RUNSCRIPT (and all POOLMEM) */
96 void free_runscript(RUNSCRIPT *script);
97
98 /* foreach_alist free RUNSCRIPT */
99 void free_runscripts(alist *runscripts); /* you have to free alist */
100
101 #endif /* __RUNSCRIPT_H_ */