summaryrefslogtreecommitdiffstats
path: root/drakpxelinux.pl
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2004-08-06 02:52:33 +0000
committerAntoine Ginies <aginies@mandriva.com>2004-08-06 02:52:33 +0000
commit41c95b46e7b57f78c7c4b8cbd501fb1da06d3481 (patch)
tree7165089ad17df6e9eaed9050f6daf9b92b3cb022 /drakpxelinux.pl
parent6896d3fc03274d41142d389b204f6f648a23ace8 (diff)
downloaddrakpxelinux-41c95b46e7b57f78c7c4b8cbd501fb1da06d3481.tar
drakpxelinux-41c95b46e7b57f78c7c4b8cbd501fb1da06d3481.tar.gz
drakpxelinux-41c95b46e7b57f78c7c4b8cbd501fb1da06d3481.tar.bz2
drakpxelinux-41c95b46e7b57f78c7c4b8cbd501fb1da06d3481.tar.xz
drakpxelinux-41c95b46e7b57f78c7c4b8cbd501fb1da06d3481.zip
fix button display
add help.txt support fix wizard add label
Diffstat (limited to 'drakpxelinux.pl')
-rw-r--r--drakpxelinux.pl165
1 files changed, 114 insertions, 51 deletions
diff --git a/drakpxelinux.pl b/drakpxelinux.pl
index ea720ad..270b161 100644
--- a/drakpxelinux.pl
+++ b/drakpxelinux.pl
@@ -38,9 +38,10 @@ use constant TRUE => 1;
# KERNEL images/vmlinuz
# APPEND initrd=images/all.rdz automatic=method:http,interface:eth0,network:dhcp,server:10.0.1.33,directory:/install/ ramdisk_size=64000 root=/dev/ram3 rw vga=788 display=:0
+
+
my $conf = "/var/lib/tftpboot/X86PC/linux/pxelinux.cfg/default";
#my $conf = "/tmp/tr";
-my $pxeconf = "/etc/pxe.conf";
my $HOSTNAME = chomp_(`hostname`);
my $TFTPDIR = "/var/lib/tftpboot";
my $CLIENTPATH = '/X86PC/linux';
@@ -74,7 +75,7 @@ VGA: if you encounter any problem with VGA, please adjust
my $date = chomp_(`date +%d-%m-20%y`);
if (!-f $conf) {
- err_dialog("Error !", "missing $conf\n\nPlease install pxe package.") and die;
+ err_dialog(N("Error !", "missing $conf\n\nPlease install pxe package.")) and die;
} else {
cp_af($conf, "$conf-$date");
}
@@ -118,7 +119,6 @@ sub get_items() {
$network or my ($networ) = m!\bnetwork\b:(dhcp|10.0.1.33)!;
$server or my ($serve) = m!\bserver\b:(.*?),!;
$directory or my ($director) = m!\bdirectory\b:(.*?)\s!;
- my $information = "$label $automati";
my $initall; my $ramdiskall; my $autoall; my $vgaall; my $displayall; my $interfaceall; my $networkall; my $serverall; my $directoryall;
if ($initrd) { $initall = $initrd } else { $initall = $init }
if ($ramdisk) { $ramdiskall = $ramdisk } else { $ramdiskall = $ramdis }
@@ -133,7 +133,9 @@ sub get_items() {
my ($autocomp) = m!\bautomatic\b=(.*?)\s!;
my ($devram) = m!root=/dev/ram3\srw!;
my $optionsall = join(' ', grep { ! /$devram/ and ! /initrd=$initall/ and ! /display=$displayall/ and ! /ramdisk_size=$ramdiskall/ and ! /automatic=$autocomp/ and ! /vga=$vgaall/ } split(' ', $allopt));
-
+ my $information;
+ foreach (cat_($PXEHELP)) { my ($information) = /$label\s:\s(\.*)/; }
+# my ($information) = cat_($PXEHELP) =~ /$label\s:\s(\.*)/;# or my $information = "install $label";
if ($label and $kernel and $initall) {
push @listpxe, {
label => $label,
@@ -191,7 +193,7 @@ sub write_conf_pxe {
my $prompt = get_default_prompt;
my $time = get_default_timeout;
output($conf, <<EOF);
-# DO NOT EDIT auto_generated by drakpxe2.pl
+# DO NOT EDIT auto_generated by drakpxelinux.pl
PROMPT 10
DEFAULT $default
DISPLAY messages
@@ -249,7 +251,7 @@ sub create_model {
}
sub add_item {
- my ($button, $model) = @_;
+ my ($model, $treeview) = @_;
my @a;
push @a, {
label => "cooker",
@@ -283,11 +285,12 @@ sub add_item {
COLUMN_DISPLAY, $a[-1]{display},
COLUMN_OPTION, $a[-1]{option},
);
-# write_conf_pxe;
+# edit_box_item($model, $treeview, "-1");
}
sub remove_item {
my ($widget, $treeview) = @_;
+ $::isWizard = 0;
my $model = $treeview->get_model;
my $selection = $treeview->get_selection;
my $iter = $selection->get_selected;
@@ -297,12 +300,14 @@ sub remove_item {
ask_okcancel("Remove $listpxe[$i]{label} PXE entry ?") or return;
$model->remove($iter);
splice @listpxe, $i, 1;
+ remove_in_help($listpxe[$i]{label});
+ write_conf_pxe;
}
- write_conf_pxe;
}
sub edit_box_item {
- my ($widget, $treeview) = @_;
+ my ($widget, $treeview, $indice) = @_;
+ $::isWizard = 0;
my $model = $treeview->get_model;
my $selection = $treeview->get_selection;
@@ -324,7 +329,7 @@ sub edit_box_item {
my $kernel = Gtk2::Entry->new;
$kernel->set_text($listpxe[$i]{kernel});
# file selection for kernel
- my $file_dialogk = new Gtk2::FileSelection("File Selection");
+ my $file_dialogk = new Gtk2::FileSelection(N("File Selection"));
$file_dialogk->set_modal(TRUE);
$file_dialogk->signal_connect("destroy", sub { $file_dialogk->hide });
$file_dialogk->ok_button->signal_connect(clicked => sub {
@@ -334,13 +339,13 @@ sub edit_box_item {
}, $file_dialogk);
$file_dialogk->cancel_button->signal_connect(clicked => sub { $file_dialogk->hide });
# button kernel
- my $buttonkernel = Gtk2::Button->new("Select kernel");
+ my $buttonkernel = Gtk2::Button->new(N("Select kernel"));
$buttonkernel->signal_connect(clicked => sub { $file_dialogk->show });
my $initrd = Gtk2::Entry->new;
$initrd->set_text($listpxe[$i]{initrd});
# file selection for initrd
- my $file_dialog = new Gtk2::FileSelection("File Selection");
+ my $file_dialog = new Gtk2::FileSelection(N("File Selection"));
$file_dialog->set_modal(TRUE);
$file_dialog->signal_connect("destroy", sub { $file_dialog->hide });
$file_dialog->ok_button->signal_connect(clicked => sub {
@@ -396,19 +401,19 @@ sub edit_box_item {
};
gtkpack_($dialog->vbox,
- 0, gtkadd(Gtk2::Frame->new(("Descrition")),
+ 0, gtkadd(Gtk2::Frame->new(N("Descrition")),
gtkpack_(gtkset_border_width(Gtk2::VBox->new, 3),
0, $label_and_widgets->(N("Label"), $label, ""),
0, $label_and_widgets->(N("Info"), $info, ""),
),
),
- 0, gtkadd(Gtk2::Frame->new(("Boot image")),
+ 0, gtkadd(Gtk2::Frame->new(N("Boot image")),
gtkpack_(gtkset_border_width(Gtk2::VBox->new, 3),
0, $label_and_widgets->(N("Kernel"), $kernel, $buttonkernel),
0, $label_and_widgets->(N("Initrd"), $initrd, $buttoninitrd),
),
),
- 0, gtkadd(Gtk2::Frame->new(("Automatic Options")),
+ 0, gtkadd(Gtk2::Frame->new(N("Automatic Options")),
gtkpack_(gtkset_border_width(Gtk2::VBox->new, 3),
0, $label_and_widgets->(N("Automatic"), $automatic, ""),
0, $label_and_widgets->(N("Interface"), $interface, ""),
@@ -417,13 +422,13 @@ sub edit_box_item {
0, $label_and_widgets->(N("Directory"), $directory, ""),
),
),
- 0, gtkadd(Gtk2::Frame->new(("Display")),
+ 0, gtkadd(Gtk2::Frame->new(N("Display")),
gtkpack_(gtkset_border_width(Gtk2::VBox->new, 3),
0, $label_and_widgets->(N("Vga"), $vga, ""),
0, $label_and_widgets->(N("Display"), $display, ""),
),
),
- 0, gtkadd(Gtk2::Frame->new(("Other options")),
+ 0, gtkadd(Gtk2::Frame->new(N("Other options")),
gtkpack_(gtkset_border_width(Gtk2::VBox->new, 3),
0, $label_and_widgets->(N("Ramdisk"), $ramdisk, ""),
0, $label_and_widgets->(N("Option"), $option, ""),
@@ -465,6 +470,7 @@ sub edit_box_item {
);
$dialog->destroy;
write_conf_pxe;
+ add_in_help($listpxe[$i]{label}, $listpxe[$i]{info});
},
},
),
@@ -473,6 +479,37 @@ sub edit_box_item {
}
}
+# add in help.txt
+sub add_in_help {
+ my ($NAME, $DESCR) = @_;
+ if (!any { /$NAME/ } cat_($PXEHELP)) {
+ append_to_file($PXEHELP, <<EOF);
+$NAME : install $DESCR
+EOF
+
+ } else {
+ substInFile {
+ s/$NAME.*/$NAME : $DESCR/;
+ } $PXEHELP;
+ }
+}
+
+sub change_label_in_help {
+ my ($NAMEOLD, $NEWNAME) = @_;
+ substInFile {
+ s/$NAMEOLD\s(.*)/$NEWNAME $1/;
+ } $PXEHELP;
+}
+
+# remove entry in help.txt
+sub remove_in_help {
+ my ($NAME) = @_;
+ substInFile {
+ s/^$NAME\s:.*//x;
+ s/^\s*$//;
+ } $PXEHELP;
+}
+
sub cell_edited {
my ($cell, $path_string, $new_text, $model) = @_;
my $path = Gtk2::TreePath->new_from_string($path_string);
@@ -481,6 +518,9 @@ sub cell_edited {
if ($column == COLUMN_LABEL) {
my $i = ($path->get_indices)[0];
+ my $oldname = $listpxe[$i]{label};
+ my $newname = $new_text;
+ change_label_in_help($oldname, $newname);
$listpxe[$i]{label} = $new_text;
$model->set($iter, $column, $listpxe[$i]{label});
} elsif ($column == COLUMN_INFO) {
@@ -569,15 +609,15 @@ sub pxe_conf {
}
sub wizard_pxe_server {
- my $in = 'interactive'->vnew('su');
local $::isEmbedded = 0;
+ my $in = 'interactive'->vnew('su');
+ undef $::WizardTable;
+ undef $::WizardWindow;
$::isWizard = 1;
use wizards;
my $w = wizards->new;
my $wiz = {
- defaultimage => "logdrake.png",
name => N("PXE Wizard"),
- needed_rpm => [ 'pxe', 'tftp-server', 'xinetd' ],
init => sub {
if (member($DOMAINNAME, qw(localdomain (none)))) {
return 0, N("You need to readjust your domainname, not equal to localdomain or none. Please launch drakconnect to adjust it.")
@@ -591,17 +631,19 @@ sub wizard_pxe_server {
},
pxeserver => {
name => N("Set PXE server") . "\n\n" . N("We need to use a special dhcpd.conf file with PXE parameter. To set up such a DHCP server, launch the DHCP wizard and check the box 'Enable \PXE'. If you don't do that, PXE query will not be answered by this server.") . "\n" . N("Now the wizard will configure all needed default configuration files to allow computers to boot through the network."),
+ no_back => 1,
next => 'summaryserver',
},
summaryserver => {
name => N("The wizard will now prepare all default files to set your PXE server"),
data => [
- { label => N("TFTP directory:"), fixed_val => \$TFTPDIR },
- { label => N("Boot image path:"), fixed_val => \$IMGPATH },
- { label => N("PXE 'default' file:"), fixed_val => \$pxeconf },
- { label => N("PXE 'help' file:"), fixed_val => \$PXEHELP },
+ { label => N("TFTP directory:"), val => \$TFTPDIR },
+ { label => N("Boot image path:"), val => \$IMGPATH },
+ { label => N("PXE 'default' file:"), val => \$pxeconf },
+ { label => N("PXE 'help' file:"), val => \$PXEHELP },
],
post => \&do_it_pxe,
+ no_back => 1,
next => 'endserver',
},
endserver => {
@@ -613,8 +655,20 @@ sub wizard_pxe_server {
},
},
};
+ $w->process($wiz, $in);
+}
+
+sub save_config {
+ my ($old) = @_;
+ my $DATE = chomp_(`date +%d-%m-20%y`);
+ if (-f $old) {
+ print " - Backup of $old configuration\n";
+ cp_af($old, $old . '.' . $DATE);
+ }
+ return($old . '.' . $DATE);
}
+
sub default_pxe_messages {
save_config($PXEMESSAGE);
output($PXEMESSAGE, <<EOF);
@@ -643,18 +697,6 @@ Available images are:
---------------------
local: local boot
EOF
-
- save_config($pxeconf);
- output($pxeconf, <<EOF);
-PROMPT 1
-DEFAULT local
-DISPLAY messages
-TIMEOUT 50
-F1 help.txt
-label local
- LOCALBOOT 0
-
-EOF
}
sub tftp_blksize {
@@ -667,12 +709,24 @@ sub tftp_blksize {
}
}
+sub enable_tftps {
+ substInFile { s/disable.*/disable = no/ } "$XINETDDIR/tftp";
+}
+
sub memlinux_prep {
if (!-f "$X86/memdisk") {
cp_af($MEMDISK, $X86);
}
}
+sub check_started {
+ my ($service) = @_;
+ my ($isrunning) = chomp_(`pidof $service`) =~ /(\d+)/m;
+ if (!$isrunning) {
+ return 1;
+ }
+}
+
sub do_it_pxe {
return if $::testing;
my $in = 'interactive'->vnew('su', 'PXE server');
@@ -750,26 +804,35 @@ my $okcancel = create_okcancel({
;
$okcancel ="" unless $::isEmbedded;
-
$W->add(gtkpack_(Gtk2::VBox->new(0,0),
0, $banner,
1, create_scrolled_window($treeview),
0, gtkpack_(gtkset_border_width(Gtk2::HBox->new, 3),
+ 0, Gtk2::Label->new(N("default boot:")),
0, $labels,
- 0, gtksignal_connect(Gtk2::Button->new("set PXE server"), clicked => sub {
- \&wizard_pxe_server; }),
- 0, gtkpack(gtkset_layout(new Gtk2::HButtonBox, 'spread'),
- 0, (map {
- my ($label, $sub, $widg) = @$_;
- gtksignal_connect(Gtk2::Button->new($label), clicked => sub {
- $sub->($model, $widg); }),
- } ([ ("Help"), \&show_help ],
- [ ("Add a PXE entry"), \&add_item, $model ],
- [ ("Remove PXE entry"), \&remove_item, $treeview ],
- [ ("Edit a PXE entry"), \&edit_box_item, $treeview ],
- )
- ),
- ),
+ 0, gtksignal_connect(new Gtk2::Button(N("PXE server")),
+ clicked => sub {
+ eval { wizard_pxe_server() };
+ my $err = $@;
+ $::WizardWindow->destroy if defined $::WizardWindow;
+ undef $::WizardWindow;
+ if ($err && $err !~ /wizcancel/) {
+ err_dialog(N("Error"), N("The PXE server wizard had unexpectly failled:")
+ . "\n\n" . $err);
+ }
+ }),
+ 0, gtksignal_connect(new Gtk2::Button(N("Help")),
+ clicked => sub { show_help }
+ ),
+ 0, gtksignal_connect(Gtk2::Button->new(N("Add a PXE entry")), clicked => sub {
+ add_item($model, $treeview); }
+ ),
+ 0, gtksignal_connect(Gtk2::Button->new((N"Remove a PXE entry")), clicked => sub {
+ remove_item($model, $treeview); }
+ ),
+ 0, gtksignal_connect(Gtk2::Button->new(N("Edit a PXE entry")), clicked => sub {
+ edit_box_item($model, $treeview); }
+ ),
),
0, $okcancel,
),