summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2004-01-16 10:39:51 +0000
committerAntoine Ginies <aginies@mandriva.com>2004-01-16 10:39:51 +0000
commit96dbb444b37795f5169db4352b0a210e899600c3 (patch)
tree2a127e018a4bfdccb5bcf9b319f4a10388286020
parentc217f8e5de5e70796ede9b4c7fcfc9c72b1df56f (diff)
downloaddrakwizard-96dbb444b37795f5169db4352b0a210e899600c3.tar
drakwizard-96dbb444b37795f5169db4352b0a210e899600c3.tar.gz
drakwizard-96dbb444b37795f5169db4352b0a210e899600c3.tar.bz2
drakwizard-96dbb444b37795f5169db4352b0a210e899600c3.tar.xz
drakwizard-96dbb444b37795f5169db4352b0a210e899600c3.zip
- can modify option in boot img
- read old conf in boot disk - drakwizard now loop for add/remove/modify img (R1)
-rw-r--r--pxe_wizard/Pxe.pm133
1 files changed, 108 insertions, 25 deletions
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 <aginies _ateuh _ mandrakesoft.com>
@@ -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 ,<<EOF);
@@ -271,18 +307,13 @@ $NAME : $DESCR
EOF
}
+# add bootable image in correct place
sub add_img {
my ($SIMG, $PXENAME) = @_;
cp_af($SIMG, $IMGPATH . "/" . $PXENAME . '.img');
}
-sub get_menu_entry {
- my ($NAME) = @_;
- my $conf = cat_($PXEDEFAULT) . "#EndOfFile";
- my ($NAME_bloc) = $conf =~ /(# TAG: ${NAME}_BEGIN.*?# TAG: ${NAME}_END)#EndOfFile/s or die "unable to find Menu entry section";
- print "$NAME_bloc";
-}
-
+# remove entry in PXE menu
sub remove_in_menu {
my ($NAME) = @_;
my $conf = cat_($PXEDEFAULT) . "#EndOfFile";
@@ -290,6 +321,7 @@ sub remove_in_menu {
output($PXEDEFAULT, $begin, $end);
}
+# get list of available PXE boot images
sub list_menu {
my @list_menu;
foreach (cat_($PXEDEFAULT)) {
@@ -299,6 +331,7 @@ sub list_menu {
@list_menu;
}
+# remove entry in help.txt
sub remove_in_help {
my ($NAME) = @_;
substInFile {
@@ -311,13 +344,23 @@ sub remove_img {
rm_rf($IMGPATH . "/" . $NAME . '.img');
}
+sub save_config {
+ my ($FILE) = @_;
+ if (!-f "$FILE.ori") {
+ cp_af($FILE, "$FILE.ori");
+ }
+}
+
+# set default help.txt file
sub default_pxe_menu {
+ save_config($PXEHELP);
output($PXEHELP, <<EOF);
Available images are:
---------------------
local: local boot
EOF
+ save_config($PXEDEFAULT);
output($PXEDEFAULT, <<EOF);
PROMPT 1
DEFAULT local
@@ -330,7 +373,9 @@ label local
EOF
}
+# set default pxe messages
sub default_pxe_messages {
+ save_config($PXEMESSAGE);
output($PXEMESSAGE, <<EOF);
Welcome to Mandrake Linux PXE Server
@@ -351,6 +396,7 @@ EOF
}
+# main add image in PXE menu
sub do_it_add {
return if $::testing;
add_in_help($o->{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", <<EOF);
+default linux
+prompt 1
+timeout 72
+display boot.msg
+F1 help.msg
+F2 advanced.msg
+F3 boot.msg
+label linux
+ kernel vmlinuz
+ append initrd=network.rdz automatic=method:$METHOD,interface:$ETH,network:dhcp,server:$IP,directory:$DIR ramdisk_size=$RAM root=/dev/ram3 rw vga=$VGA acpi=$ACPI $APIC
+EOF
+
+ system("umount $mount");
+ if (-e $mount) {
+ rm_rf($mount);
+ }
}
+# set PXE server
sub do_it_pxe {
return if $::testing;
my $in = 'interactive'->vnew('su', 'PXE server');