is
changeset 36 bdc967bf50d2
parent 35 1c7e99693439
child 37 a61b92c60367
equal deleted inserted replaced
35:1c7e99693439 36:bdc967bf50d2
     6 use strict;
     6 use strict;
     7 use warnings;
     7 use warnings;
     8 use Getopt::Long;
     8 use Getopt::Long;
     9 use Pod::Usage;
     9 use Pod::Usage;
    10 use File::Basename;
    10 use File::Basename;
       
    11 use Data::Dumper;
    11 
    12 
    12 use lib "lib";
    13 use lib "lib";
    13 use SI::system;
    14 use SI::system;
       
    15 use SI::ptable;
       
    16 use SI::lvm;
    14 
    17 
    15 my $ME = basename $0;
    18 my $ME = basename $0;
    16 my $opt_base = "..";
    19 my $opt_base = "..";
    17 my $opt_src = undef;
    20 my $opt_src = undef;
       
    21 my $opt_verbose = undef;
    18 
    22 
    19 
    23 
    20 MAIN: {
    24 MAIN: {
    21 
    25 
    22     GetOptions(
    26     GetOptions(
    23 	"base=s" => \$opt_base,
    27 	"base=s" => \$opt_base,
    24 	"src=s"	=> \$opt_src,
    28 	"src=s"	=> \$opt_src,
       
    29 	"help" => sub { pod2usage(-verbose => 1, exit => 0) },
       
    30 	"man" => sub { pod2usage(-verbose => 2, exit => 0) },
       
    31 	"verbose" => \$opt_verbose,
    25     ) or pod2usage;
    32     ) or pod2usage;
    26 		
    33 		
    27     my $id = SI::system::id();
    34     my $id = SI::system::id();
    28 
    35 
    29     # now check if we find a suitable image
    36     # now check if we find a suitable image
    30     my $src = defined $opt_src ? $opt_src : "$opt_base/image-$id";
    37     my $src = defined $opt_src ? $opt_src : "image-$id";
       
    38     $src = "$opt_base/$src" if $src !~ /\//;
       
    39 
    31     -d $src or die "$ME: $src: $!\n";
    40     -d $src or die "$ME: $src: $!\n";
    32 
    41 
    33     our $VAR1;
    42     our $VAR1;
    34     do "$src/info/devices";
    43     do "$src/info/devices";
    35     my %devices = %$VAR1;
    44     my %devices = %$VAR1;
    36 
    45 
    37     die %devices;
    46 #    SI::ptable::restore(%devices);
       
    47 #    SI::ptable::mkfs(%devices);
       
    48     SI::lvm::pvcreate(%devices);
       
    49     SI::lvm::vgcfgrestore("$src/lvm/vg.*", %devices);
       
    50 
       
    51 
       
    52     exit;
       
    53     die Dumper \%devices;
    38 
    54 
    39 }
    55 }
       
    56 
       
    57 __END__
       
    58 
       
    59 =head1 NAME
       
    60 
       
    61 is - revert si (recover from system image)
       
    62 
       
    63 =head1 SYNOPSIS
       
    64 
       
    65   is [--base=BASE] [--source=SOURCE]
       
    66   is --help
       
    67   is --man
       
    68 
       
    69 =head1 DESCRIPTION
       
    70 
       
    71 This B<is> tool installs the image you saved with B<si>.
       
    72 
       
    73 =head1 OPTIONS
       
    74 
       
    75 =over
       
    76 
       
    77 =item B<-b>|B<--base> I<base>
       
    78 
       
    79 The directory where to look for the images. Each image should have 
       
    80 a unique subdirectory there. (default: I<..>)
       
    81 
       
    82 =item B<-s>|B<--source> I<source>
       
    83 
       
    84 The source of the image. If the source does not contain a slash ("/"), the
       
    85 it is expected to be a subdirectory of the base (see option B<--base>).
       
    86 
       
    87 Normally the source directories are named by the MAC address of the system. 
       
    88 For convenience a symbolic link with the hostname of the saved systems may be
       
    89 in place. (default: mac address)
       
    90 
       
    91 =back
       
    92 
       
    93 =cut
    40 # vim:sts=4 sw=4 aw ai si:
    94 # vim:sts=4 sw=4 aw ai si: