#!/usr/bin/perl -w use POSIX; die "Wrong!\nUsage: nukedisk.pl with no parameters OR nukedisk.pl \ndisk = /dev/sdX\ntest = y(yes)/n(no)" unless( (@ARGV == 2) or (@ARGV == 0) ); if (@ARGV == 2) { our ($disk, $test) = @ARGV; print("Disk: $disk\n"); print("Test: $test\n"); } elsif (@ARGV == 0) { print ("Which disk do you want to wipe? (/dev/sdX): "); $disk = ; chop ($disk); while ($disk !~ /^\/dev\/sd[a-z]$/) { print ("Invalid Value, try again: "); $disk = ; chop ($disk); } print ("Do you wish to test the disk after wiping? (y/n): "); $test = ; chop ($test); while (($test ne "y") && ($test ne "n")) { print ("Invalid Value, try again: "); $test = ; chop ($test); } } if (($disk =~ /^\/dev\/sd[a-z]$/) && (-e $disk)) { print ("Valid Disk\n"); } else { die "Invalid Disk\n"; } if (($test ne "y") && ($test ne "n")) { die "Invalid Value for \n"; } print ("Ready to process disk $disk. Continue? (y/n) "); $continue = ; chop ($continue); while ( ($continue ne "y") && ($continue ne "n")) { print ("Invalid Selection, try again: "); $continue = ; chop ($continue); } if ($continue eq "y") { $startdate = `date`; print ($startdate); my $nukecmd = ("scrub -S -p dod $disk"); print ("Wiping with $nukecmd\n"); # system ($nukecmd); if ($test eq "y") { my $testcmd = ("badblocks -ws -o /dev/null $disk"); print ("Testing with $testcmd\n"); # system ($testcmd); } $enddate = `date`; print ($enddate); print ("Wipe of $disk started at $startdate"); print ("Wipe of $disk ended at $enddate"); } elsif ($continue eq "n") { die "Processing aborted by user.\n"; } else { die "Cannot process selections, try again.\n"; }