minor syntax corrections and output adjustments
This commit is contained in:
parent
97e3b5f41e
commit
5a8d07e678
24
wipe.pl
24
wipe.pl
@ -93,14 +93,16 @@ sub getdisks {
|
||||
return %listhash;
|
||||
}
|
||||
|
||||
# To whip a drive
|
||||
# To whipe a drive
|
||||
sub wipethemdrives {
|
||||
my $diskid = shift;
|
||||
my $disks = shift;
|
||||
# Write
|
||||
say "$disks->{$diskid}{path} - Serial:$disks->{$diskid}{serial} is being wiped...";
|
||||
my $disksum;
|
||||
my $spacer = 29;
|
||||
if ($notreally) {
|
||||
$spacer = 18;
|
||||
print "Pretend wipe complete, pretending to check...";
|
||||
$disksum = $clobsum;
|
||||
} else {
|
||||
@ -118,16 +120,12 @@ sub wipethemdrives {
|
||||
}
|
||||
# say "Disk Checksum: $disksum";
|
||||
if ($disksum eq $clobsum) {
|
||||
say +("."x28)."Checksum $color{green}PASSED!!!$color{reset}";
|
||||
say +("."x$spacer)."Checksum $color{green}PASSED$color{reset}";
|
||||
# say "$disks->{$diskid}{path} is clean.";
|
||||
return 1;
|
||||
} else {
|
||||
# say "Wipe Checksum: $clobsum";
|
||||
say +("."x28)."Checksum $color{red}FAILED!!!$color{reset}";
|
||||
# this code will not work on the majority of terminals,
|
||||
# now that we support anything with a terminfo entry.
|
||||
# printf("%-37.37s %9.9s\n", "Checksum ","$color{red}FAILED!!!$color{reset}");
|
||||
# say "$disks->{$diskid}{path} did not take, it could be bad.";
|
||||
say +("."x$spacer)."Checksum $color{red}FAILED$color{reset}";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -137,11 +135,11 @@ sub smartcheck {
|
||||
# Do our smart disk thing...
|
||||
my $diskid = shift;
|
||||
my $disks = shift;
|
||||
say "Checking overall-health self-assessment test result: ";
|
||||
print "Checking overall-health self-assessment test result: ".(" "x19);
|
||||
(my $smartassess = `smartctl /dev/sda -H | grep overall`) or (say "$!\ncould not check smart data, skipping" and return 1);
|
||||
$disks->{$diskid}{smart}{selftest} = (split(": ", $smartassess))[1];
|
||||
if ( "FAILED" == $disks->{$diskid}{smart}{selftest} ) { say "$color{red}Failed$color{reset}"; return 0
|
||||
} else { say "$color{green}Passed$color{reset}\n"; }
|
||||
$disks->{$diskid}{selftest} = (split(": ", $smartassess))[1];
|
||||
if ( "FAILED" eq $disks->{$diskid}{selftest} ) { say "$color{red}Failed$color{reset}"; return 0
|
||||
} else { say "$color{green}Passed$color{reset}"; }
|
||||
say "Checking S.M.A.R.T. variables...";
|
||||
# say qq(smartctl $disks->{$diskid}{path} -A -f hex,id | grep "^0x");
|
||||
(my $smartcommand = `smartctl $disks->{$diskid}{path} -A -f hex,id | grep "^0x"`) or (say "$!\ncould not check smart data, skipping" and return 1);
|
||||
@ -180,7 +178,7 @@ while () {
|
||||
foreach my $diskid (sort {$disks{$a}{serial} cmp $disks{$b}{serial}} keys %disks) {
|
||||
say $disks{$diskid}{serial};
|
||||
}
|
||||
exit unless "\n" eq anykey("Last chance to save your data, hit ENTER to DESTROY ALL DATA, or any other key to abort!\n");
|
||||
# exit unless "\n" eq anykey("Last chance to save your data, hit ENTER to DESTROY ALL DATA, or any other key to abort!\n");
|
||||
foreach my $diskid (sort {$a cmp $b}keys %disks) {
|
||||
print "="x33;
|
||||
printf '[ %-10s ]', $diskid;
|
||||
@ -190,7 +188,7 @@ while () {
|
||||
$disks{$diskid}{smartpass} = smartcheck($diskid,\%disks);
|
||||
if ($disks{$diskid}{smartpass} == 1) {
|
||||
push(@good, sprintf("%-26.26s\t%46.46s",$disks{$diskid}{serial},$disks{$diskid}{model}));
|
||||
} else { push(@failed, $sprintf("%-26.26s\t%46.46s",$disks{$diskid}{serial},$disks{$diskid}{model})); }
|
||||
} else { push(@failed, sprintf("%-26.26s\t%46.46s",$disks{$diskid}{serial},$disks{$diskid}{model})); }
|
||||
} else { push(@failed, $disks{$diskid}{serial}); }
|
||||
print "="x80;
|
||||
print "\n"x5;
|
||||
|
Loading…
x
Reference in New Issue
Block a user