[2076] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
| 3 | # Analyze the LVM configuration
|
---|
| 4 | # and stor the configuration for restore time
|
---|
| 5 | #
|
---|
| 6 | # $Id$
|
---|
| 7 | #
|
---|
| 8 | # Copyright B. Cornec 2008
|
---|
| 9 | # Provided under the GPL v2
|
---|
| 10 |
|
---|
| 11 | # Syntax: see below
|
---|
| 12 |
|
---|
| 13 | use strict 'vars';
|
---|
| 14 | use Getopt::Long qw(:config auto_abbrev no_ignore_case);
|
---|
| 15 | use Data::Dumper;
|
---|
| 16 | use English;
|
---|
| 17 | use lib qw (lib);
|
---|
| 18 | use ProjectBuilder::Base;
|
---|
| 19 | use ProjectBuilder::Distribution;
|
---|
[2149] | 20 | use MondoRescue::Base;
|
---|
[2540] | 21 | use MondoRescue::LVM;
|
---|
[2076] | 22 |
|
---|
| 23 | =pod
|
---|
| 24 |
|
---|
| 25 | =head1 NAME
|
---|
| 26 |
|
---|
[2648] | 27 | mrprepare-lvm - A MondoRescue Tool to restore the LVM configuration and apply it
|
---|
[2076] | 28 |
|
---|
| 29 | =head1 DESCRIPTION
|
---|
| 30 |
|
---|
[2119] | 31 | B<mrprepare-lvm> gets all the information related to the LVM configuration from stdin or a file and prepare a restoration script
|
---|
[2076] | 32 |
|
---|
| 33 | =head1 SYNOPSIS
|
---|
| 34 |
|
---|
[2119] | 35 | mrprepare-lvm [-v]|[-q]|[-h]|[--man][-i inputfile][-l logfile][-m multiplier]
|
---|
[2076] | 36 |
|
---|
| 37 | =head1 OPTIONS
|
---|
| 38 |
|
---|
| 39 | =over 4
|
---|
| 40 |
|
---|
| 41 | =item B<-v|--verbose>
|
---|
| 42 |
|
---|
[2119] | 43 | Be more verbose
|
---|
[2076] | 44 |
|
---|
| 45 | =item B<-q|--quiet>
|
---|
| 46 |
|
---|
| 47 | Do not print any output.
|
---|
| 48 |
|
---|
| 49 | =item B<-h|--help>
|
---|
| 50 |
|
---|
| 51 | Print a brief help message and exits.
|
---|
| 52 |
|
---|
| 53 | =item B<--man>
|
---|
| 54 |
|
---|
| 55 | Prints the manual page and exits.
|
---|
| 56 |
|
---|
[2119] | 57 | =item B<-i|--input>
|
---|
[2076] | 58 |
|
---|
[2119] | 59 | Name of the file to get input from. Use stdin by default
|
---|
[2076] | 60 |
|
---|
[2119] | 61 | The input format is:
|
---|
| 62 | LVM:lvm-version
|
---|
| 63 | PV:pv-information as done with pvdisplay -c
|
---|
| 64 | VG:vg-information as done with vgdisplay -c
|
---|
| 65 | LV:lv-information as done with lvdisplay -c
|
---|
| 66 |
|
---|
| 67 | =item B<-o|--output>
|
---|
| 68 |
|
---|
| 69 | Name of the file to write output to. Use stdout by default.
|
---|
| 70 | The output file is a srpit ready to run in order to setup correctly LVM
|
---|
| 71 |
|
---|
| 72 |
|
---|
[2076] | 73 | =back
|
---|
| 74 |
|
---|
| 75 | =head1 WEB SITES
|
---|
| 76 |
|
---|
| 77 | The main Web site of the project is available at L<http://www.mondorescue.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.mondorescue.org/>.
|
---|
| 78 |
|
---|
| 79 | =head1 USER MAILING LIST
|
---|
| 80 |
|
---|
[2119] | 81 | The mailing list of the project is available at L<mailto:mondo@lists.sf.net>
|
---|
[2076] | 82 |
|
---|
| 83 | =head1 AUTHORS
|
---|
| 84 |
|
---|
| 85 | The Mondorescue.org team L<http://www.mondorescue.org/> lead by Bruno Cornec L<mailto:bruno@mondorescue.org>.
|
---|
| 86 |
|
---|
| 87 | =head1 COPYRIGHT
|
---|
| 88 |
|
---|
| 89 | Analyze-LVM is distributed under the GPL v2.0 license
|
---|
| 90 | described in the file C<COPYING> included with the distribution.
|
---|
| 91 |
|
---|
| 92 | =cut
|
---|
| 93 |
|
---|
| 94 |
|
---|
| 95 | # ---------------------------------------------------------------------------
|
---|
[2119] | 96 | # Globals
|
---|
| 97 | my %opts; # CLI Options
|
---|
[2076] | 98 |
|
---|
| 99 | # Initialize the syntax string
|
---|
| 100 |
|
---|
[2119] | 101 | pb_syntax_init("mrprepare-lvm Version PBVER-rPBREV\n");
|
---|
[2076] | 102 |
|
---|
| 103 | # Handle options
|
---|
| 104 | #
|
---|
| 105 | GetOptions("help|?|h" => \$opts{'h'},
|
---|
| 106 | "man" => \$opts{'man'},
|
---|
| 107 | "verbose|v+" => \$opts{'v'},
|
---|
| 108 | "quiet|q" => \$opts{'q'},
|
---|
[2119] | 109 | "input|i=s" => \$opts{'o'},
|
---|
| 110 | "output|o=s" => \$opts{'o'},
|
---|
| 111 | "multiplier|m=s" => \$opts{'o'},
|
---|
[2076] | 112 | "log-files|l=s" => \$opts{'l'},
|
---|
| 113 | "version|V" => \$opts{'V'},
|
---|
| 114 | ) || pb_syntax(-1,0);
|
---|
| 115 |
|
---|
| 116 | # easy options
|
---|
| 117 | if (defined $opts{'h'}) {
|
---|
| 118 | pb_syntax(0,1);
|
---|
| 119 | }
|
---|
| 120 | if (defined $opts{'man'}) {
|
---|
| 121 | pb_syntax(0,2);
|
---|
| 122 | }
|
---|
| 123 | if (defined $opts{'v'}) {
|
---|
| 124 | $pbdebug = $opts{'v'};
|
---|
| 125 | }
|
---|
| 126 | if (defined $opts{'q'}) {
|
---|
[2119] | 127 | $pbdebug = -1;
|
---|
[2076] | 128 | }
|
---|
[2119] | 129 | my $mrmult = 1;
|
---|
| 130 | if (defined $opts{'m'}) {
|
---|
| 131 | $mrmult = $opts{'m'};
|
---|
| 132 | }
|
---|
[2076] | 133 |
|
---|
| 134 | #
|
---|
| 135 | # Global variables
|
---|
| 136 | #
|
---|
[2648] | 137 | my $MRMINI_VERSION = "PBVER-rPBREV";
|
---|
| 138 | my $MRMINI_PREFIX = "PBPREFIX";
|
---|
| 139 | my $MRMINI_CONF = "PBCONF";
|
---|
| 140 | my $MRMINI_LIB = "PBLIB";
|
---|
| 141 | my $MRMINI_SBIN = "$MRMINI_PREFIX/sbin";
|
---|
[2076] | 142 | #
|
---|
| 143 | # Temp dir
|
---|
| 144 | #
|
---|
| 145 | pb_temp_init();
|
---|
| 146 |
|
---|
| 147 | # -------------------------------- main -----------------------------------
|
---|
[2119] | 148 | # Where to send the output
|
---|
| 149 | my $OUTPUT = \*STDOUT;
|
---|
| 150 | if (defined $opts{'o'}) {
|
---|
| 151 | open(OUTPUT, "> $opts{'o'}") || mr_exit(-1, "Unable to write to $opts{'o'}");
|
---|
| 152 | $OUTPUT = \*OUTPUT;
|
---|
[2076] | 153 | }
|
---|
| 154 |
|
---|
[2119] | 155 | # Where to get the input
|
---|
| 156 | my $INPUT = \*STDIN;
|
---|
| 157 | if (defined $opts{'i'}) {
|
---|
| 158 | open(INPUT, " $opts{'i'}") || mr_exit(-1, "Unable to read from $opts{'i'}");
|
---|
| 159 | $INPUT = \*INPUT;
|
---|
[2076] | 160 | }
|
---|
| 161 |
|
---|
[2149] | 162 | mr_lvm_prepare($INPUT,$OUTPUT,$mrmult);
|
---|
[2119] | 163 |
|
---|
[2149] | 164 | close($INPUT);
|
---|
| 165 | close($OUTPUT);
|
---|
[2119] | 166 | #WriteShutdownScript
|
---|
| 167 | mr_exit(0,"End of mrprepare-lvm");
|
---|