Also out of interest, and maybe a little boasting. :(
I have attached the config.pl I use as an example also. I am no brilliant
Perl coders, but this functions quite well. I have also changed the WinMedia
included so I can specific the place to check drivers for.
$u->{'_meta'}->{'drivers_dir'} = 'none';
# Function to set Driver Paths for Each Machine
# Drivers Should be stored in Z:\Drivers\<driver-set>\
# all drivers for a given machine/type should be stored here.
# drivers will be copied to machines before installation
sub oem_pnp_dirs ($;$) {
my $media_obj = Unattend::WinMedia->new ($u->{'_meta'}->{'OS_media'});
my $oem_system_dir = "z:\\Drivers\\".$u->{'_meta'}->{'drivers_dir'};
print "Looking for drivers under $oem_system_dir...\n";
my @ret = $media_obj->oem_pnp_dirs (1, $oem_system_dir);
#my @ret = $media_obj->oem_pnp_dirs (1);
$verbose && scalar @ret == 0
and print "...no driver directories found.\n";
foreach my $dir (@ret) {
push @selecteddirs, "Drivers\\".$dir;
}
my $ret = join ';', @selecteddirs;
return $ret;
}
#Open PC file and find The Current PC as its parameters
# File format Tab seperated list
# Computer Name MYCOMPUTER
# MAC Address 00004455AACC
# Operating System <win2k|winxp|winxpoem>
# Software Script top (runs top.bat to install apps)
# Driver Directory IBM6288
# OEM Product Key XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
open(pcs, 'z:\\site\\pc');
while(<pcs>) {
chop;
($image,$pc,$mac,$os,$software,$drivers,$productkey) = split(/\t/);
if ( $mac eq $u->{'_meta'}->{'macaddr'}) {
$u->{'_meta'}->{'OS'} = $os;
$u->{'_meta'}->{'top'} = $software.".bat";
$u->{'UserData'}->{'ComputerName'} = $pc;
$u->{'_meta'}->{'drivers_dir'} = $drivers;
$u->{'UserData'}->{'ProductKey'} = $productkey;
last;
}
}
if ( $mac != $u->{'_meta'}->{'macaddr'}) {
print $u->{'_meta'}->{'macaddr'};
#my $newpcname = simple_q ("Enter PC's Name: ");
#my $newpcmac = get_value('_meta','macaddr');
#open(NEWPC,">>z:\\tmp\\newpc") || die ("Cannot Add New PC to File");
#print NEWPC "$newpcname\t$newpcmac\n";
#close NEWPC;
die "Added to the new list, please configure it and restart";
# I should ask questions here, and get it added to the list
# of newpc's like in the old version.
}
#Make boot mac address, strip leading 0's from bytes, last 8 bytes.
#00AABB0DCCE0 -> 0AABBDCCE0 -> ABBDCCE0
my $mac = $u->{'_meta'}->{'macaddr'};
my $newmac = "";
for ($i=0; $i<6 ;$i++) {
$j=substr($mac,($i*2),2);
if (substr($j,0,1) eq "0") {
$j=substr($j,1);
}
$newmac = $newmac . $j;
}
$newmac = substr($newmac,-8);
#Now set doit to tell machine to boot from local machine
#my $copying = "copy /Y z:\\tftpboot\\pxelinux.cfg\\hdd z:\\tftpboot\\pxelinux.cfg\\$newmac;";
my $copying = "copy /Y z:\\tftpboot\\pxelinux.cfg\\hdd z:\\tftpboot\\pxelinux.cfg\\$newmac;";
# Set doit.bat to copy drivers to machine to install.
$copying .= "mkdir C:\\Drivers;xcopy /Y /S z:\\Drivers\\$drivers c:\\Drivers\\;";
$u->{'_meta'}->{'doit_cmds'} = $copying . $u->{'_meta'}->{'doit_cmds'};
# Set PNP drivers.
$u->{'Unattended'}->{'OemPnPDriversPath'} = \&oem_pnp_dirs;
$u->{'_meta'}->{'autolog'} = 'autolog.pl --logon=0';
rtlnet LAB1PCA06 0020ED895A3C winxpoem Fbase build03
XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
rtlnet LAB1PCD02 0020ED896F12 winxpoem Fvideo build03
XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
e100net SPECEDPCA5 0002B3EB2A3F winxpoem Fbase lib04
XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
e100net LIB1PCA03 0002B3EB2C60 winxpoem Flib lib04
XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
--- unattended/install/lib/Unattend/WinMedia.pm 2004-03-16 11:56:13.000000000 +1100
+++ lib/Unattend/WinMedia.pm 2004-03-16 13:38:28.000000000 +1100
@@ -272,9 +272,12 @@
sub oem_pnp_dirs ($;$) {
my Unattend::WinMedia $self = shift;
my $verbose = shift;
+ my $oem_system_dir = shift;
- my $oem_system_dir =
+ if (!$oem_system_dir) {
+ $oem_system_dir =
$file_spec->catdir ($self->path (), 'i386', '$oem$', '$1');
+ }
$verbose
and print "Looking for drivers under $oem_system_dir...\n";