From b2f8d6ac7d8acc830af5c5ae232af06498c773b4 Mon Sep 17 00:00:00 2001 From: Antoine Ginies Date: Wed, 14 Jan 2004 18:28:03 +0000 Subject: now can remove entry in PXE --- pxe_wizard/Pxe.pm | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'pxe_wizard') diff --git a/pxe_wizard/Pxe.pm b/pxe_wizard/Pxe.pm index 007ed6bb..67ad1bdf 100644 --- a/pxe_wizard/Pxe.pm +++ b/pxe_wizard/Pxe.pm @@ -54,6 +54,7 @@ my $o = { IMG => '/tmp/t.img', PXENAME => '92', DESCR => 'install 9.2', + IMGTOREMOVE => '', }, needed_rpm => [ 'pxe', 'tftp-server', 'xinetd' ], }; @@ -64,6 +65,8 @@ my %level = ( 3 => N("remove - remove image in PXE"), # 4 => N("Modify - Modify image in PXE"), ); +# to get menu entry +list_menu(); $o->{pages} = { welcome => { @@ -99,7 +102,7 @@ $o->{pages} = { removeimg => { name => N("Remove a boot Image") . "\n\n" . N("Which one ?"), data => [ - { label => "Wich one ?", val => \$o->{var}{PXENAME} }, + { label => N("Which one:"), val => \$o->{var}{IMGTOREMOVE} }, ], next => 'summaryremove', }, @@ -148,6 +151,9 @@ $o->{pages} = { }, summaryremove => { name => N('Now will remove your PXE boot image'), + data => [ + { label => N("PXE entry to remove:"), fixed_val => \$o->{var}{IMGTOREMOVE} }, + ], post => \&do_it_remove, next => 'endremove', }, @@ -255,27 +261,35 @@ sub add_img { sub get_menu_entry { my ($NAME) = @_; - my ($NAME_bloc) = $PXEDEFAULT =~ /# TAG: ${NAME}_BEGIN(.*?)# TAG: ${NAME}_END/s or die "unable to find Menu entry section"; - $NAME_bloc; + my $conf = cat_($PXEDEFAULT) . "#EndOfFile"; + my ($NAME_bloc) = $conf =~ /(# TAG: ${NAME}_BEGIN.*?# TAG: ${NAME}_END)#EndOfFile/s or die "unable to find Menu entry section"; + print "$NAME_bloc"; } sub remove_in_menu { my ($NAME) = @_; - substInFile { - s/${NAME}_BEGIN.* \n\n\n//; - } $PXEDEFAULT; + 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); +} + +sub list_menu { + foreach (cat_($PXEDEFAULT)) { + my ($ent) = /\# TAG: (\w+)_BEGIN/; + ! $ent or print "$ent\n"; + } } sub remove_in_help { my ($NAME) = @_; substInFile { - s/^$NAME//; + s/^$NAME :.*//x; } $PXEHELP; } sub remove_img { - my ($PXENAME) = @_; - rm_rf($IMGPATH . "/" . $PXENAME . '.img'); + my ($NAME) = @_; + rm_rf($IMGPATH . "/" . $NAME . '.img'); } sub default_pxe_menu { @@ -327,6 +341,9 @@ sub do_it_add { sub do_it_remove { return if $::testing; + remove_in_menu($o->{var}{IMGTOREMOVE}); + remove_in_help($o->{var}{IMGTOREMOVE}); + remove_img($o->{var}{IMGTOREMOVE}); } sub do_it_modify { -- cgit v1.2.1