From 96dbb444b37795f5169db4352b0a210e899600c3 Mon Sep 17 00:00:00 2001 From: Antoine Ginies Date: Fri, 16 Jan 2004 10:39:51 +0000 Subject: - can modify option in boot img - read old conf in boot disk - drakwizard now loop for add/remove/modify img (R1) --- pxe_wizard/Pxe.pm | 133 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 108 insertions(+), 25 deletions(-) (limited to 'pxe_wizard') diff --git a/pxe_wizard/Pxe.pm b/pxe_wizard/Pxe.pm index 1a3d2a38..79c2fb63 100644 --- a/pxe_wizard/Pxe.pm +++ b/pxe_wizard/Pxe.pm @@ -1,7 +1,7 @@ #!/usr/bin/perl -w -# Drakwizard - +# Drakwizard PXE +# release 0.2 # Copyright (C) 2003 Mandrakesoft # # Author: Antoine Ginies @@ -48,6 +48,7 @@ my $SYSLINUXPATH = '/usr/lib/syslinux/'; my $MEMDISK = $SYSLINUXPATH . '/memdisk'; my $XINETDDIR = "/etc/xinetd.d"; + my $o = { name => N("PXE Wizard (devel)"), var => { @@ -56,6 +57,9 @@ my $o = { DESCR => 'install 9.2', IMGTOREMOVE => '', IMGTOMODIFY => '', + IP => '127.0.0.1', + DIR => '/var/install/', + i => '', }, needed_rpm => [ 'pxe', 'tftp-server', 'xinetd' ], }; @@ -76,6 +80,23 @@ foreach (cat_($PXEDEFAULT)) { ! $ent or push @list_menu,$ent; } +#set default list for entry in syslinux.cfg +my @list_method = qw(nfs http); +my @list_ram = qw(32000 64000 1280000); +my @list_vga = qw(788 normal 785 791 text); +my @list_acpi = qw(ht force off); +my @list_apic = qw(apic noapic); +my @list_eth = qw(eth0 eth1 eth2); + + +# to get list menu entry +my @list_menu; +foreach (cat_($PXEDEFAULT)) { + my ($ent) = /# TAG: (\w+)_BEGIN/; + ! $ent or push @list_menu,$ent; +} + +#begin of wizard $o->{pages} = { welcome => { name => N("PXE wizard") . "\n\n" . N("Set a PXE server.") . "\n\n" . N("This wizard will help you configuring the PXE server. This configuration will provide a pxe service, and ability to add/remove/modify boot images."), @@ -98,7 +119,7 @@ $o->{pages} = { next => 'pxeserver', }, addimg => { - name => N("Add a boot Image") . "\n\n" . N("Path to image: Full path to image") . "\n\n" . N("PXE Name: Name in PXE menu (one word/number, no space)"), + name => N("Add a boot Image") . "\n\n" . N("Path to image: Full path to image (need network boot image)") . "\n\n" . N("PXE Name: Name in PXE menu (one word/number, no space)"), data => [ { label => "PXE Name:", val => \$o->{var}{PXENAME} }, { label => "PXE Description:", val => \$o->{var}{DESCR} }, @@ -119,18 +140,21 @@ $o->{pages} = { data => [ { label => N("Which one:"), val => \$o->{var}{IMGTOMODIFY}, fixed_list => \@list_menu }, ], + post => \&read_option, next => 'gomodify', }, gomodify => { name => N("Options to add to PXE boot disk"), data => [ - { label => N("Installation method"), val => \$o->{var}{METHOD} }, + { label => N("Image to modify"), fixed_val => \$o->{var}{i} }, { label => N("Server IP"), val => \$o->{var}{IP} }, { label => N("Install directory"), val => \$o->{var}{DIR} }, - { label => N("Ramsize"), val => \$o->{var}{RAM} }, - { label => N("VGA option"), val => \$o->{var}{VGA} }, - { label => N("Acpi option"), val => \$o->{var}{ACPI} }, - { label => N("Apic option"), val => \$o->{var}{APIC} }, + { label => N("Installation method"), val => \$o->{var}{METHOD}, fixed_list => \@list_method }, + { label => N("Network Client Interface"), val => \$o->{var}{ETH}, fixed_list => \@list_eth }, + { label => N("Ramsize"), val => \$o->{var}{RAM}, fixed_list => \@list_ram }, + { label => N("VGA option"), val => \$o->{var}{VGA}, fixed_list => \@list_vga }, + { label => N("Acpi option"), val => \$o->{var}{ACPI}, fixed_list => \@list_acpi }, + { label => N("Apic option"), val => \$o->{var}{APIC}, fixed_list => \@list_apic }, ], next => 'summarymodify', }, @@ -163,6 +187,17 @@ $o->{pages} = { }, summarymodify => { name => N('Now will Modify boot options in image'), + data => [ + { label => N("Image to Modify"), fixed_val => \$o->{var}{i} }, + { label => N("Server IP"), fixed_val => \$o->{var}{IP} }, + { label => N("Install directory"), fixed_val => \$o->{var}{DIR} }, + { label => N("Installation method"), fixed_val => \$o->{var}{METHOD} }, + { label => N("Network Client Interface"), fixed_val => \$o->{var}{ETH} }, + { label => N("Ramsize"), fixed_val => \$o->{var}{RAM} }, + { label => N("VGA option"), fixed_val => \$o->{var}{VGA} }, + { label => N("Acpi option"), fixed_val => \$o->{var}{ACPI} }, + { label => N("Apic option"), fixed_val => \$o->{var}{APIC} }, + ], post => \&do_it_modify, next => 'endmodify', }, @@ -187,23 +222,17 @@ $o->{pages} = { endadd => { name => N('Congratulations'), data => [ { label => N('The wizard successfully add a PXE image.') } ], - no_back => 1, - end => 1, - next => 0 + next => 'welcome', }, endremove => { name => N('Congratulations'), data => [ { label => N('The wizard successfully remove a PXE image.') } ], - no_back => 1, - end => 1, - next => 0 + next => 'welcome', }, endmodify => { name => N('Congratulations'), data => [ { label => N('The wizard successfully modify image(s).') } ], - no_back => 1, - end => 1, - next => 0 + next => 'welcome', }, endserver => { name => N('Congratulations'), @@ -214,12 +243,15 @@ $o->{pages} = { }, }; + +#cp memlinux from syslinux sub memlinux_prep { if (!-f "$X86/memdisk") { cp_af($MEMDISK, $X86); } } +# test img and similar entry in PXE sub test_data { $o->{var}{PXENAME} =~ /^\w+$/ or return 'error_name'; if (!-f $o->{var}{IMG}) { @@ -230,10 +262,12 @@ sub test_data { } } +# enable tftp server sub enable_tftps { substInFile { s/disable.*/disable = no/ } "$XINETDDIR/tftp"; } +# can change option in tftp server sub tftp_blksize { # $o should be with W or not N my ($o) = @_; @@ -251,6 +285,7 @@ sub crea_wdir { mkdir_p($TMPDIR); } +# add TAGGED entry in PXE menu sub add_in_default { my ($NAME) = @_; if (!any { /${NAME}_BEGIN/ } cat_($PXEDEFAULT)) { @@ -264,6 +299,7 @@ EOF } } +# add entry in Help.txt of PXE sub add_in_help { my ($NAME, $DESCR) = @_; append_to_file($PXEHELP ,<{var}{PXENAME}, $o->{var}{DESCR}); @@ -358,6 +404,7 @@ sub do_it_add { add_img($o->{var}{IMG}, $o->{var}{PXENAME}); } +# main remove image sub do_it_remove { return if $::testing; remove_in_menu($o->{var}{IMGTOREMOVE}); @@ -365,14 +412,50 @@ sub do_it_remove { remove_img($o->{var}{IMGTOREMOVE}); } +# get default option for an image sub read_option { + my ($IMG) = $o->{var}{IMGTOMODIFY}; + my $mount = "/tmp/loop_for_images"; + mkdir_p($mount); + system("mount $IMGPATH/$IMG.img $mount -o loop"); + my $line = cat_("$mount/syslinux.cfg"); + $o->{var}{i} = "$IMGPATH/$IMG.img"; + ($o->{var}{METHOD}, $o->{var}{ETH}, $o->{var}{IP}, $o->{var}{DIR}, $o->{var}{RAM}, $o->{var}{VGA}, $o->{var}{ACPI}, $o->{var}{APIC}) = $line =~ /method:(nfs|http),interface:(eth0|eth1|eth2),network:dhcp,server:(.*?),directory:(.*?) ramdisk_size=(.*?) root=\/dev\/ram3 rw vga=(.*?)acpi=(ht|force|off)\s(apic|noapic)/; + system("umount $mount"); + if (-e $mount) { + rm_rf($mount); + } } +# modify default boot option of an image sub do_it_modify { - my ($METHOD , $IP, $DIR, $RAM, $VGA, $ACPI, $APIC) = ($o->{var}{METHOD}, $o->{var}{IP}, $o->{var}{DIR}, $o->{var}{RAM}, $o->{var}{VGA}, $o->{var}{ACPI}, $o->{var}{APIC}); + my ($IMG, $METHOD, $ETH, $IP, $DIR, $RAM, $VGA, $ACPI, $APIC) = ($o->{var}{IMGTOMODIFY}, $o->{var}{METHOD}, $o->{var}{ETH}, $o->{var}{IP}, $o->{var}{DIR}, $o->{var}{RAM}, $o->{var}{VGA}, $o->{var}{ACPI}, $o->{var}{APIC}); + $o->{var}{i} = "$IMGPATH/$IMG.img"; return if $::testing; +#APPEND initrd=images/ken/cooker/i586/isolinux/alt0/all.rdz automatic=method:nfs,interface:eth0,network:dhcp,server:192.168.100.7,directory:/c/cooker ramdisk_size=32000 root=/dev/ram3 rw vga=788 meta_class=discovery + my $mount = "/tmp/loop_for_images"; + mkdir_p($mount); + system("mount $o->{var}{i} $mount -o loop"); + output("$mount/syslinux.cfg", <vnew('su', 'PXE server'); -- cgit v1.2.1