Added more sorting, changed some readouts, corrected find function
This commit is contained in:
parent
83d9ccb08d
commit
21e03eb0a5
12
wipe.pl
12
wipe.pl
@ -48,7 +48,7 @@ sub uniq {
|
|||||||
|
|
||||||
# To get the list of devices we will be cleaning
|
# To get the list of devices we will be cleaning
|
||||||
sub getdisks {
|
sub getdisks {
|
||||||
my $devices = `find /dev/sd*`;
|
my $devices = `find /dev/sd*[a-z]`;
|
||||||
my %listhash = ();
|
my %listhash = ();
|
||||||
foreach(split("\n",$devices)) {
|
foreach(split("\n",$devices)) {
|
||||||
my $devicepath = $_;
|
my $devicepath = $_;
|
||||||
@ -56,7 +56,7 @@ sub getdisks {
|
|||||||
my $model = `udevadm info --query=all --name=$_ | grep ID_MODEL | sed -e 's/^.*=//'`;
|
my $model = `udevadm info --query=all --name=$_ | grep ID_MODEL | sed -e 's/^.*=//'`;
|
||||||
chomp( $serial );
|
chomp( $serial );
|
||||||
chomp( $model );
|
chomp( $model );
|
||||||
if ( $serial ) {
|
if ( $serial && $model ) {
|
||||||
print $devicepath."\t".$serial."\n";
|
print $devicepath."\t".$serial."\n";
|
||||||
$listhash{$_}{"path"} = $devicepath;
|
$listhash{$_}{"path"} = $devicepath;
|
||||||
$listhash{$_}{"serial"} = $serial;
|
$listhash{$_}{"serial"} = $serial;
|
||||||
@ -118,7 +118,7 @@ sub smartcheck {
|
|||||||
$disks->{$diskid}{"smart"}{$smartdata[0]}{"raw_value"} = $smartdata[9];
|
$disks->{$diskid}{"smart"}{$smartdata[0]}{"raw_value"} = $smartdata[9];
|
||||||
}
|
}
|
||||||
close( $smartcommand );
|
close( $smartcommand );
|
||||||
for my $smartentry (keys %{$disks->{$diskid}{"smart"}}) { # I want to have this sort before executing the for loop
|
for my $smartentry (sort {$a cmp $b} keys %{$disks->{$diskid}{"smart"}}) {
|
||||||
if ($disks->{$diskid}{"smart"}{$smartentry}{"id"} =~ /0x05|0x07|0xc4|0xc5|0xc6|0xc7/) {
|
if ($disks->{$diskid}{"smart"}{$smartentry}{"id"} =~ /0x05|0x07|0xc4|0xc5|0xc6|0xc7/) {
|
||||||
print $disks->{$diskid}{"smart"}{$smartentry}{"id"}." ".$disks->{$diskid}{"smart"}{$smartentry}{"name"}."\t".$disks->{$diskid}{"smart"}{$smartentry}{"raw_value"}."\t";
|
print $disks->{$diskid}{"smart"}{$smartentry}{"id"}." ".$disks->{$diskid}{"smart"}{$smartentry}{"name"}."\t".$disks->{$diskid}{"smart"}{$smartentry}{"raw_value"}."\t";
|
||||||
if ($disks->{$diskid}{"smart"}{$smartentry}{"raw_value"} =~ /0|0\/0/) {
|
if ($disks->{$diskid}{"smart"}{$smartentry}{"raw_value"} =~ /0|0\/0/) {
|
||||||
@ -135,12 +135,12 @@ while () {
|
|||||||
my %disks = getdisks();
|
my %disks = getdisks();
|
||||||
my $batchcount = keys %disks;
|
my $batchcount = keys %disks;
|
||||||
print "About to wipe ".$batchcount." drives with the following serial numbers:\n";
|
print "About to wipe ".$batchcount." drives with the following serial numbers:\n";
|
||||||
foreach my $diskid (keys %disks) {
|
foreach my $diskid (sort {$a cmp $b} keys %disks) {
|
||||||
print $disks{$diskid}{"serial"}."\n";
|
print $disks{$diskid}{"serial"}."\n";
|
||||||
}
|
}
|
||||||
anykey("Hit any key to continue...\n");
|
anykey("Hit any key to continue...\n");
|
||||||
foreach my $diskid (keys %disks) {
|
foreach my $diskid (sort {$a cmp $b}keys %disks) {
|
||||||
print "\e[J";
|
print "\e[0;0H\e[2J"; # move cursor to 0,0 and then clear all text below.
|
||||||
print "="x33;
|
print "="x33;
|
||||||
printf '[ %-10s ]', $diskid;
|
printf '[ %-10s ]', $diskid;
|
||||||
print "="x33;
|
print "="x33;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user