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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
|
#!/usr/bin/perl -w
# Drakwizard PXE
# release 0.3
# Copyright (C) 2004 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 $INSTALLDIR = "/var/install/pxe";
#my $IA64PATH = '/IA64PC';
my $TMPDIR = '/tmp';
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 $PXEDEFAULT = $X86 . '/pxelinux.cfg/default';
my $pxeconf = '/etc/pxe.conf';
my $SYSLINUXPATH = '/usr/lib/syslinux/';
my $MEMDISK = $SYSLINUXPATH . '/memdisk';
my $XINETDDIR = "/etc/xinetd.d";
my $IPSERVER = $wiz->{net}->itf_get("IPADDR");
if (!$IPSERVER) {
my $interface = 'eth0';
($IPSERVER) = `/sbin/ip addr show dev $interface` =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/m;
}
#my $DOMAINNAME = $wiz->{net}->network_get("DOMAINNAME");
my $DOMAINNAME = chomp_(`dnsdomainname`);
my $o = {
name => N("PXE Wizard"),
allow_user => 'root',
var => {
IMG => '/var/install/9.2/images/network.img',
PXENAME => '92',
DESCR => 'install 9.2',
IMGTOREMOVE => '',
IMGTOMODIFY => '',
IP => '127.0.0.1',
DIR => '/var/install/',
ALLRDZ => '/mnt/cdrom/isolinux/alt0/all.rdz',
VMLINUZ => '/mnt/cdrom/isolinux/alt0/vmlinuz',
OPTION => '',
i => '',
},
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
},
};
my %level = (
1 => N("Set PXE server"),
2 => N("Add boot image in PXE"),
3 => N("Remove boot image in PXE"),
4 => N("Modify boot image in PXE"),
5 => N("Add all.rdz image in PXE"),
);
# to get list menu entry
my @list_menu;
foreach (cat_($PXEDEFAULT)) {
my ($ent) = /# TAG: (\w+)_BEGIN/;
! $ent or push @list_menu,$ent;
}
#set default list for entry in syslinux.cfg
my @list_method = qw(nfs http);
my @list_ram = qw(32000 48000 64000 1280000);
my @list_vga = qw(788 normal 785 791 792 text);
my @list_acpi = qw(ht force off);
my @list_apic = qw(apic noapic);
my @list_eth = qw(eth0 eth1 eth2);
#begin of wizard
$o->{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."),
no_back => 1,
pre => sub {
$o->{var}{wiz_level} ||= 1;
},
post => sub {
if (! -f "$X86/drakwizard_pxe") { return 'pxeserver' }
if ($o->{var}{wiz_level} == 1) { return 'pxeserver' }
elsif ($o->{var}{wiz_level} == 2) { return 'addimg' }
elsif ($o->{var}{wiz_level} == 5) { return 'addimgrdz' }
@list_menu or return 'needimg';
if ($o->{var}{wiz_level} == 3) { return 'removeimg' }
elsif ($o->{var}{wiz_level} == 4) { return 'modifyimg' }
},
data => [
{ label => N("What do you want to do:"), 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("To boot through network, the network computer needs a boot image. Morever we need to name this image, so each boot image is related to a name in PXE menu. User can then choose which image he wants to boot through PXE.") . "\n\n" . N("PXE description is used to explain the rule of the boot image, ie: Mandrake 10 image, Mandrake cooker image..") . "\n\n" . N("Path to image: provide the full path to the network boot image") . "\n\n" . N("PXE name: the name displayed in PXE menu (please provide a word or a number, with no space)"),
data => [
{ label => "PXE name:", val => \$o->{var}{PXENAME} },
{ label => "PXE description:", val => \$o->{var}{DESCR} },
{ label => "Full path to boot image:", val => \$o->{var}{IMG} },
],
post => \&test_data,
next => 'summaryadd',
},
addimgrdz => {
name => N("Add all.rdz boot image") . "\n\n" . N("To boot through network, network computer need a boot image. Morever we need to name this image, so each boot image is related to a name in PXE menu. So user can choose wich image he wants to boot through PXE.") . "\n\n" . N("PXE description is used to explain the rule of the boot image, ie: Mandrake 10 image, Mandrake cooker image..") . N("For technical reason, in case of multiple boot image, it's more simple to boot network computer through a kernel (vmlinuz), and provide one file with all drivers needed (in our case all.rdz).") . "\n\n" . N("Path to all.rdz: provide the full path to all.rdz image") . "\n\n" . N("PXE name: the name displayed in PXE menu (please provide a word or a number, with no space)"),
data => [
{ label => "PXE name:", val => \$o->{var}{PXENAME} },
{ label => "PXE description:", val => \$o->{var}{DESCR} },
{ label => "Full path to all.rdz image:", val => \$o->{var}{ALLRDZ} },
{ label => "Full path to vmlinuz:", val => \$o->{var}{VMLINUZ} },
],
post => \&test_datardz,
next => 'summaryaddrdz',
},
removeimg => {
name => N("Remove a boot image") . "\n\n" . N("Please choose the PXE boot image you want to remove from the PXE server.") . "\n\n" . N("The PXE boot image, and the related entry in PXE menu will be deleted."),
data => [
{ label => N("Boot image to remove:"), val => \$o->{var}{IMGTOREMOVE}, fixed_list => \@list_menu },
],
no_back => 1,
next => 'summaryremove',
},
modifyimg => {
name => N("Add options to boot image") . "\n\n" . N("In some cases, you want to add some options to the PXE boot image. This wizard provides an easy way to customize a boot image with common parameters.") . "\n\n" . N("Please choose, from the list below, the PXE boot image you want to modify"),
data => [
{ label => N("Boot image to modify:"), val => \$o->{var}{IMGTOMODIFY}, fixed_list => \@list_menu },
],
post => \&read_option,
no_back => 1,
next => 'gomodify',
},
gomodify => {
name => N("Add option to the PXE boot disk") . "\n\n" . N("Server IP: IP address of the server, which contains installation directory. You can create one with MDK install server wizard.") . "\n" . N("Install directory: the full path to MDK install server directory") . "\n" . N("Installation method: choose NFS or HTTP."),
data => [
{ label => N("Boot image to modify:"), fixed_val => \$o->{var}{i} },
{ label => N("Server IP:"), val => \$o->{var}{IP} },
{ label => N("Install directory:"), val => \$o->{var}{DIR} },
{ label => N("Installation method:"), val => \$o->{var}{METHOD}, fixed_list => \@list_method },
],
next => 'gomodify2',
},
gomodify2 => {
name => N("Network client interface: the network interface used for the installation process.") . "\n" . N("Ramsize: adjust the ramsize parameter on boot disk.") . "\n" . N("VGA option: if you encounter any problem whith VGA, please adjust. ") . "\n" . N("ACPI option: Advanced Configuration and Power Interface"),
data => [
{ label => N("Network client interface:"), val => \$o->{var}{ETH}, fixed_list => \@list_eth },
{ label => N("Ramsize:"), val => \$o->{var}{RAM}, fixed_list => \@list_ram },
{ label => N("VGA option:"), val => \$o->{var}{VGA}, fixed_list => \@list_vga },
{ label => N("ACPI option:"), val => \$o->{var}{ACPI}, fixed_list => \@list_acpi },
{ label => N("APIC option:"), val => \$o->{var}{APIC}, fixed_list => \@list_apic },
{ label => N("Custom option:"), val => \$o->{var}{OPTION} },
],
next => 'summarymodify',
},
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',
},
error_img => {
name => N("Please provide a bootable image. To boot through a network, network computers need a boot image."),
next => 'addimg',
},
needimg => {
name => N("We need an all.rdz or a network.img image. Please add one."),
no_back => 1,
next => 'welcome',
post => sub {
$o->{var}{wiz_level} = 5
},
},
error_imgrdz => {
name => N("Please provide an all.rdz image, wich contains all drivers. You can find one on the first CD of Mandrakelinux distribution, in /isolinux/alt0/ directory."),
next => 'addimgrdz',
},
error_path_img => {
name => N("Please choose an image from a different directory than %s.", $IMGPATH),
next => 'addimg',
},
error_path_imgrdz => {
name => N("Please choose an image from a different directory than %s.", $IMGPATH),
next => 'addimgrdz',
},
error_name => {
name => N("Please provide a correct PXE name: one word or one number with no space."),
next => 'addimg',
},
error_needpxe => {
name => N("To add/remove/modify PXE boot image, you need to run 'Set PXE server' before."),
no_back => 1,
next => 'pxeserver',
},
simmilar_entry => {
name => N("A similar name is already used in PXE menu") . "\n\n" . N("Please provide another one."),
next => 'addimg',
},
simmilar_entryrdz => {
name => N("A similar name is already used in PXE menu") . "\n\n" . N("Please provide another one."),
next => 'addimgrdz',
},
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 => \$PXEDEFAULT },
{ label => N("PXE 'help' file:"), fixed_val => \$PXEHELP },
],
post => \&do_it_pxe,
next => 'endserver',
},
summarymodify => {
name => N("The wizard will now modify boot options with those parameters:"),
data => [
{ label => N("Boot image to modify:"), fixed_val => \$o->{var}{i} },
{ label => N("Server IP:"), fixed_val => \$o->{var}{IP} },
{ label => N("Install directory:"), fixed_val => \$o->{var}{DIR} },
{ label => N("Installation method:"), fixed_val => \$o->{var}{METHOD} },
{ label => N("Network client interface:"), fixed_val => \$o->{var}{ETH} },
{ label => N("Ramsize:"), fixed_val => \$o->{var}{RAM} },
{ label => N("VGA option:"), fixed_val => \$o->{var}{VGA} },
{ label => N("ACPI option:"), fixed_val => \$o->{var}{ACPI} },
{ label => N("APIC option:"), fixed_val => \$o->{var}{APIC} },
{ label => N("Custom option:"), fixed_val => \$o->{var}{OPTION} },
],
post => \&do_it_modify,
next => 'endmodify',
},
summaryremove => {
name => N("The wizard will now remove this PXE boot image"),
data => [
{ label => N("PXE entry to remove:"), fixed_val => \$o->{var}{IMGTOREMOVE} },
],
no_back => 1,
post => \&do_it_remove,
next => 'endremove',
},
summaryadd => {
name => N("The wizard will now add this PXE boot image"),
data => [
{ label => "PXE name:", fixed_val => \$o->{var}{PXENAME} },
{ label => "PXE description:", fixed_val => \$o->{var}{DESCR} },
{ label => "Path to boot image:", fixed_val => \$o->{var}{IMG} },
],
post => \&do_it_add,
next => 'endadd',
},
summaryaddrdz => {
name => N("The wizard will now add this PXE boot image"),
data => [
{ label => "PXE name:", fixed_val => \$o->{var}{PXENAME} },
{ label => "PXE description:", fixed_val => \$o->{var}{DESCR} },
{ label => "Full path to all.rdz image:", fixed_val => \$o->{var}{ALLRDZ} },
{ label => "Full path to vmlinuz:", fixed_val => \$o->{var}{VMLINUZ} },
],
post => \&do_it_addrdz,
next => 'endadd',
},
endadd => {
name => N("Congratulations"),
data => [ { label => N("The wizard successfully added the PXE boot image.") } ],
post => sub {
@list_menu = ();
foreach (cat_($PXEDEFAULT)) {
my ($ent) = /# TAG: (\w+)_BEGIN/;
! $ent or push @list_menu,$ent;
}
},
next => 'welcome',
},
endremove => {
name => N("Congratulations"),
data => [ { label => N("The wizard successfully removed the PXE boot image.") } ],
post => sub {
@list_menu = ();
foreach (cat_($PXEDEFAULT)) {
my ($ent) = /# TAG: (\w+)_BEGIN/;
! $ent or push @list_menu,$ent;
}
},
next => 'welcome',
},
endmodify => {
name => N("Congratulations"),
data => [ { label => N("The wizard successfully modified the boot option.") } ],
next => 'welcome',
},
endserver => {
name => N("Congratulations"),
data => [ { label => N("The wizard successfully configured your PXE server.") } ],
no_back => 1,
end => 1,
next => 0
},
error_end => {
name => N("Failed"),
data => [ { label => N("Please relaunch drakwizard, and try to change some parameters.") } ],
no_back => 1,
end => 1,
next => 0,
},
};
#cp memlinux from syslinux
sub memlinux_prep {
if (!-f "$X86/memdisk") {
cp_af($MEMDISK, $X86);
}
}
# test img and similar entry in PXE
sub test_data {
$o->{var}{PXENAME} =~ /^\w+$/ or return 'error_name';
if (!-f $o->{var}{IMG}) {
return 'error_img'
}
if (any { /^$o->{var}{PXENAME}/ } cat_($PXEHELP)) {
return 'simmilar_entry'
}
}
sub test_datardz {
$o->{var}{PXENAME} =~ /^\w+$/ or return 'error_name';
if (!-f $o->{var}{ALLRDZ}) {
return 'error_imgrdz'
}
if (!-f $o->{var}{VMLINUZ}) {
return 'error_imgrdz'
}
if (any { /^$o->{var}{PXENAME}/ } cat_($PXEHELP)) {
return 'simmilar_entryrdz'
}
}
# enable tftp server
sub enable_tftps {
substInFile { s/disable.*/disable = no/ } "$XINETDDIR/tftp";
}
# can change option in tftp server
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 crea_wdir {
if (-e $TMPDIR) { rm_rf($TMPDIR);
}
mkdir_p($TMPDIR);
}
# add TAGGED entry in PXE menu
sub add_in_default {
my ($NAME) = @_;
if (!any { /${NAME}_BEGIN/ } cat_($PXEDEFAULT)) {
append_to_file($PXEDEFAULT, <<EOF);
# TAG: ${NAME}_BEGIN
label $NAME
KERNEL memdisk
APPEND initrd=images/$NAME.img
# TAG: ${NAME}_END
EOF
}
}
sub add_in_defaultrdz {
my ($NAME) = @_;
if (!any { /${NAME}_BEGIN/ } cat_($PXEDEFAULT)) {
append_to_file($PXEDEFAULT, <<EOF);
# TAG: ${NAME}_BEGIN
label $NAME
KERNEL images/vmlinuz-$NAME
APPEND initrd=images/$NAME.rdz
# TAG: ${NAME}_END
EOF
}
}
# add entry in Help.txt of PXE
sub add_in_help {
my ($NAME, $DESCR) = @_;
append_to_file($PXEHELP, <<EOF);
$NAME : $DESCR
EOF
}
# add bootable image in correct place
sub add_img {
my ($SIMG, $PXENAME) = @_;
!member($SIMG, "tfptboot") or return 'error_path_img';
cp_af($SIMG, $IMGPATH . "/" . $PXENAME . '.img');
}
sub add_imgrdz {
my ($SIMG, $VM, $PXENAME) = @_;
!member($SIMG, "tfptboot") or return 'error_path_img';
cp_af($VM, "$IMGPATH/" . basename($VM) . "-$PXENAME");
cp_af($SIMG, "$IMGPATH/$PXENAME.rdz");
}
# remove entry in PXE menu
sub remove_in_menu {
my ($NAME) = @_;
my $conf = cat_($PXEDEFAULT) . "#EndOfFile";
my ($begin, $_NAME_bloc, $end) = $conf =~ /(.*?)(# TAG: ${NAME}_BEGIN.*?# TAG: ${NAME}_END)\n(.*)#EndOfFile/s or die "unable to find Menu entry section";
output($PXEDEFAULT, $begin, $end);
}
# remove entry in help.txt
sub remove_in_help {
my ($NAME) = @_;
substInFile {
s/^$NAME\s:.*//x;
s/^\s*$//;
} $PXEHELP;
}
sub remove_img {
my ($NAME) = @_;
if (-f "$IMGPATH/$NAME.img") {
rm_rf($IMGPATH . "/" . $NAME . '.img')
}
if (-f "$IMGPATH/vmlinuz-$NAME") {
rm_rf("$IMGPATH/vmlinuz-$NAME");
rm_rf("$IMGPATH/$NAME.rdz");
}
}
sub save_config {
my ($FILE) = @_;
if (!-f "$FILE.ori") {
cp_af($FILE, "$FILE.ori");
}
}
# set default help.txt file
sub default_pxe_menu {
save_config($PXEHELP);
output($PXEHELP, <<EOF);
Available images are:
---------------------
local: local boot
EOF
save_config($PXEDEFAULT);
output($PXEDEFAULT, <<EOF);
PROMPT 1
DEFAULT local
DISPLAY messages
TIMEOUT 50
F1 help.txt
label local
LOCALBOOT 0
EOF
}
# set default pxe messages
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
}
# main add image in PXE menu
sub do_it_add {
return if $::testing;
add_in_help($o->{var}{PXENAME}, $o->{var}{DESCR});
add_in_default($o->{var}{PXENAME});
add_img($o->{var}{IMG}, $o->{var}{PXENAME});
}
sub do_it_addrdz {
return if $::testing;
add_in_help($o->{var}{PXENAME}, $o->{var}{DESCR});
add_in_defaultrdz($o->{var}{PXENAME});
add_imgrdz($o->{var}{ALLRDZ}, $o->{var}{VMLINUZ}, $o->{var}{PXENAME});
}
# main remove image
sub do_it_remove {
return if $::testing;
@list_menu or return 'needimg';
remove_in_menu($o->{var}{IMGTOREMOVE});
remove_in_help($o->{var}{IMGTOREMOVE});
remove_img($o->{var}{IMGTOREMOVE});
}
# get default option for an image
sub read_option {
my $IMG = $o->{var}{IMGTOMODIFY};
# detect if need loop or just add option to APPEND line
if (-f "$IMGPATH/$IMG.img") {
my $mount = "/tmp/loop_for_images";
mkdir_p($mount);
system("mount $IMGPATH/$IMG.img $mount -o loop 2>/dev/null");
my $line = cat_("$mount/syslinux.cfg");
$o->{var}{i} = "$IMGPATH/$IMG.img";
($o->{var}{METHOD}, $o->{var}{ETH}, $o->{var}{IP}, $o->{var}{DIR}, $o->{var}{RAM}, $o->{var}{VGA}, $o->{var}{ACPI}, $o->{var}{APIC}, $o->{var}{OPTION}) = $line =~ m!method:(nfs|http),interface:(eth0|eth1|eth2),network:dhcp,server:(.*?),directory:(.*?) ramdisk_size=(.*?) root=/dev/ram3 rw vga=(.*?)acpi=(ht|force|off)\s(apic|noapic)\s(.*)!;
system("umount $mount");
if (-e $mount) {
rm_rf($mount);
}
} else {
my $line = cat_($PXEDEFAULT);
$o->{var}{i} = "$IMGPATH/$IMG.rdz";
($o->{var}{METHOD}, $o->{var}{ETH}, $o->{var}{IP}, $o->{var}{DIR}, $o->{var}{RAM}, $o->{var}{VGA}, $o->{var}{ACPI}, $o->{var}{APIC}, $o->{var}{OPTION}) = $line =~ m!APPEND initrd=images/$IMG.rdz automatic=method:(nfs|http),interface:(eth0|eth1|eth2),network:dhcp,server:(.*?),directory:(.*?) ramdisk_size=(.*?) root=/dev/ram3 rw vga=(.*?)acpi=(ht|force|off)\s(apic|noapic)\s(.*)!;
}
}
# modify default boot option of an image
sub do_it_modify {
@list_menu or return 'needimg';
my $IMG = $o->{var}{IMGTOMODIFY};
my ($METHOD, $ETH, $IP, $DIR, $RAM, $VGA, $ACPI, $APIC, $OPTION) = ($o->{var}{METHOD}, $o->{var}{ETH}, $o->{var}{IP}, $o->{var}{DIR}, $o->{var}{RAM}, $o->{var}{VGA}, $o->{var}{ACPI}, $o->{var}{APIC}, $o->{var}{OPTION});
return if $::testing;
if (-f "$IMGPATH/$IMG.img") {
$o->{var}{i} = "$IMGPATH/$IMG.img";
return if $::testing;
#APPEND initrd=images/ken/cooker/i586/isolinux/alt0/all.rdz automatic=method:nfs,interface:eth0,network:dhcp,server:192.168.100.7,directory:/c/cooker ramdisk_size=32000 root=/dev/ram3 rw vga=788 meta_class=discovery
my $mount = "/tmp/loop_for_images";
mkdir_p($mount);
system("mount $o->{var}{i} $mount -o loop");
output("$mount/syslinux.cfg", <<EOF);
default linux
prompt 1
timeout 72
display boot.msg
F1 help.msg
F2 advanced.msg
F3 boot.msg
label linux
kernel vmlinuz
append initrd=network.rdz automatic=method:$METHOD,interface:$ETH,network:dhcp,server:$IP,directory:$DIR ramdisk_size=$RAM root=/dev/ram3 rw vga=$VGA acpi=$ACPI $APIC $OPTION
EOF
system("umount $mount");
if (-e $mount) {
rm_rf($mount);
}
} else {
$o->{var}{i} = "$IMGPATH/$IMG.rdz";
substInFile {
s!APPEND initrd=images/$IMG.rdz.*!APPEND initrd=images/$IMG.rdz automatic=method:$METHOD,interface:$ETH,network:dhcp,server:$IP,directory:$DIR ramdisk_size=$RAM root=/dev/ram3 rw vga=$VGA acpi=$ACPI $APIC $OPTION!m;
} $PXEDEFAULT;
}
}
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;
}
# set PXE server
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 new {
my ($class) = @_;
bless {
o => $o,
}, $class;
}
1;
|