Changeset 2541 in MondoRescue for devel/mr/lib/MondoRescue/LVM.pm
- Timestamp:
- Jan 9, 2010, 4:40:56 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/mr/lib/MondoRescue/LVM.pm
r2540 r2541 16 16 use ProjectBuilder::Base; 17 17 use ProjectBuilder::Conf; 18 use MondoRescue::Base; 18 19 19 20 # Inherit from the "Exporter" module which handles exporting functions. … … 58 59 my $lvmpath = $lvmpath_t->{$ENV{PBPROJ}}; 59 60 61 # That file is not mandatory anymore 60 62 if (! -x $lvmproc) { 61 pb_log(1,"$lvmproc doesn't exist .");62 return(0,undef); 63 }64 65 # Check LVM volumes presence 66 open(LVM,$lvmproc) || mr_exit(-1,"Unable to open $lvmproc"); 67 while (<LVM>) {68 if (/0 VGs 0 PVs 0 LVs/) {69 pb_log(1,"No LVM volumes found in $lvmproc");70 return(0,undef);71 } 72 } 73 close(LVM); 63 pb_log(1,"$lvmproc doesn't exist\n"); 64 } else { 65 # Check LVM volumes presence 66 pb_log(2,"Checking with $lvmproc\n"); 67 open(LVM,$lvmproc) || mr_exit(-1,"Unable to open $lvmproc"); 68 while (<LVM>) { 69 if (/0 VGs 0 PVs 0 LVs/) { 70 pb_log(1,"No LVM volumes found in $lvmproc\n"); 71 return(0,undef); 72 } 73 } 74 close(LVM); 75 } 74 76 75 77 # Check LVM version 76 my $lvmver=0; 77 if (-x $lvmds ) { 78 my $lvmver = 0; 79 if (-x $lvmds) { 80 pb_log(2,"Checking with $lvmds\n"); 78 81 open(LVM,"$lvmds --help 2>&1 |") || mr_exit(-1,"Unable to execute $lvmds"); 79 82 while (<LVM>) { 80 83 if (/Logical Volume Manager/ || /LVM version:/) { 81 84 $lvmver = $_; 85 chomp($lvmver); 82 86 $lvmver =~ s/:([0-9])\..*/$1/; 83 87 } 84 88 } 85 } 86 close(LVM); 89 close(LVM); 90 pb_log(2,"Found a LVM version of $lvmver with $lvmds --help\n"); 91 } 87 92 88 93 if ($lvmver == 0) { 89 # Still not found94 pb_log(2,"LVM version value is still not known\n"); 90 95 if (-x $lvmcmd) { 96 pb_log(2,"Checking with $lvmcmd\n"); 91 97 open(LVM,"$lvmcmd version |") || mr_exit(-1,"Unable to execute $lvmcmd"); 92 98 while (<LVM>) { 93 99 if (/LVM version/) { 94 100 $lvmver = $_; 95 $lvmver =~ s/LVM version ([0-9])\..*/$1/; 101 chomp($lvmver); 102 $lvmver =~ s/:([0-9])\..*/$1/; 103 $lvmver =~ s/[\s]*LVM version[:]*[\s]+([0-9])\..*/$1/; 96 104 } 97 105 } 98 106 close(LVM); 107 pb_log(2,"Found a LVM version of $lvmver with $lvmcmd version\n"); 99 108 } 100 109 } … … 102 111 if ($lvmver == 0) { 103 112 # Still not found 104 mr_exit(-1,"Unable to determine LVM version.\nPlease report to the dev team with the result of the commands \n$lvmds and $lvmcmd");113 mr_exit(-1,"Unable to determine LVM version.\nPlease report to the dev team with the result of the commands:\n$lvmds --help and $lvmcmd version\n"); 105 114 } elsif ($lvmver == 1) { 106 115 $lvmcmd = "$lvmpath"; … … 108 117 $lvmcmd .= " "; 109 118 } else { 110 pb_log(0,"Unknown LVM version $lvmver ");119 pb_log(0,"Unknown LVM version $lvmver\n"); 111 120 } 112 121 # Here $lvmcmd contains a full path name 113 pb_log(1,"Found LVM version $lvmver ");122 pb_log(1,"Found LVM version $lvmver\n"); 114 123 return ($lvmver,$lvmcmd); 115 124 … … 203 212 print $OUTPUT "\n"; 204 213 } elsif (/^LV:/) { 205 if ($firsttime eq0) {214 if ($firsttime == 0) { 206 215 print $OUTPUT "\n"; 207 216 print $OUTPUT "# Activate All Volume Groups\n";
Note:
See TracChangeset
for help on using the changeset viewer.