summaryrefslogtreecommitdiffstats
path: root/drakpxelinux.pl
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2004-08-05 08:49:10 +0000
committerAntoine Ginies <aginies@mandriva.com>2004-08-05 08:49:10 +0000
commit6896d3fc03274d41142d389b204f6f648a23ace8 (patch)
tree8ebaf9d712c554a906468b5efb8984bc458abe1b /drakpxelinux.pl
parentd6808abe3bd42bfcaba482966ae42c0cfa87a1ce (diff)
downloaddrakpxelinux-6896d3fc03274d41142d389b204f6f648a23ace8.tar
drakpxelinux-6896d3fc03274d41142d389b204f6f648a23ace8.tar.gz
drakpxelinux-6896d3fc03274d41142d389b204f6f648a23ace8.tar.bz2
drakpxelinux-6896d3fc03274d41142d389b204f6f648a23ace8.tar.xz
drakpxelinux-6896d3fc03274d41142d389b204f6f648a23ace8.zip
add wizard to set a PXE server
Diffstat (limited to 'drakpxelinux.pl')
-rw-r--r--drakpxelinux.pl159
1 files changed, 157 insertions, 2 deletions
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, <<EOF);
+
+ Welcome to Mandrake Linux PXE Server
+ Pxelinux
+ . .-----------------------------------.
+ /|\\ / Press F1 for available images \\
+ /_|_\\ \\ Hosted by $HOSTNAME
+ \\ | / _ /'-----------------------------------'
+ \\|/ (') /
+ '. U / (O__
+ . '. / (o_ (o_ (0_ //\\
+ {o_ (o_ (o_ (o_ (o_ //\\ //\\ //\\ // )
+ (')_ (`)_ (/)_ (/)_ (/)_ V_/_ V_/_ V_/_ V__/_
+ ---------------------------------------------------------
+
+ press F1 for help
+EOF
+}
+
+sub default_pxe_menu {
+ save_config($PXEHELP);
+ output($PXEHELP, <<EOF);
+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 {
+ # $o should be with W or not N
+ my ($o) = @_;
+ if ($o =~ /W/) {
+ substInFile { s/server_args.*/server_args = -r blksize -s $TFTPDIR/ } "$XINETDDIR/tftp";
+ } else {
+ substInFile { s/server_args.*/server_args = -s $TFTPDIR/ } "$XINETDDIR/tftp";
+ }
+}
+
+sub memlinux_prep {
+ if (!-f "$X86/memdisk") {
+ cp_af($MEMDISK, $X86);
+ }
+}
+
+sub do_it_pxe {
+ return if $::testing;
+ my $in = 'interactive'->vnew('su', 'PXE server');
+ my $w = $in->wait_message(N("PXE server"), N("Configuring PXE server on your system..."));
+ output("$X86/drakwizard_pxe", <<EOF);
+do not remove
+use to check if drakwizard PXE set server
+has been launch.
+EOF
+
+ mkdir_p($IMGPATH);
+ memlinux_prep();
+ default_pxe_menu();
+ default_pxe_messages();
+ enable_tftps();
+ pxe_conf();
+ tftp_blksize('N');
+ system("service $_ restart") foreach qw(xinetd pxe);
+ undef $w;
+ check_started($_) foreach qw(xinetd pxe);
+}
+
sub add_columns {
my $treeview = shift;
my $model = $treeview->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 ],