source: devel/mindi/sbin/mranalyze-lvm @ 2538

Last change on this file since 2538 was 2538, checked in by bruno, 10 years ago

r3572@localhost: bruno | 2010-01-07 23:38:36 +0100
Reorg of files begining to start working on LVM low level fundtions and scripts

  • Property svn:executable set to *
File size: 3.0 KB
RevLine 
[2076]1#!/usr/bin/perl -w
2#
3# Analyze the LVM configuration
[2119]4# and store the configuration for restore time
[2076]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]27mranalyze-lvm - A Mindi Tool to analyze the LVM configuration and store it
[2076]28
29=head1 DESCRIPTION
30
[2119]31B<mranalyze-lvm> prints all the information related to the LVM configuration that may be used by a restoration process
[2076]32
33=head1 SYNOPSIS
34
[2119]35mranalyze-lvm [-v]|[-q]|[-h]|[--man][-o outputfile][-l logfile]
[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<-o|--output>
[2076]58
[2119]59Name of the file to generate. Use stdout by default
[2076]60
[2119]61The output 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
[2076]67=back
68
69=head1 WEB SITES
70
71The 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/>.
72
73=head1 USER MAILING LIST
74
[2119]75The mailing list of the project is available at L<mailto:mondo@lists.sf.net>
[2076]76 
77=head1 AUTHORS
78
79The Mondorescue.org team L<http://www.mondorescue.org/> lead by Bruno Cornec L<mailto:bruno@mondorescue.org>.
80
81=head1 COPYRIGHT
82
83Analyze-LVM is distributed under the GPL v2.0 license
84described in the file C<COPYING> included with the distribution.
85
86=cut
87
88
89# ---------------------------------------------------------------------------
[2119]90# Globals
91my %opts;                   # CLI Options
[2076]92
93# Initialize the syntax string
94
[2119]95pb_syntax_init("mranalyze-lvm Version PBVER-rPBREV\n");
[2076]96
97# Handle options
98#
99GetOptions("help|?|h" => \$opts{'h'}, 
100        "man" => \$opts{'man'},
101        "verbose|v+" => \$opts{'v'},
102        "quiet|q" => \$opts{'q'},
[2119]103        "output|o=s" => \$opts{'o'},
[2076]104        "log-files|l=s" => \$opts{'l'},
105        "version|V" => \$opts{'V'},
106) || pb_syntax(-1,0);
107
108# easy options
109if (defined $opts{'h'}) {
110    pb_syntax(0,1);
111}
112if (defined $opts{'man'}) {
113    pb_syntax(0,2);
114}
115if (defined $opts{'v'}) {
116    $pbdebug = $opts{'v'};
117}
118if (defined $opts{'q'}) {
119    $pbdebug=-1;
120}
121
122#
123# Global variables
124#
125my $MINDI_VERSION = "PBVER-rPBREV";
126my $MINDI_PREFIX = "PBPREFIX";
127my $MINDI_CONF = "PBCONF";
128my $MINDI_LIB = "PBLIB";
129my $MINDI_SBIN = "$MINDI_PREFIX/sbin";
130#
131# Temp dir
132#
133pb_temp_init();
134
135# -------------------------------- main -----------------------------------
[2119]136# Where to send the output
137my $OUTPUT = \*STDOUT;
138if (defined $opts{'o'}) {
139    open(OUTPUT, "> $opts{'o'}") || mr_exit(-1, "Unable to write to $opts{'o'}");
140    $OUTPUT = \*OUTPUT;
[2076]141}
142
[2538]143my $lvmver = mr_lvm_analyze($OUTPUT);
[2076]144
[2538]145if ($lvmver == 0) {
[2149]146    pb_log(1,"No LVM handling") 
147} else {
148    pb_log(1,"LVM v$lvmver Structure Analyzed") 
[2076]149}
[2149]150close($OUTPUT);
[2119]151mr_exit(0,undef);
Note: See TracBrowser for help on using the repository browser.