From 6896d3fc03274d41142d389b204f6f648a23ace8 Mon Sep 17 00:00:00 2001 From: Antoine Ginies Date: Thu, 5 Aug 2004 08:49:10 +0000 Subject: add wizard to set a PXE server --- drakpxelinux.pl | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 2 deletions(-) (limited to 'drakpxelinux.pl') diff --git a/drakpxelinux.pl b/drakpxelinux.pl index 186dd94..ea720ad 100644 --- a/drakpxelinux.pl +++ b/drakpxelinux.pl @@ -28,7 +28,7 @@ use strict; use common; use MDK::Common; use ugtk2 qw(:ask :helpers :wrappers :create :dialogs); - +use interactive; use constant FALSE => 0; use constant TRUE => 1; @@ -40,6 +40,22 @@ use constant TRUE => 1; 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'; +my $X86 = $TFTPDIR . $CLIENTPATH; +my $IMGPATH = $X86 . '/images'; +my $PXEHELP = $X86 . '/help.txt'; +my $PXEMESSAGE = $X86 . '/messages'; +my $pxeconf = '/etc/pxe.conf'; +my $SYSLINUXPATH = '/usr/lib/syslinux/'; +my $MEMDISK = $SYSLINUXPATH . '/memdisk'; +my $XINETDDIR = "/etc/xinetd.d"; + +my $interface = 'eth0'; +my ($IPSERVER) = `/sbin/ip addr show dev $interface` =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/m; +my $DOMAINNAME = chomp_(`dnsdomainname`); my $help = " PXE Label: the name displayed in PXE menu (a word/number) @@ -543,6 +559,142 @@ sub cell_edited { sub show_help { info_dialog("Help", $help) } +sub pxe_conf { + if (!-f "$pxeconf.orig") { cp_af($pxeconf, "$pxeconf.orig") } + substInFile { + s/default_address.*/default_address=$IPSERVER/; + s/mtftp_address.*/mtftp_address=$IPSERVER/; + s/domain.*/domain=$DOMAINNAME/; + } $pxeconf; +} + +sub wizard_pxe_server { + my $in = 'interactive'->vnew('su'); + local $::isEmbedded = 0; + $::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.") + } + 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 Envir\onment) 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."), + no_back => 1, + next => 'pxeserver', + }, + 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."), + 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 }, + ], + post => \&do_it_pxe, + next => 'endserver', + }, + endserver => { + name => N("Congratulations"), + data => [ { label => N("The wizard successfully configured your PXE server.") } ], + no_back => 1, + end => 1, + next => 0 + }, + }, + }; +} + +sub default_pxe_messages { + save_config($PXEMESSAGE); + output($PXEMESSAGE, <vnew('su', 'PXE server'); + my $w = $in->wait_message(N("PXE server"), N("Configuring PXE server on your system...")); + output("$X86/drakwizard_pxe", <get_model; @@ -598,16 +750,19 @@ 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, $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); }) + $sub->($model, $widg); }), } ([ ("Help"), \&show_help ], [ ("Add a PXE entry"), \&add_item, $model ], [ ("Remove PXE entry"), \&remove_item, $treeview ], -- cgit v1.2.1