Changeset 3109 in MondoRescue for devel/mr


Ignore:
Timestamp:
May 5, 2013, 4:48:19 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • First working Base.pm module
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/mr/lib/MondoRescue/Base.pm

    r3108 r3109  
    6161my $msg = shift || "";
    6262
     63pb_log_init($pbdebug);
     64
    6365if (defined $msg) {
    6466    pb_log($pbdebug,$msg);
     
    6668
    6769
     70my $pbproj;
    6871# Get the various location determined at installation time
    69 my ($etcdir,$pbproj) = mr_dynconf_init();
     72($mr->{'confdir'},$pbproj) = mr_dynconf_init();
    7073
    7174# Temp dir
     
    7477# First use the main configuration file
    7578pb_conf_init($pbproj);
     79$ENV{'PBPROJ'} = $pbproj;
    7680#
    7781# Conf files Management
    78 # the $etcdir/mondorescue.conf.dist is delivered as part of the project and
     82# the $mr->{'confdir'}/mondorescue.conf.dist is delivered as part of the project and
    7983# its checksum is verified as we need good default values that we can trust
    8084#
    81 open(MD5,"$etcdir/$pbproj.conf.dist.md5") || die "Unable to read mandatory $etcdir/$pbproj.conf.dist.md5: $!";
     85open(MD5,"$mr->{'confdir'}/$pbproj.conf.dist.md5") || die "Unable to read mandatory $mr->{'confdir'}/$pbproj.conf.dist.md5: $!";
    8286my $omd5 = <MD5>;
     87close(MD5);
    8388chomp($omd5);
    84 close(MD5);
    85 open(CONF,"$etcdir/$pbproj.conf.dist") || die "Unable to read mandatory $etcdir/$pbproj.conf.dist: $!";
    86 my $md5 = Digest::MD5->new;
     89# remove file name
     90$omd5 =~ s/ .*//;
     91open(CONF,"$mr->{'confdir'}/$pbproj.conf.dist") || die "Unable to read mandatory $mr->{'confdir'}/$pbproj.conf.dist: $!";
    8792binmode(CONF);
    88 $md5->addfile(CONF);
    89 my $digest = $md5->hexdigest;
    90 die "Invalid MD5 sum found for $etcdir/$pbproj.conf.dist: $digest" if ($omd5 ne $digest);
     93my $md5 = Digest::MD5->new->addfile(*CONF)->hexdigest;
     94chomp($md5);
     95die "Invalid MD5 found sum for $mr->{'confdir'}/$pbproj.conf.dist: *$md5* instead of *$omd5*" if ($omd5 ne $md5);
    9196close(CONF);
    9297
    93 pb_conf_add("$etcdir/$pbproj.conf.dist");
     98pb_conf_add("$mr->{'confdir'}/$pbproj.conf.dist");
     99pb_conf_add("$mr->{'confdir'}/$pbproj.conf") if (-f "$mr->{'confdir'}/$pbproj.conf");
     100
     101my @date = pb_get_date();
     102$mr->{'start_date'} = strftime("%Y-%m-%d %H:%M:%S", @date);
    94103}
    95104
     
    113122    close($mr->{'logdesc'});
    114123}
    115 die "ERROR returned\n" if ($code < 0);
     124die "ERROR returned\n" if ($code lt 0);
    116125exit($code);
    117126}
Note: See TracChangeset for help on using the changeset viewer.