Changeset 50
- Timestamp:
- 05/02/08 15:38:40 (2 years ago)
- Files:
-
- devel/dploy-pxe/bin/dploy-add2pxe (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/dploy-pxe/bin/dploy-add2pxe
r49 r50 11 11 use File::Copy; 12 12 use File::Basename; 13 use ProjectBuilder::Base; 14 use Dploy::Base; 13 15 14 16 my %opts; 15 my $type = ""; 16 my $mac = ""; 17 my $url = ""; 17 my $url = undef; 18 18 my $ksdevice = "eth0"; 19 my $prefix = "";20 my $mrserver = "";21 my $mrpath = "";19 my $prefix = undef; 20 my $mrserver = undef; 21 my $mrpath = undef; 22 22 23 23 GetOptions("help|?|h" => \$opts{'h'}, … … 25 25 "mac|m=s" => \$opts{'mac'}, # Mac address 26 26 "url|u=s" => \$opts{'url'}, # URL of ISO image containing kernel, modules and answer file 27 ) || dploy_syntax(-1,0); 28 29 if (defined $opts{'type'}) { 30 $type = $opts{'type'}; 31 } 27 ) || pb_syntax(-1,0); 32 28 33 29 if (defined $opts{'h'}) { 34 dploy_syntax(0,1);30 pb_syntax(0,1); 35 31 } 36 32 … … 46 42 my $mnt2="$tmp/nfs"; 47 43 48 my $mac=$ARGV[0] || ""; 49 50 # Check Mac consitency (to be done in an external function) 51 if ($mac !~ /^(?:[[:xdigit:]]{1,2}[-:]){5}[[:xdigit:]]{1,2}$/) { 52 print "Syntax: dploy-add2pxe MAC url-to-iso\n"; 53 exit(-1); 54 } 55 56 # only lowercase for homogeneity 57 $mac =~ tr/A-Z/a-z/; 58 59 # newmac replaces : separator with - and only lowercase for pxelinux 60 my $newmac = $mac; 61 $newmac =~ tr/A-Z/a-z/; 62 $newmac =~ s/:/-/g; 44 # Check Mac consitency 45 my $mac = dploy_check_mac($opt{'mac'}); 63 46 64 47 # Check URL syntax 65 48 if (defined $opts{'url'}) { 66 $url = $opts{'url'};49 $url = $opts{'url'}; 67 50 } 68 51 … … 87 70 # mount the ISO to get kernel and initrd 88 71 mkdir "$mnt",0755; 89 if ($Type == "LinuxCOE") { 90 system("sudo /bin/mount -o loop $linuxcoe/$iso $mnt"); 72 if ($opt{'type'} == "LinuxCOE") { 73 pb_system("sudo /bin/mount -o loop $linuxcoe/$iso $mnt","Error mounting $linuxcoe/$iso"); 74 } else if ($opt{'type'} == "MondoRescue") { 75 pb_system("sudo /bin/mount -t nfs $mrserver:$mrpath $mnt2","Error mountig NFS $mrserver:$mrpath"); 76 pb_system("sudo /bin/mount -o loop $mnt2/$prefix-1.iso $mnt","Error mounting LOOP $mnt2/$prefix-1.iso"); 91 77 } else { 92 system("sudo /bin/mount -t nfs $mrserver:$mrpath $mnt2"); 93 system("sudo /bin/mount -o loop $mnt2/$prefix-1.iso $mnt");78 # Type passed has parameter does not contain a valid value 79 pb_syntax(-1.0); 94 80 } 81 95 82 # Install script will have to check (and create if not existing) /tftpboot/tmp 96 83 copy("$mnt/isolinux/vmlinuz","$pxe/../tmp/$k") or die "Copy failed: $!"; … … 109 96 close ISOLINUX; 110 97 # All done with ISO image... umounting 111 system("sudo /bin/umount $mnt"); 112 98 pb_system("sudo /bin/umount $mnt","Error umount ISO image); 113 99 114 100 # Updates PXElinux 115 open(PXE, "> $pxe/01-$ newmac") || die "Unable to open $pxe/01-$newmac for writing";101 open(PXE, "> $pxe/01-$mac") || die "Unable to open $pxe/01-$mac for writing"; 116 102 print PXE << "EOF"; 117 103 default local … … 128 114 129 115 # Customize pxe file depending on Job type submited 130 open(PXE, ">> $pxe/01-$ newmac") || die "Unable to open $pxe/01-$newmac for writing";131 if ($ Type== "LinuxCOE") {116 open(PXE, ">> $pxe/01-$mac") || die "Unable to open $pxe/01-$mac for writing"; 117 if ($opt{'type'} == "LinuxCOE") { 132 118 print PXE "label linuxcoe\n"; 133 119 print PXE " kernel linuxcoe/$k\n"; … … 139 125 } 140 126 close(PXE); 141
