summaryrefslogtreecommitdiffstats
path: root/drakpxelinux.pl
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2004-08-06 15:25:28 +0000
committerAntoine Ginies <aginies@mandriva.com>2004-08-06 15:25:28 +0000
commitae505bfdb7ce9a0ad2b092d54ae8e7759b4ee8fb (patch)
tree58023bde0a4ee0130b4375b622fb26d00ef7d97a /drakpxelinux.pl
parentd91952b5c1a5abee2b432c6b35854ce5f52ceb3c (diff)
downloaddrakpxelinux-ae505bfdb7ce9a0ad2b092d54ae8e7759b4ee8fb.tar
drakpxelinux-ae505bfdb7ce9a0ad2b092d54ae8e7759b4ee8fb.tar.gz
drakpxelinux-ae505bfdb7ce9a0ad2b092d54ae8e7759b4ee8fb.tar.bz2
drakpxelinux-ae505bfdb7ce9a0ad2b092d54ae8e7759b4ee8fb.tar.xz
drakpxelinux-ae505bfdb7ce9a0ad2b092d54ae8e7759b4ee8fb.zip
add tooltips
Diffstat (limited to 'drakpxelinux.pl')
-rw-r--r--drakpxelinux.pl152
1 files changed, 113 insertions, 39 deletions
diff --git a/drakpxelinux.pl b/drakpxelinux.pl
index e7b9b09..e003dd4 100644
--- a/drakpxelinux.pl
+++ b/drakpxelinux.pl
@@ -18,10 +18,11 @@
# 02111-1307, USA.
# Quick configuration of PXE menu parameters
-# release 0.8
# use with care developement release....
# thx R1 for test and some debug
+my $version = "0.9";
+
use lib qw(/usr/lib/libDrakX);
use standalone;
use strict;
@@ -38,6 +39,7 @@ 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
+# default VAR
my $conf = "/var/lib/tftpboot/X86PC/linux/pxelinux.cfg/default";
#my $conf = "/tmp/tr";
my $HOSTNAME = chomp_(`hostname`);
@@ -70,18 +72,42 @@ Display: export display on another computer (ie: 10.0.1.33:0)
VGA: if you encounter any problem with VGA, please adjust
";
-my $date = chomp_(`date +%d-%m-20%y`);
+
+my %help = (
+ 'initrd' => N("network boot image (network.img ) or all.rdz"),
+ 'kernel' => N("memdisk in case of network.img, or vmlinuz"),
+ 'vga' => N("if you encounter any problem with VGA, please adjust"),
+ 'interface' => N("network interface used for the installation process"),
+ 'info' => N("the name displayed in PXE menu (a word/number)"),
+ 'network' => N("dhcp or an IP address"),
+ 'directory' => N("full path to MDK install server directory"),
+ 'automatic' => N("installation method: choose NFS or HTTP"),
+ 'ramsize' => N("ramsize parameter on boot disk"),
+ 'display' => N("export display on another computer (ie: 10.0.1.33:0)"),
+ 'option' => N("apic nolapic acpi=off initrd=/bin/shell"),
+ 'server' => N("IP address of server, which contains installation directory"),
+ 'labels' => N("list all PXE entry, selected one is the default boot"),
+ 'wizardsrv' => N("Launch a wizard to setup a PXE server"),
+ 'editb' => N("Edit the PXE entry selected with a dialog box"),
+ 'removepxe' => N("Remove the PXE entry selected"),
+ 'addpxe' => N("Launch a Wizard to add a PXE entry "),
+ );
+
+sub set_help_tip {
+ my ($entry, $key) = @_;
+ gtkset_tip(new Gtk2::Tooltips, $entry, formatAlaTeX($help{$key}));
+}
if (!-f $conf) {
err_dialog(N("Error !", "missing $conf\n\nPlease install pxe package.")) and die;
} else {
- cp_af($conf, "$conf-$date");
+ save_config($conf);
}
my @listpxe;
my @list_method = qw(nfs http);
my @list_ram = qw(48000 32000 64000 1280000);
-my @list_vga = qw(788 normal 785 791 792 text);
+my @list_vga = qw(normal 785 788 791 794 text);
my @list_eth = qw(eth0 eth1 eth2);
use constant COLUMN_LABEL => 0;
@@ -99,7 +125,7 @@ use constant COLUMN_DISPLAY => 11;
use constant COLUMN_OPTION => 12;
use constant NUM_COLUMNS => 13;
-
+# get all values from default PXE file
sub get_items() {
my $info; my $label; my $kernel; my $initrd;
foreach (cat_($conf)) {
@@ -133,6 +159,7 @@ sub get_items() {
my $optionsall = join(' ', grep { ! /$devram/ and ! /initrd=$initall/ and ! /display=$displayall/ and ! /ramdisk_size=$ramdiskall/ and ! /automatic=$autocomp/ and ! /vga=$vgaall/ } split(' ', $allopt));
if ($label and $kernel and $initall) {
my $information = get_information($label);
+ # now push data in @
push @listpxe, {
label => $label,
info => $information,
@@ -153,6 +180,8 @@ sub get_items() {
}
}
+
+# get info from help.txt
sub get_information {
my ($label) = @_;
my $line = cat_($PXEHELP);
@@ -169,6 +198,7 @@ sub list_label_pxe() {
@labels;
}
+# set new default boot PXE
sub set_new_default {
my ($default) = @_;
substInFile {
@@ -192,6 +222,7 @@ sub get_default_timeout() {
return $time;
}
+# write conf in default file
sub write_conf_pxe {
my $default = get_default_pxe;
my $prompt = get_default_prompt;
@@ -220,6 +251,7 @@ label $a->{label}
KERNEL $a->{kernel}
APPEND initrd=$a->{initrd} automatic=method:$a->{automatic},interface:$a->{interface},network:$a->{network},server:$a->{server},directory:$a->{directory} ramdisk_size=$a->{ramdisk} root=/dev/ram3 rw vga=$a->{vga} display=$a->{display}
");
+ # case of .img image
} else {
append_to_file($conf, "
label $a->{label}
@@ -254,6 +286,7 @@ sub create_model {
return $model;
}
+# wizard to add an entry in PXE menu
sub wizard_add_entry {
my ($widget, $treeview) = @_;
my $model = $treeview->get_model;
@@ -277,12 +310,16 @@ sub wizard_add_entry {
next => 'addimg',
},
addimg => {
- name => N("PXE information is used to explain the rule of the boot image, ie: Mandrake 10 image, Mandrake cooker image..") . "\n\n" . N("Path to all.rdz: provide the full path to all.rdz image source") . "\n\n" . N("PXE label: the name displayed in PXE menu (please provide a word or a number, with no space)") . "\n\n" . N("At the end of this wizard, the all.rdz image and kernel vmlinuz will be copied into \n$IMGPATH"),
+ name => N("At the end of this wizard, the all.rdz image and kernel vmlinuz will be copied into \n$IMGPATH.\n\nPXE menu list will be updated with this new entry"),
data => [
- { label => "PXE label:", val => \$WPXENAME },
- { label => "PXE information:", val => \$WINFO },
- { label => "Full path to all.rdz image source:", val => \$WALLRDZ },
- { label => "Full path to vmlinuz source:", val => \$WVMLINUZ},
+ { label => "PXE label:", val => \$WPXENAME,
+ help => N("name displayed in PXE menu (please provide a word or a number, with no space)") },
+ { label => "PXE information:", val => \$WINFO,
+ help => N("PXE information is used to explain the rule of the boot image,\nie:\nMandrake 10 rescue disk\nMandrake cooker install via http") },
+ { label => "Full path to all.rdz image source:", val => \$WALLRDZ,
+ help => N("Provide the full path to all.rdz image source") },
+ { label => "Full path to vmlinuz source:", val => \$WVMLINUZ,
+ help => N("Provide the full path to vmlinuz kernel source") },
],
complete => sub {
if (any { /^$WPXENAME :/ } cat_($PXEHELP)) {
@@ -350,6 +387,7 @@ sub wizard_add_entry {
$::isWizard = 0;
}
+# remove an entry in PXE menu
sub remove_item {
my ($widget, $treeview) = @_;
$::isWizard = 0;
@@ -388,6 +426,7 @@ sub test_similar_label {
} else { return 1 };
}
+# dialog box to edit a PXE entry
sub edit_box_item {
my ($widget, $treeview) = @_;
$::isWizard = 0;
@@ -410,9 +449,11 @@ sub edit_box_item {
my $info = Gtk2::Entry->new;
$info->set_text($listpxe[$i]{info});
+ set_help_tip($info, 'info');
my $kernel = Gtk2::Entry->new;
$kernel->set_text($listpxe[$i]{kernel});
+ set_help_tip($kernel, 'kernel');
# file selection for kernel
my $file_dialogk = new Gtk2::FileSelection(N("File Selection"));
$file_dialogk->set_modal(TRUE);
@@ -431,6 +472,7 @@ sub edit_box_item {
my $initrd = Gtk2::Entry->new;
$initrd->set_text($listpxe[$i]{initrd});
+ set_help_tip($initrd, 'initrd');
# file selection for initrd
my $file_dialog = new Gtk2::FileSelection(N("File Selection"));
$file_dialog->set_modal(TRUE);
@@ -447,37 +489,46 @@ sub edit_box_item {
$buttoninitrd->signal_connect(clicked => sub { $file_dialog->show });
# combo box to pop down automatic installation
- my $automatic = Gtk2::Combo->new;
+ my $automatic = Gtk2::OptionMenu->new;
$automatic->set_popdown_strings(@list_method);
$automatic->entry->set_text($listpxe[$i]{automatic});
+ set_help_tip($automatic, 'automatic');
# combo box to pop down list of network interface
- my $interface = new Gtk2::Combo();
+ my $interface = new Gtk2::OptionMenu();
$interface->set_popdown_strings(@list_eth);
$interface->entry->set_text($listpxe[$i]{interface});
+ set_help_tip($interface, 'interface');
my $network = Gtk2::Entry->new;
$network->set_text($listpxe[$i]{network});
+ set_help_tip($network, 'network');
my $server = Gtk2::Entry->new;
$server->set_text($listpxe[$i]{server});
+ set_help_tip($server, 'server');
my $directory = Gtk2::Entry->new;
$directory->set_text($listpxe[$i]{directory});
+ set_help_tip($directory, 'directory');
- my $ramdisk = new Gtk2::Combo();
+ my $ramdisk = new Gtk2::OptionMenu();
$ramdisk->set_popdown_strings(@list_ram);
$ramdisk->entry->set_text($listpxe[$i]{ramdisk});
+ set_help_tip($ramdisk, 'ramsize');
- my $vga = new Gtk2::Combo();
+ my $vga = new Gtk2::OptionMenu();
$vga->set_popdown_strings(@list_vga);
$vga->entry->set_text($listpxe[$i]{vga});
+ set_help_tip($vga, 'vga');
my $display = Gtk2::Entry->new;
$display->set_text($listpxe[$i]{display});
+ set_help_tip($display, 'display');
my $option = Gtk2::Entry->new;
$option->set_text($listpxe[$i]{option});
+ set_help_tip($option, 'option');
my %size_groups = map { $_ => Gtk2::SizeGroup->new('horizontal') } qw(label widget button);
my $label_and_widgets = sub {
@@ -489,6 +540,7 @@ sub edit_box_item {
);
};
+ # ok, lets create the dialog box :-)
gtkpack_($dialog->vbox,
0, gtkadd(Gtk2::Frame->new(N("Descrition")),
gtkpack_(gtkset_border_width(Gtk2::VBox->new, 3),
@@ -600,6 +652,8 @@ sub remove_in_help {
} $PXEHELP;
}
+# edit cell direct on main interface
+# disable due to bug in "cell edit placement" :-(
sub cell_edited {
my ($cell, $path_string, $new_text, $model) = @_;
my $path = Gtk2::TreePath->new_from_string($path_string);
@@ -689,8 +743,17 @@ sub cell_edited {
write_conf_pxe;
}
-sub show_help { info_dialog("Help", $help) }
+sub show_help { info_dialog("help",
+ gtkpack_(gtkset_border_width(Gtk2::VBox->new, 3),
+ 0, $help,
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("online PXE documentation")), 'editb'),
+ clicked => sub { open(F, "mozilla http://clic.mandrakesoft.com/pxe/ |") }
+ ),
+ ),
+ )
+ }
+# adjust pxe confi with good value
sub pxe_conf {
if (!-f "$pxeconf.orig") { cp_af($pxeconf, "$pxeconf.orig") }
substInFile {
@@ -700,6 +763,7 @@ sub pxe_conf {
} $pxeconf;
}
+# launch wizard to setup a PXE server
sub wizard_pxe_server {
local $::isEmbedded = 0;
my $in = 'interactive'->vnew('su');
@@ -710,11 +774,11 @@ sub wizard_pxe_server {
my $w = wizards->new;
my $wiz = {
name => N("PXE Wizard"),
- 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.")
- }
- 1},
+# init => sub {
+# if (($DOMAINNAME eq "") or ($HOSTNAME eq "localhost")) {
+# return 0, N("You need to readjust your domainname, not equal to localdomain or none. Please launch drakconnect to adjust it.")
+# }
+# 1},
pages => {
welcome => {
name => N("PXE wizard") . "\n\n" . N("Set a PXE server.") . "\n" . N("This wizard will help you configuring the PXE server, and PXE boot image management. PXE (Pre-boot eXecution Environment) is a protocol designed by Intel that allows computers to boot through the network. PXE is stored in the ROM of new generation network cards. When the computer boots up, the BIOS loads the PXE ROM in the memory and executes it. A menu is displayed, allowing the computer to boot an operating system loaded through the network."),
@@ -729,10 +793,10 @@ sub wizard_pxe_server {
summaryserver => {
name => N("The wizard will now prepare all default files to set your PXE server"),
data => [
- { 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 },
+ { label => N("TFTP directory: $TFTPDIR") },
+ { label => N("Boot image path: $IMGPATH") },
+ { label => N("PXE config file: $pxeconf") },
+ { label => N("PXE help file: $PXEHELP") },
],
post => \&do_it_pxe,
no_back => 1,
@@ -750,6 +814,7 @@ sub wizard_pxe_server {
$w->process($wiz, $in);
}
+# save old config with date
sub save_config {
my ($old) = @_;
my $DATE = chomp_(`date +%d-%m-20%y`);
@@ -760,7 +825,7 @@ sub save_config {
return($old . '.' . $DATE);
}
-
+# set default PXE message
sub default_pxe_messages {
save_config($PXEMESSAGE);
output($PXEMESSAGE, <<EOF);
@@ -791,6 +856,7 @@ local: local boot
EOF
}
+# can adjust block size in tftp server (ita64)
sub tftp_blksize {
# $o should be with W or not N
my ($o) = @_;
@@ -801,6 +867,7 @@ sub tftp_blksize {
}
}
+# enable tftp server in xinetd conf
sub enable_tftps {
substInFile { s/disable.*/disable = no/ } "$XINETDDIR/tftp";
}
@@ -819,6 +886,7 @@ sub check_started {
}
}
+# main procedure to setup PXE server
sub do_it_pxe {
return if $::testing;
my $in = 'interactive'->vnew('su', 'PXE server');
@@ -841,6 +909,7 @@ EOF
check_started($_) foreach qw(xinetd pxe);
}
+# add colum to model
sub add_columns {
my $treeview = shift;
my $model = $treeview->get_model;
@@ -858,10 +927,11 @@ sub add_columns {
#(("Label"), ("Info"), ("Kernel"), ("Initrd"), ("Method"), ("Interface"), ("Network"), ("Server"), ("Directory"), ("Ramdisk"), ("vga"), ("Display"), ("Extra"), ("Options"));
}
-#
-# Main
+###############
+# Main Program
+###############
-# create model
+# check if first launch
if (! -f "$X86/drakwizard_pxe") {
info_dialog("Please confure a PXE server", "Its seems this is the first time you run this tool.
A wizard will apppear to configure your pxe server.");
@@ -870,15 +940,16 @@ A wizard will apppear to configure your pxe server.");
$::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);
+ err_dialog(N("Error"), N("The PXE server wizard had unexpectly failled:") . "\n\n" . $err);
}
}
+# disable wizard
$::isWizard = 0;
+# create model
my $model = create_model();
-my $window = ugtk2->new('Drakpxe2');
+my $window = ugtk2->new("Drakpxelinux $version");
$window->{rwindow}->set_size_request(800, 400) unless $::isEmbedded; # seems embedded cause some pb
my $W = $window->{window};
$W->signal_connect(delete_event => sub { ugtk2->exit });
@@ -888,17 +959,19 @@ $treeview->set_rules_hint(TRUE);
$treeview->get_selection->set_mode('single');
add_columns($treeview);
-my $labels = new Gtk2::Combo();
+# labels that list pxe menu entry
+my $labels = new Gtk2::OptionMenu();
my @labels = list_label_pxe;
my $defaultlabel = get_default_pxe;
-$labels->entry->set_text("$defaultlabel");
+$labels->entry->set_text($defaultlabel);
$labels->entry->signal_connect("changed", sub { list_label_pxe; my $new_default = $labels->entry->get_text;
set_new_default($new_default);
}
);
$labels->set_popdown_strings(@labels);
-$labels->entry->set_text("$defaultlabel");
+$labels->entry->set_text($defaultlabel);
+set_help_tip($labels, 'labels');
my $banner = Gtk2::Banner->new('wiz_default_up', ("DrakPXE default configuration file"));
my $okcancel = create_okcancel({
@@ -908,14 +981,15 @@ my $okcancel = create_okcancel({
);
;
+# main interface
$W->add(gtkpack_(Gtk2::VBox->new(0,0),
if_(! $::isEmbedded, 0, $banner ),
1, create_scrolled_window($treeview),
0, gtkpack_(gtkset_border_width(Gtk2::HBox->new, 3),
- 0, Gtk2::Label->new(N("boot:")),
+ 0, Gtk2::Label->new(N("boot:")),
0, $labels,
0, Gtk2::VSeparator->new(),
- 0, gtksignal_connect(new Gtk2::Button(N("Wizard PXE server")),
+ 0, gtksignal_connect(set_help_tip(new Gtk2::Button(N("Wizard PXE server")), 'wizardsrv'),
clicked => sub {
eval { wizard_pxe_server() };
my $err = $@;
@@ -931,7 +1005,7 @@ $W->add(gtkpack_(Gtk2::VBox->new(0,0),
clicked => sub { show_help }
),
0, Gtk2::VSeparator->new,
- 0, gtksignal_connect(Gtk2::Button->new(N("Add PXE entry")), clicked => sub {
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Add PXE entry")), 'addpxe'), clicked => sub {
eval { wizard_add_entry($model, $treeview) };
my $err = $@;
$::WizardWindow->destroy if defined $::WizardWindow;
@@ -941,10 +1015,10 @@ $W->add(gtkpack_(Gtk2::VBox->new(0,0),
. "\n\n" . $err);
}
}),
- 0, gtksignal_connect(Gtk2::Button->new((N"Remove PXE entry")), clicked => sub {
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new((N"Remove PXE entry")), 'removepxe'), clicked => sub {
remove_item($model, $treeview); }
),
- 0, gtksignal_connect(Gtk2::Button->new(N("Edit PXE entry")), clicked => sub {
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Edit PXE entry")), 'editb'), clicked => sub {
edit_box_item($model, $treeview); }
),
),