summaryrefslogtreecommitdiffstats
path: root/pxe_wizard/Pxe.pm
blob: 4751c9e56012a7a2f14405738c62645c353911eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/perl -w

# Drakwizard

# Copyright (C) 2003 Mandrakesoft
#
# Author: Antoine Ginies <aginies _ateuh _ mandrakesoft.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

package MDK::Wizard::Pxe;
use lib qw(/usr/lib/libDrakX);
use strict;

use common;
use services;
use MDK::Wizard::Wizcommon;

my $wiz = new MDK::Wizard::Wizcommon;

my $intel_path = 'PXEClient';
my $com_path = 'X86PC';
my $ia64_path = 'IA64PC';
my $TFTPDIR = "/var/lib/tftpboot";
my $full64 = $TFTPDIR . '/' . $ia64_path . '/linux';
my $img_path64 = "$full64/images";
my $temp_dir = '/tmp';
my $INSTALLDIR = "/var/install/pxe";

my $o = {
	 name => N("PXE Wizard"),
	 var => {
		 INTELPATH => $intel_path,
		 COMPATH => $com_path,
		 IA64PATH => $ia64_path,
		 FULLINTEL => $TFTPDIR . '/' . $intel_path,
		 FULLCOM => $TFTPDIR . '/' . $com_path . '/linux',
		 FULL64 => $full64,
		 IMGPATH64 => $img_path64,
		 NET64 => "$img_path64/net",
		 KA64 => "$img_path64/ka",
		 TEMPDIR => $temp_dir,
		 PXEDEFAULT => 'pxelinux.cfg/default',
		 PXEDEFAULT64 => 'linux.1',
		 PXEMENU => "$temp_dir/default.pxe",
		 PXEMESSAGE => "$temp_dir/message.pxe",
		 FREEDOSIMAGE => $INSTALLDIR . '/images/freedos.img',
		 KAIMAGE => $INSTALLDIR . '/images/ka.img',
		 NETIMAGE => "$temp_dir/network.img",
		 SYSLINUXPATH => '/usr/lib/syslinux/',
		 PXEHELP => "$temp_dir/help.txt.pxe",
		 ELILO => '/boot/efi/elilo.efi',
		 CONF => '/etc/pxe.conf',
		},
	 needed_rpm => [ 'pxe', 'tftp-server' ],
	};

my %level = (
             1 => N("PXE - Set PXE server"),
             2 => N("add - Add image in PXE"),
	     3 => N("remove - remove image in PXE"),
	     4 => N("Modify - Modify image in PXE"),
	    );



$o->{pages} = {
	       welcome => {
			   name => N("PXE wizard") . "\n\n" . N("Set a PXE server.") . "\n\n" . N("This wizard will help you configuring the PXE server. This configuration will provide a pxe services, and ability to add/remove/modify boot images."),
			   no_back => 1,
			   pre => sub {
			     $o->{var}{wiz_level} ||= 1;
			   },
			   post => sub {
			     if ($o->{var}{wiz_level} == 2) { 
			       return 'addimg' }
			     elsif ($o->{var}{wiz_level} == 3) {
			       return 'removeimg' }
			     elsif ($o->{var}{wiz_level} == 4) {
			       return 'modifyimg' }
			     },
			   data => [
				    { label => N("Wich operation:"), val => \$o->{var}{wiz_level}, list => [ keys %level ], format => sub { $level{$_[0]} } },
				   ],
			   no_back => 1,
			   next => 'pxeserver',
			  },
	       addimg => {
			  name => N("Add a boot Image") . "\n\n" . N("Where is that boot image ?"),
			  data => [
				   { label => N(""), val => \$o->{var}{} },
				  ],
			  next => 'summaryadd',
			 },
	       removeimg => {
			  name => N("Remove a boot Image") . "\n\n" . N("Which one ?"),
			  data => [
				   { label => N(""), val => \$o->{var}{} },
				  ],
			  next => 'summaryremove',
			    },
	       modifyimg => {
			     name => N("Add Option to boot image") . "\n\n" . N("on Wich image ?"),
			     data => [
				      { label => N(""), val => \$o->{var}{} },
				     ],
			     next => 'summarymodify',
			    },
	       pxeserver => {
			  name => N("Set PXE server") . "\n\n" . N("We will use a special dhcpd.conf"),
			  data => [
				   { label => N(""), val => \$o->{var}{} },
				  ],
			  next => 'summaryserver',
			    },
	       error_dir => {
			     name => N('Error Should be a directory'),
			     next => '',
			    },
	       summaryserver => {
			      name => N(''),
			      next => 'endserver',
			     },
	       summarymodify => {
			      name => N(''),
			      next => 'endmodify',
				},
	       summaryremove => {
			      name => N(''),
			      next => 'endremove',
				},
	       summaryadd => {
			      name => N(''),
			      next => 'endadd',
			     },
	       endadd => {
			     name => N('Congratulations'),
			     data => [ { label => N('The wizard successfully add a PXE image.') } ],
                             no_back => 1,
                             end => 1,
                             next => 0
			    },
	       endremove => {
			     name => N('Congratulations'),
			     data => [ { label => N('The wizard successfully remove a PXE image.') } ],
                             no_back => 1,
                             end => 1,
                             next => 0
			    },
	       endmodify => {
			     name => N('Congratulations'),
			     data => [ { label => N('The wizard successfully modify image(s).') } ],
                             no_back => 1,
                             end => 1,
                             next => 0
			    },
	       endserver => {
			     name => N('Congratulations'),
			     data => [ { label => N('The wizard successfully configured Your PXE server.') } ],
                             no_back => 1,
                             end => 1,
                             next => 0
			    },
	      };


sub new {
    my ($class, $conf) = @_;
    bless {
            o   => $o,
	   }, $class;
}

1;