Ide-detect.pl
From Organic Design wiki
#!/usr/bin/perl -w
# Script to detect and auto-install the OS image
# on an ide disk connected to the system.
use strict;
my $bb = "/bin/busybox";
my %disks;
my @list = split /^/, `ls /proc/ide`;
# get list of connected devices
foreach my $file (@list) {
if ($file =~ m/^(hd[a-d])/) {
chomp $file;
# filter for type=disk (ignore cdrom)
if ( `cat /proc/ide/$file/media` =~ m/^disk/ ) {
# construct a hash with the devices as keys
$disks{$file}{'device'} = "/dev/$file\n";
$disks{$file}{'model'} = `cat /proc/ide/$file/model`;
}
}
}
print $disks{hda}{device};
print "You are about to install the Peer OS onto the hard disk of your computer.\n";
print "This installer will ERASE ALL DATA on the target hard drive.\nIf this is not your intention or you do not understand what this means reply NO.\nIf you want to go ahead and initalise the hard drive, reply yes.\n\n";
print "Do you realy want to install? ";
#my $answer = <>;
#if (!grep /^y/i, $answer) { print "Aborting. Your disks were not modified.\n"; exit; }
#if ( keys( %disks ) > 1 ) {
# print "\nMultiple hard drives detected:";
# my @disks = keys %disks;
# foreach (@disks) {
# print "$_\n: model ${$_}{'model'}\n";
# }
# }
print "Initialising filesystem on hda\n";
system "mkfs";
#system "mount /dev/hda /install -t devfs";