equal
deleted
inserted
replaced
14 use File::Basename; |
14 use File::Basename; |
15 use Cwd qw(abs_path); |
15 use Cwd qw(abs_path); |
16 use autodie qw(:all); |
16 use autodie qw(:all); |
17 use Pod::Usage; |
17 use Pod::Usage; |
18 use Getopt::Long; |
18 use Getopt::Long; |
|
19 use Hash::Util qw(lock_keys); |
19 use IO::Uncompress::Gunzip qw(gunzip $GunzipError); |
20 use IO::Uncompress::Gunzip qw(gunzip $GunzipError); |
20 |
21 |
21 use constant KiB => 1024; |
22 use constant KiB => 1024; |
22 use constant MiB => 1024 * KiB; |
23 use constant MiB => 1024 * KiB; |
23 use constant GiB => 1024 * MiB; |
24 use constant GiB => 1024 * MiB; |
24 use constant ME => basename $0; |
25 use constant ME => basename $0; |
|
26 use constant CIPHER => "aes-128-cbc"; |
|
27 |
|
28 my %o = (pass => "stdin"); |
|
29 lock_keys(%o); |
25 |
30 |
26 sub find_data_dir; |
31 sub find_data_dir; |
27 |
32 |
28 MAIN: { |
33 MAIN: { |
29 |
34 |
30 Getopt::Long::Configure(qw(Bundling)); |
35 Getopt::Long::Configure(qw(Bundling)); |
31 GetOptions( |
36 GetOptions( |
32 "h|help" => sub { pod2usage(-verbose => 1, -exit => 0) }, |
37 "p|pass=s" => \$o{pass}, |
33 "m|man" => sub { |
38 "h|help" => sub { pod2usage(-verbose => 1, -exit => 0) }, |
|
39 "m|man" => sub { |
34 pod2usage( |
40 pod2usage( |
35 -verbose => 2, |
41 -verbose => 2, |
36 -exit => 0, |
42 -exit => 0, |
37 -noperldoc => system( |
43 -noperldoc => system( |
38 "perldoc -V 1>/dev/null |
44 "perldoc -V 1>/dev/null |
64 my ($in, $buffer); |
70 my ($in, $buffer); |
65 |
71 |
66 if (-f "$data/$path") { |
72 if (-f "$data/$path") { |
67 open($in => "$data/$path"); |
73 open($in => "$data/$path"); |
68 binmode($in); |
74 binmode($in); |
69 local $/ = \$blocksize; |
75 local $/ = undef; |
70 $buffer = <$in>; |
76 $buffer = <$in>; |
71 } |
77 } |
72 elsif (-f "$data/$path.gz") { |
78 elsif (-f "$data/$path.gz") { |
73 open($in => "$data/$path.gz"); |
79 open($in => "$data/$path.gz"); |
|
80 binmode($in); |
|
81 gunzip($in => \$buffer) |
|
82 or die $GunzipError; |
|
83 } |
|
84 elsif (-f "$data/$path.x") { |
|
85 open($in, "openssl @{[CIPHER]} -d -pass $o{pass} -in '$data/$path.x'|"); |
|
86 binmode($in); |
|
87 local $/ = undef; |
|
88 $buffer = <$in>; |
|
89 } |
|
90 elsif (-f "$data/$path.x.gz") { |
|
91 warn "$data/$path.x.gz: depreciated!\n"; |
|
92 open($in, |
|
93 "gzip -d -c $data/$path.x.gz | openssl bf -d -pass $o{pass}|"); |
|
94 binmode($in); |
|
95 local $/ = undef; |
|
96 $buffer = <$in>; |
|
97 } |
|
98 elsif (-f "$data/$path.gz.x") { |
|
99 open($in, "openssl bf -d -pass $o{pass} -in $data/$path.gz.x|"); |
74 binmode($in); |
100 binmode($in); |
75 gunzip($in => \$buffer) |
101 gunzip($in => \$buffer) |
76 or die $GunzipError; |
102 or die $GunzipError; |
77 } |
103 } |
78 else { |
104 else { |
98 |
124 |
99 imager.restore - cats the blocks of the imager |
125 imager.restore - cats the blocks of the imager |
100 |
126 |
101 =head1 SYNOPSIS |
127 =head1 SYNOPSIS |
102 |
128 |
103 imager.restore {idx} {destination} |
129 imager.restore [options] {idx} {destination} |
104 |
130 |
105 =head1 DESCRIPTION |
131 =head1 DESCRIPTION |
106 |
132 |
107 The B<imager.restore> takes all the blocks from the IDX file and |
133 The B<imager.restore> takes all the blocks from the IDX file and |
108 cats them as one data stream. The destination can be any block device, |
134 cats them as one data stream. The destination can be any block device, |
109 a file name or even B<-> (STDOUT). |
135 a file name or even B<-> (STDOUT). |
110 |
136 |
|
137 =head1 OPTIONS |
|
138 |
|
139 =over |
|
140 |
|
141 =item B<-p> I<pass> | B<--pass=>I<pass> |
|
142 |
|
143 In case you expect encrypted data, this option takes the argument for |
|
144 B<openssl>'s C<-pass> option. See L<openssl(3)> for mor information. |
|
145 (default: stdin) |
|
146 |
|
147 =item B<-h>|B<--help> |
|
148 |
|
149 =item B<-m>|B<--man> |
|
150 |
|
151 The standard help options. |
|
152 |
|
153 =back |
111 |
154 |
112 =cut |
155 =cut |