summaryrefslogtreecommitdiffstats
path: root/pxe_wizard
diff options
context:
space:
mode:
Diffstat (limited to 'pxe_wizard')
-rw-r--r--pxe_wizard/Pxe.pm152
1 files changed, 129 insertions, 23 deletions
diff --git a/pxe_wizard/Pxe.pm b/pxe_wizard/Pxe.pm
index d53f1968..55e1baf8 100644
--- a/pxe_wizard/Pxe.pm
+++ b/pxe_wizard/Pxe.pm
@@ -64,6 +64,8 @@ my $o = {
IMGTOMODIFY => '',
IP => '127.0.0.1',
DIR => '/var/install/',
+ ALLRDZ => '/mnt/cdrom/isolinux/alt0/all.rdz',
+ VMLINUZ => '/mnt/cdrom/isolinux/alt0/vmlinuz',
i => '',
},
needed_rpm => [ 'pxe', 'tftp-server', 'xinetd' ],
@@ -80,6 +82,7 @@ my %level = (
2 => N("Add boot image in PXE"),
3 => N("Remove boot image in PXE"),
4 => N("Modify boot image in PXE"),
+ 5 => N("Add all.rdz image in PXE"),
);
@@ -109,13 +112,15 @@ $o->{pages} = {
},
post => sub {
-f "$X86/drakwizard_pxe" or return 'error_needpxe';
- @list_menu or return 'addimg';
+# @list_menu or return 'addimgrdz' ;
if ($o->{var}{wiz_level} == 2) {
return 'addimg' }
elsif ($o->{var}{wiz_level} == 3) {
return 'removeimg' }
elsif ($o->{var}{wiz_level} == 4) {
return 'modifyimg' }
+ elsif ($o->{var}{wiz_level} == 5) {
+ return 'addimgrdz' }
},
data => [
{ label => N("What do you want to do:"), val => \$o->{var}{wiz_level}, list => [ keys %level ], format => sub { $level{$_[0]} } },
@@ -133,6 +138,17 @@ $o->{pages} = {
post => \&test_data,
next => 'summaryadd',
},
+ addimgrdz => {
+ name => N("Add a boot image") . "\n\n" . N("Path to all.rdz: full path to all.rdz image") . "\n\n" . N("PXE name: name in PXE menu (one wo\rd/number, no space please)"),
+ data => [
+ { label => "PXE name:", val => \$o->{var}{PXENAME} },
+ { label => "PXE description:", val => \$o->{var}{DESCR} },
+ { label => "Full path to all.rdz image:", val => \$o->{var}{ALLRDZ} },
+ { label => "Full path to vmlinuz:", val => \$o->{var}{VMLINUZ} },
+ ],
+ post => \&test_datardz,
+ next => 'summaryaddrdz',
+ },
removeimg => {
name => N("Remove a boot image") . "\n\n" . N("Choose PXE boot image you want to remove from PXE server."),
data => [
@@ -178,10 +194,18 @@ $o->{pages} = {
name => N("Please provide a bootable image..."),
next => 'addimg',
},
+ error_imgrdz => {
+ name => N("Please provide a bootable image..."),
+ next => 'addimgrdz',
+ },
error_path_img => {
name => N("Please choose an image from a different directory than %s.", $IMGPATH),
next => 'addimg',
},
+ error_path_imgrdz => {
+ name => N("Please choose an image from a different directory than %s.", $IMGPATH),
+ next => 'addimgrdz',
+ },
error_name => {
name => N("Please provide a correct name in PXE entry (one word)."),
next => 'addimg',
@@ -194,6 +218,10 @@ $o->{pages} = {
name => N("Similar name is already used in PXE menu entry") . "\n\n" . N("Please provide another PXE Menu name"),
next => 'addimg',
},
+ simmilar_entryrdz => {
+ name => N("Similar name is already used in PXE menu entry") . "\n\n" . N("Please provide another PXE Menu name"),
+ next => 'addimgrdz',
+ },
summaryserver => {
name => N("Now will prepare all default files to set the PXE server"),
data => [
@@ -239,6 +267,17 @@ $o->{pages} = {
post => \&do_it_add,
next => 'endadd',
},
+ summaryaddrdz => {
+ name => N("Now will add your PXE boot image"),
+ data => [
+ { label => "PXE name:", fixed_val => \$o->{var}{PXENAME} },
+ { label => "PXE description:", fixed_val => \$o->{var}{DESCR} },
+ { label => "Full path to all.rdz image:", fixed_val => \$o->{var}{ALLRDZ} },
+ { label => "Full path to vmlinuz:", fixed_val => \$o->{var}{VMLINUZ} },
+ ],
+ post => \&do_it_addrdz,
+ next => 'endadd',
+ },
endadd => {
name => N("Congratulations"),
data => [ { label => N("The wizard successfully add a PXE boot image.") } ],
@@ -303,6 +342,19 @@ sub test_data {
}
}
+sub test_datardz {
+ $o->{var}{PXENAME} =~ /^\w+$/ or return 'error_name';
+ if (!-f $o->{var}{ALLRDZ}) {
+ return 'error_imgrdz'
+ }
+ if (!-f $o->{var}{VMLINUZ}) {
+ return 'error_imgrdz'
+ }
+ if (any { /^$o->{var}{PXENAME}/ } cat_($PXEHELP)) {
+ return 'simmilar_entryrdz'
+ }
+}
+
# enable tftp server
sub enable_tftps {
substInFile { s/disable.*/disable = no/ } "$XINETDDIR/tftp";
@@ -326,7 +378,7 @@ sub crea_wdir {
mkdir_p($TMPDIR);
}
-# add TAGGED entry in PXE menu
+# add TAGGED entry in PXE menu
sub add_in_default {
my ($NAME) = @_;
if (!any { /${NAME}_BEGIN/ } cat_($PXEDEFAULT)) {
@@ -340,6 +392,20 @@ EOF
}
}
+sub add_in_defaultrdz {
+ my ($NAME) = @_;
+ if (!any { /${NAME}_BEGIN/ } cat_($PXEDEFAULT)) {
+ append_to_file($PXEDEFAULT, <<EOF);
+# TAG: ${NAME}_BEGIN
+label $NAME
+ KERNEL images/vmlinuz-$NAME
+ APPEND initrd=images/$NAME.rdz
+# TAG: ${NAME}_END
+EOF
+ }
+}
+
+
# add entry in Help.txt of PXE
sub add_in_help {
my ($NAME, $DESCR) = @_;
@@ -355,6 +421,14 @@ sub add_img {
cp_af($SIMG, $IMGPATH . "/" . $PXENAME . '.img');
}
+sub add_imgrdz {
+ my ($SIMG, $VM, $PXENAME) = @_;
+ !member($SIMG, "tfptboot") or return 'error_path_img';
+ cp_af($SIMG, "$IMGPATH/$PXENAME.rdz");
+ cp_af($VM, "$IMGPATH/$VM-$PXENAME");
+}
+
+
# remove entry in PXE menu
sub remove_in_menu {
my ($NAME) = @_;
@@ -374,7 +448,13 @@ sub remove_in_help {
sub remove_img {
my ($NAME) = @_;
- rm_rf($IMGPATH . "/" . $NAME . '.img');
+ if (-f "$IMGPATH/$NAME.img") {
+ rm_rf($IMGPATH . "/" . $NAME . '.img')
+ }
+ if (-f "$IMGPATH/vmlinuz-$NAME") {
+ rm_rf("$IMGPATH/vmlinuz-$NAME");
+ rm_rf("$IMGPATH/$NAME.rdz");
+ }
}
sub save_config {
@@ -437,6 +517,13 @@ sub do_it_add {
add_img($o->{var}{IMG}, $o->{var}{PXENAME});
}
+sub do_it_addrdz {
+ return if $::testing;
+ add_in_help($o->{var}{PXENAME}, $o->{var}{DESCR});
+ add_in_defaultrdz($o->{var}{PXENAME});
+ add_imgrdz($o->{var}{ALLRDZ}, $o->{var}{VMLINUZ}, $o->{var}{PXENAME});
+}
+
# main remove image
sub do_it_remove {
return if $::testing;
@@ -447,29 +534,40 @@ sub do_it_remove {
# 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 2>/dev/null");
- 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 =~ m!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);
+ my $IMG = $o->{var}{IMGTOMODIFY};
+ # detect if need loop or just add option to APPEND line
+ if (-f "$IMGPATH/$IMG.img") {
+ my $mount = "/tmp/loop_for_images";
+ mkdir_p($mount);
+ system("mount $IMGPATH/$IMG.img $mount -o loop 2>/dev/null");
+ 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 =~ m!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);
+ }
+ } else {
+ my $line = cat_($PXEDEFAULT);
+ $o->{var}{i} = "$IMGPATH/$IMG.rdz";
+ ($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 =~ m!APPEND initrd=images/$IMG.rdz automatic=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)!;
}
}
+
# modify default boot option of an image
sub do_it_modify {
- 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";
+ my $IMG = $o->{var}{IMGTOMODIFY};
+ my ($METHOD, $ETH, $IP, $DIR, $RAM, $VGA, $ACPI, $APIC) = ($o->{var}{METHOD}, $o->{var}{ETH}, $o->{var}{IP}, $o->{var}{DIR}, $o->{var}{RAM}, $o->{var}{VGA}, $o->{var}{ACPI}, $o->{var}{APIC});
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);
+ if (-f "$IMGPATH/$IMG.img") {
+ $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
@@ -482,12 +580,20 @@ label linux
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);
+ system("umount $mount");
+ if (-e $mount) {
+ rm_rf($mount);
+ }
+ } else {
+ $o->{var}{i} = "$IMGPATH/$IMG.rdz";
+ print "je suis la\n";
+ substInFile {
+ s!APPEND initrd=images/$IMG.rdz!APPEND initrd=images/$IMG.rdz automatic=method:$METHOD,interface:$ETH,network:dhcp,server:$IP,directory:$DIR ramdisk_size=$RAM root=/dev/ram3 rw vga=$VGA acpi=$ACPI $APIC!m;
+ } $PXEDEFAULT;
}
}
+
sub pxe_conf {
if (!-f "$pxeconf.orig") { cp_af($pxeconf, "$pxeconf.orig") }
substInFile {