diff options
author | Nicolas Lécureuil <nlecureuil@mandriva.com> | 2011-08-30 13:16:42 +0000 |
---|---|---|
committer | Nicolas Lécureuil <nlecureuil@mandriva.com> | 2011-08-30 13:16:42 +0000 |
commit | c590a4a7c162d1a81dbf02ca2e174384af0385bb (patch) | |
tree | 7e1279550b8e48add99b7b41281d27d249d279f3 /lib/network/drakconnect/delete.pm | |
parent | 39d2ee13572a6dc634c0c454dfc43e0297483279 (diff) | |
download | drakx-net-c590a4a7c162d1a81dbf02ca2e174384af0385bb.tar drakx-net-c590a4a7c162d1a81dbf02ca2e174384af0385bb.tar.gz drakx-net-c590a4a7c162d1a81dbf02ca2e174384af0385bb.tar.bz2 drakx-net-c590a4a7c162d1a81dbf02ca2e174384af0385bb.tar.xz drakx-net-c590a4a7c162d1a81dbf02ca2e174384af0385bb.zip |
Create 2010.1 branch for drakx-net
Diffstat (limited to 'lib/network/drakconnect/delete.pm')
-rw-r--r-- | lib/network/drakconnect/delete.pm | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/network/drakconnect/delete.pm b/lib/network/drakconnect/delete.pm new file mode 100644 index 0000000..b8d0689 --- /dev/null +++ b/lib/network/drakconnect/delete.pm @@ -0,0 +1,68 @@ +package network::drakconnect::delete; + +use common; +use wizards; +use interactive; +use network::connection::ethernet; + +sub del_intf { + my ($in, $net, $modules_conf) = @_; + my ($intf2delete, $failure); + if (!keys %{$net->{ifcfg}}) { + $in->ask_warn(N("Error"), N("No ethernet network adapter has been detected on your system. Please run the hardware configuration tool.")); + return; + } + my @all_cards = network::connection::ethernet::get_eth_cards($modules_conf); + my %names = network::connection::ethernet::get_eth_cards_names(@all_cards); + + my $wiz = wizards->new( + { + defaultimage => "drakconnect", + name => N("Remove a network interface"), + pages => { + welcome => { + no_back => 1, + name => N("Select the network interface to remove:"), + data => [ { label => N("Net Device"), val => \$intf2delete, allow_empty_list => 1, + list => [ keys %{$net->{ifcfg}} ], + format => sub { + my $type = network::tools::get_interface_type($net->{ifcfg}{$_[0]}); + $names{$_[0]} || ($type ? "$type ($_[0])" : $_[0]); + } + } + ], + post => sub { + !$::testing and eval { + if (member($intf2delete, qw(adsl modem))) { + eval { rm_rf("/etc/ppp/peers/ppp0") }; + eval { rm_rf("/etc/sysconfig/network-scripts/ifcfg-ppp0") }; + } + if ($intf2delete eq 'adsl') { + eval { rm_rf("/etc/sysconfig/network-scripts/ifcfg-sagem") }; + } elsif ($intf2delete eq 'isdn') { + eval { rm_rf("/etc/sysconfig/network-scripts/ifcfg-ippp0") }; + } else { + system("ifdown $intf2delete"); + eval { rm_rf("/etc/sysconfig/network-scripts/$intf2delete") }; + eval { rm_rf("/etc/sysconfig/network-scripts/ifcfg-$intf2delete") }; + } + }; + $failure = $@; + network::network::reload_net_applet(); + return "end"; + }, + }, + end => { + name => sub { + $failure ? + N("An error occurred while deleting the \"%s\" network interface:\n\n%s", $intf2delete, $failure) + : N("Congratulations, the \"%s\" network interface has been successfully deleted", $intf2delete); + }, + end => 1, + }, + }, + }); + $wiz->safe_process($in); +} + +1; |