Changeset 59 for devel/dploy-pxe/bin/dploy-add2pxe
- Timestamp:
- 06/02/08 19:14:30 (4 years ago)
- File:
-
- 1 edited
-
devel/dploy-pxe/bin/dploy-add2pxe (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
devel/dploy-pxe/bin/dploy-add2pxe
r53 r59 18 18 use Dploy::Base; 19 19 20 my %opts; 21 my $url = undef; 22 my $ksdevice = "eth0"; 23 my $prefix = undef; 20 =pod 21 22 =head1 NAME 23 24 dploy-add2pxe - Update PXE configuration file for dploy.org 25 26 =head1 DESCRIPTION 27 28 dploy-add2pxe helps you keeping your PXE configuration up to date 29 30 =head1 SYNOPSIS 31 32 dploy-add2pxe -t mondorescue|linuxcoe -m MAC-address -u ISO-image-URL 33 34 dploy-add2pxe --type mondorescue|linuxcoe --mac MAC-address --url ISO-image-URL 35 36 =head1 OPTIONS 37 38 =over 4 39 40 =item B<-h|--help> 41 42 Print a brief help message and exits. 43 44 =cut 45 46 47 my %opts; # GetOpt Hash 48 my $url = undef; # url of the boot ISO image 49 my $ksdevice = "eth0"; # NIC device to boot on 50 my $prefix = undef; # Prefix of the MondoRescue image 51 my $cliparams; # Command Line parames of the MondoRescue image 52 my $destdir = undef; # Destination driectory for tftp files 24 53 25 54 pb_syntax_init("dploy-add2pxe Version PBVER-PBREV\n"); … … 35 64 } 36 65 37 pb_conf_add("PBCONF/dploy.conf"); 66 # type is always lowercase 67 $opts{'type'} = lc($opts{'type'}); 68 69 my $dploydir = "PBCONF"; 70 pb_conf_add("$dploydir/dploy.conf"); 38 71 39 72 # Root of the PXE setup 40 my $pxe=pb_conf_get("pathpxe");73 my ($pxe)=pb_conf_get("pathpxe"); 41 74 my $pathpxe = $pxe->{"default"}; 42 75 … … 52 85 53 86 # Get the ID given by LinuxCOE/MondoRescue to prepare kernel/initrd/ks 54 my $iso=basename($ url);87 my $iso=basename($opts{'url'}); 55 88 my $id=$iso; 56 89 $id =~ s/img([0-9]+)\.iso/$1/; 57 90 my $k="k-$id"; 58 91 my $i="i-$id"; 59 my $ks=$ url;92 my $ks=$opts{'url'}; 60 93 $ks =~ s/img([0-9]+)\.iso/ks$1.cfg/; 61 94 62 95 # mount the ISO to get kernel and initrd 63 96 mkdir "$mnt",0755; 64 if ($opts{'type'} = = "LinuxCOE") {97 if ($opts{'type'} =~ /linuxcoe/) { 65 98 my $bn = basename($mrpath); 66 99 unlink("$ENV{'PBTMP'}/$bn"); 67 pb_system("cd \$PBTMP ; wget $ url","Downloading $url");100 pb_system("cd \$PBTMP ; wget $opts{'url'}","Downloading $opts{'url'}"); 68 101 pb_system("sudo /bin/mount -o loop $ENV{'PBTMP'}/$bn $mnt","Mounting $bn"); 69 } elsif ($opts{'type'} = = "MondoRescue") {102 } elsif ($opts{'type'} =~ /mondorescue/) { 70 103 pb_system("sudo /bin/mount -t nfs $mrserver:$mrpath $mnt2","Mountig NFS $mrserver:$mrpath"); 71 104 pb_system("sudo /bin/mount -o loop $mnt2/$prefix-1.iso $mnt","Mounting LOOP $mnt2/$prefix-1.iso"); … … 76 109 77 110 # Install script will have to check (and create if not existing) /tftpboot/tmp 78 copy("$mnt/isolinux/vmlinuz","$pathpxe/../tmp/$k") or die "Copy failed: $!"; 79 copy("$mnt/isolinux/initrd.img","$pathpxe/../tmp/$i") or die "Copy failed: $!"; 111 # $pathpxe is normaly setup correctly by package install 112 $destdir = "$pathpxe/../$opts{'type'}"; 113 copy("$mnt/isolinux/vmlinuz","$destdir/$k") or die "Copy of $mnt/isolinux/vmlinuz to $destdir/$k failed: $!"; 114 copy("$mnt/isolinux/initrd.img","$destdir/$i") or die "Copy of $mnt/isolinux/initrd.img to $destdir/$i failed: $!"; 80 115 81 116 # Get the Command Line parameters for MondoRescue restoration 82 my $cliparams; 83 open(ISOLINUX, "$mnt/isolinux.cfg") || die "Unable to open $mnt/isolinux.cfg for writing"; 84 while ( <ISOLINUX> ) { 85 if (/label nuke/) { 86 $cliparams = <ISOLINUX>; # kernel line 87 $cliparams = <ISOLINUX>; # append line 117 if ($opts{'type'} =~ /MondoRescue/i) { 118 open(ISOLINUX, "$mnt/isolinux.cfg") || die "Unable to open $mnt/isolinux.cfg for writing"; 119 while ( <ISOLINUX> ) { 120 if (/label nuke/) { 121 $cliparams = <ISOLINUX>; # kernel line 122 $cliparams = <ISOLINUX>; # append line 123 } 88 124 } 125 $cliparams =~ s/initrd=[A-z.] /initrd=mondorescue\/$i /; 126 close ISOLINUX; 89 127 } 90 $cliparams =~ s/initrd=[a-z.] /initrd=initrd=mondorescue\/$i /;91 128 92 close ISOLINUX;93 129 # All done with ISO image... umounting 94 130 pb_system("sudo /bin/umount $mnt","Umount ISO image"); … … 110 146 111 147 EOF 112 close(PXE);113 148 114 149 # Customize pxe file depending on Job type submited 115 open(PXE, ">> $pathpxe/01-$mac") || die "Unable to open $pathpxe/01-$mac for writing"; 116 if ($opts{'type'} == "LinuxCOE") { 117 print PXE "label linuxcoe\n"; 118 print PXE " kernel linuxcoe/$k\n"; 119 print PXE " append ksdevice=$ksdevice ks=$ks initrd=linuxcoe/$i text\n"; 150 if ($opts{'type'} =~ /linuxcoe/) { 151 print PXE << "EOF"; 152 label linuxcoe 153 kernel linuxcoe/$k 154 append ksdevice=$ksdevice ks=$ks initrd=linuxcoe/$i text 155 EOF 120 156 } else { 121 print PXE "label mondorescue\n"; 122 print PXE " kernel mondorescue/$k\n"; 123 print PXE " append $cliparams pxe prefix=$prefix ipconf=$ksdevice:dhcp nfsmount=$mrserver:$mrpath\n"; 157 print PXE << "EOF"; 158 label mondorescue 159 kernel mondorescue/$k 160 append $cliparams pxe prefix=$prefix ipconf=$ksdevice:dhcp nfsmount=$mrserver:$mrpath 161 EOF 124 162 } 125 163 close(PXE);
Note: See TracChangeset
for help on using the changeset viewer.
