bin/imager.restore
changeset 44 f1fea4381014
parent 42 b5db10953648
child 51 0b6b92d1eb65
equal deleted inserted replaced
43:27f0c30c5240 44:f1fea4381014
     3 # grep '^[[:space:]]*[[:digit:]]' IDX-file | tr -d | cut -f4 -d' ' | while read f; do
     3 # grep '^[[:space:]]*[[:digit:]]' IDX-file | tr -d | cut -f4 -d' ' | while read f; do
     4 #       if   test -f DATA/$f      then cat $f
     4 #       if   test -f DATA/$f      then cat $f
     5 #	elif test -f DATA/$f.gz   then zcat DATA/$f.gz
     5 #	elif test -f DATA/$f.gz   then zcat DATA/$f.gz
     6 #       elif test -f DATA/$f.x    then openssl aes-128-cbc -d -in DATA/$f.x
     6 #       elif test -f DATA/$f.x    then openssl aes-128-cbc -d -in DATA/$f.x
     7 #	elif test -f DATA/$f.gz.x then openssl aes-128-cbc -d -in DATA/$f.gz.x | zcat
     7 #	elif test -f DATA/$f.gz.x then openssl aes-128-cbc -d -in DATA/$f.gz.x | zcat
     8 #	elif test -f DATA/$f.x.gz then zcat DATA/$f.x.gz | openssl aes-128-cbs -d 
     8 #	elif test -f DATA/$f.x.gz then zcat DATA/$f.x.gz | openssl aes-128-cbs -d
     9 #	fi
     9 #	fi
    10 # done
    10 # done
    11 
    11 
    12 use 5.010;
    12 use 5.010;
    13 use strict;
    13 use strict;
    18 use Pod::Usage;
    18 use Pod::Usage;
    19 use Getopt::Long;
    19 use Getopt::Long;
    20 use Hash::Util qw(lock_keys);
    20 use Hash::Util qw(lock_keys);
    21 use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
    21 use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
    22 
    22 
    23 use constant KiB => 1024;
    23 use constant KiB    => 1024;
    24 use constant MiB => 1024 * KiB;
    24 use constant MiB    => 1024 * KiB;
    25 use constant GiB => 1024 * MiB;
    25 use constant GiB    => 1024 * MiB;
    26 use constant ME  => basename $0;
    26 use constant ME     => basename $0;
    27 use constant CIPHER => "aes-128-cbc";
    27 use constant CIPHER => "aes-128-cbc";
    28 
    28 
    29 my %o = (pass => "stdin");
    29 my %o = (pass => "stdin");
    30 lock_keys(%o);
    30 lock_keys(%o);
    31 
    31 
    81             binmode($in);
    81             binmode($in);
    82             gunzip($in => \$buffer)
    82             gunzip($in => \$buffer)
    83               or die $GunzipError;
    83               or die $GunzipError;
    84         }
    84         }
    85         elsif (-f "$data/$path.x") {
    85         elsif (-f "$data/$path.x") {
    86             open($in, "openssl @{[CIPHER]} -d -pass $o{pass} -in '$data/$path.x'|");
    86             open($in,
       
    87                 "openssl @{[CIPHER]} -d -pass $o{pass} -in '$data/$path.x'|");
    87             binmode($in);
    88             binmode($in);
    88             local $/ = undef;
    89             local $/ = undef;
    89             $buffer = <$in>;
    90             $buffer = <$in>;
    90         }
    91         }
    91         elsif (-f "$data/$path.gz.x") {
    92         elsif (-f "$data/$path.gz.x") {
    92             open($in, "openssl @{[CIPHER]} -d -pass $o{pass} -in $data/$path.gz.x|");
    93             open($in,
       
    94                 "openssl @{[CIPHER]} -d -pass $o{pass} -in $data/$path.gz.x|");
    93             binmode($in);
    95             binmode($in);
    94             gunzip($in => \$buffer)
    96             gunzip($in => \$buffer)
    95               or die $GunzipError;
    97               or die $GunzipError;
    96         }
    98         }
    97         elsif (-f "$data/$path.x.gz") {
    99         elsif (-f "$data/$path.x.gz") {
    98             warn "$data/$path.x.gz: depreciated!\n";
   100             warn "$data/$path.x.gz: depreciated!\n";
    99             open($in,
   101             open($in,
   100                 "gzip -d -c $data/$path.x.gz | openssl @{[CIPHER]} -d -pass $o{pass}|");
   102 "gzip -d -c $data/$path.x.gz | openssl @{[CIPHER]} -d -pass $o{pass}|"
       
   103             );
   101             binmode($in);
   104             binmode($in);
   102             local $/ = undef;
   105             local $/ = undef;
   103             $buffer = <$in>;
   106             $buffer = <$in>;
   104         }
   107         }
   105         else {
   108         else {