source: MondoRescue/devel/mrmini/sbin/mrprepare-lvm@ 3711

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

r3873@localhost: bruno | 2010-06-10 12:28:15 +0200

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