]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/admin.c
kes Modify job report to include director name and Build OS.
[bacula/bacula] / bacula / src / dird / admin.c
1 /*
2  *
3  *   Bacula Director -- admin.c -- responsible for doing admin jobs
4  *
5  *     Kern Sibbald, May MMIII
6  *
7  *  Basic tasks done here:
8  *     Display the job report.
9  *
10  *   Version $Id$
11  */
12 /*
13    Bacula® - The Network Backup Solution
14
15    Copyright (C) 2003-2006 Free Software Foundation Europe e.V.
16
17    The main author of Bacula is Kern Sibbald, with contributions from
18    many others, a complete list can be found in the file AUTHORS.
19    This program is Free Software; you can redistribute it and/or
20    modify it under the terms of version two of the GNU General Public
21    License as published by the Free Software Foundation plus additions
22    that are listed in the file LICENSE.
23
24    This program is distributed in the hope that it will be useful, but
25    WITHOUT ANY WARRANTY; without even the implied warranty of
26    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27    General Public License for more details.
28
29    You should have received a copy of the GNU General Public License
30    along with this program; if not, write to the Free Software
31    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
32    02110-1301, USA.
33
34    Bacula® is a registered trademark of John Walker.
35    The licensor of Bacula is the Free Software Foundation Europe
36    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
37    Switzerland, email:ftf@fsfeurope.org.
38 */
39
40 #include "bacula.h"
41 #include "dird.h"
42 #include "ua.h"
43
44
45 bool do_admin_init(JCR *jcr)
46 {
47    free_rstorage(jcr);
48    return true;
49 }
50
51 /*
52  *  Returns:  false on failure
53  *            true  on success
54  */
55 bool do_admin(JCR *jcr)
56 {
57
58    jcr->jr.JobId = jcr->JobId;
59
60    jcr->fname = (char *)get_pool_memory(PM_FNAME);
61
62    /* Print Job Start message */
63    Jmsg(jcr, M_INFO, 0, _("Start Admin JobId %d, Job=%s\n"),
64         jcr->JobId, jcr->Job);
65
66    set_jcr_job_status(jcr, JS_Running);
67    admin_cleanup(jcr, JS_Terminated);
68    return true;
69 }
70
71
72 /*
73  * Release resources allocated during backup.
74  */
75 void admin_cleanup(JCR *jcr, int TermCode)
76 {
77    char sdt[50], edt[50];
78    char term_code[100];
79    const char *term_msg;
80    int msg_type;
81    MEDIA_DBR mr;
82
83    Dmsg0(100, "Enter backup_cleanup()\n");
84    memset(&mr, 0, sizeof(mr));
85
86    update_job_end(jcr, TermCode);
87
88    if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) {
89       Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"),
90          db_strerror(jcr->db));
91       set_jcr_job_status(jcr, JS_ErrorTerminated);
92    }
93
94    msg_type = M_INFO;                 /* by default INFO message */
95    switch (jcr->JobStatus) {
96    case JS_Terminated:
97       term_msg = _("Admin OK");
98       break;
99    case JS_FatalError:
100    case JS_ErrorTerminated:
101       term_msg = _("*** Admin Error ***");
102       msg_type = M_ERROR;          /* Generate error message */
103       break;
104    case JS_Canceled:
105       term_msg = _("Admin Canceled");
106       break;
107    default:
108       term_msg = term_code;
109       sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
110       break;
111    }
112    bstrftime(sdt, sizeof(sdt), jcr->jr.StartTime);
113    bstrftime(edt, sizeof(edt), jcr->jr.EndTime);
114
115    Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n"
116 "  JobId:                  %d\n"
117 "  Job:                    %s\n"
118 "  Start time:             %s\n"
119 "  End time:               %s\n"
120 "  Termination:            %s\n\n"),
121         edt,
122         jcr->jr.JobId,
123         jcr->jr.Job,
124         sdt,
125         edt,
126         term_msg);
127
128    Dmsg0(100, "Leave admin_cleanup()\n");
129 }