source: MondoRescue/devel/mindi/sbin/mrprepare-lvm@ 2149

Last change on this file since 2149 was 2149, checked in by Bruno Cornec, 15 years ago

Begining f devl branch coding nd preliminary organisation

  • Property svn:executable set to *
File size: 3.5 KB
RevLine 
[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
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;
[2149]20use MondoRescue::Base;
21use MondoRescue::Mindi::LVM;
[2076]22
23=pod
24
25=head1 NAME
26
[2119]27mrprepare-lvm - A Mindi Tool to restore the LVM configuration and apply it
[2076]28
29=head1 DESCRIPTION
30
[2119]31B<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]35mrprepare-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]43Be more verbose
[2076]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
[2119]57=item B<-i|--input>
[2076]58
[2119]59Name of the file to get input from. Use stdin by default
[2076]60
[2119]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
[2076]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
[2119]81The mailing list of the project is available at L<mailto:mondo@lists.sf.net>
[2076]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# ---------------------------------------------------------------------------
[2119]96# Globals
97my %opts; # CLI Options
[2076]98
99# Initialize the syntax string
100
[2119]101pb_syntax_init("mrprepare-lvm Version PBVER-rPBREV\n");
[2076]102
103# Handle options
104#
105GetOptions("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
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'}) {
[2119]127 $pbdebug = -1;
[2076]128}
[2119]129my $mrmult = 1;
130if (defined $opts{'m'}) {
131 $mrmult = $opts{'m'};
132}
[2076]133
134#
135# Global variables
136#
137my $MINDI_VERSION = "PBVER-rPBREV";
138my $MINDI_PREFIX = "PBPREFIX";
139my $MINDI_CONF = "PBCONF";
140my $MINDI_LIB = "PBLIB";
141my $MINDI_SBIN = "$MINDI_PREFIX/sbin";
142#
143# Temp dir
144#
145pb_temp_init();
146
147# -------------------------------- main -----------------------------------
[2119]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;
[2076]153}
154
[2119]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;
[2076]160}
161
[2149]162mr_lvm_prepare($INPUT,$OUTPUT,$mrmult);
[2119]163
[2149]164close($INPUT);
165close($OUTPUT);
[2119]166#WriteShutdownScript
167mr_exit(0,"End of mrprepare-lvm");
Note: See TracBrowser for help on using the repository browser.