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