source: MondoRescue/devel/mr/lib/MondoRescue/Base.pm @ 2541

Last change on this file since 2541 was 2541, checked in by Bruno Cornec, 11 years ago

r3577@localhost: bruno | 2010-01-08 02:23:52 +0100
The 2 first commands check and analyze begin to work

File size: 1.6 KB
Line 
1#!/usr/bin/perl -w
2#
3# Base subroutines brought by the MondoRescue project
4#
5# $Id$
6#
7# Copyright B. Cornec 2008
8# Provided under the GPL v2
9
10package MondoRescue::Base;
11
12use strict 'vars';
13use Data::Dumper;
14use English;
15use File::Basename;
16use File::Copy;
17use POSIX qw(strftime);
18use lib qw (lib);
19use ProjectBuilder::Base;
20use ProjectBuilder::Conf;
21use MondoRescue::DynConf;
22
23# Inherit from the "Exporter" module which handles exporting functions.
24
25use Exporter;
26
27# Export, by default, all the functions into the namespace of
28# any code which uses this module.
29
30our @ISA = qw(Exporter);
31our @EXPORT = qw(mr_init mr_exit);
32
33=pod
34
35=head1 NAME
36
37MondoRescue::Base, part of the mondorescue.org
38
39=head1 DESCRIPTION
40
41This modules provides low level and generic functions for the Mondorescue project
42
43=head1 USAGE
44
45=over 4
46
47=item B<mr_init>
48
49This function initialize MondoRescue, point to the right conf files, setup stuff
50It takes 1 parameter, the message to print if needed
51
52=cut
53
54sub mr_init {
55
56my $msg = shift || "";
57
58if (defined $msg) {
59    pb_log($pbdebug,$msg);
60}
61
62# Get the various location determined at installation time
63my ($confdir,$localdir,$pbproj) = mr_dynconf_init();
64
65# Temp dir
66pb_temp_init();
67
68# First use the main configuration file
69pb_conf_init($pbproj);
70pb_conf_add("$confdir/$pbproj.conf");
71}
72
73=item B<mr_exit>
74
75This function closes opened files, clean up the environment and exits MondoRescue
76It takes 2 parameters, the exit code, and the message to print if needed
77
78=cut
79
80sub mr_exit {
81
82my $code = shift;
83my $msg = shift || "";
84
85if (defined $msg) {
86    pb_log($pbdebug,$msg);
87}
88die "ERROR returned\n" if ($code < 0);
89exit($code);
90}
Note: See TracBrowser for help on using the repository browser.