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

Last change on this file since 2540 was 2540, checked in by Bruno Cornec, 14 years ago

r3576@localhost: bruno | 2010-01-08 01:15:36 +0100
First set of correct split packages. Now need to work on content. mranalyze-lvm is now executable.

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# First use the main configuration file
66pb_conf_init($pbproj);
67pb_conf_add("$confdir/$pbproj.conf");
68}
69
70=item B<mr_exit>
71
72This function closes opened files, clean up the environment and exits MondoRescue
73It takes 2 parameters, the exit code, and the message to print if needed
74
75=cut
76
77sub mr_exit {
78
79my $code = shift;
80my $msg = shift || "";
81
82if (defined $msg) {
83 pb_log($pbdebug,$msg);
84}
85die "ERROR returned\n" if ($code < 0);
86exit($code);
87}
Note: See TracBrowser for help on using the repository browser.