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