summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2004-08-30 11:16:31 +0000
committerOlivier Blin <oblin@mandriva.org>2004-08-30 11:16:31 +0000
commitdc6d19b1cc33b5bf7ad00589183fab12ce192cdd (patch)
tree5d417f5d8abfaaa881ad158aae07e18bdd3c5187
parent04eb4aa7851380c102e64d7a2f6eda0d6f14c3fc (diff)
downloaddrakx-dc6d19b1cc33b5bf7ad00589183fab12ce192cdd.tar
drakx-dc6d19b1cc33b5bf7ad00589183fab12ce192cdd.tar.gz
drakx-dc6d19b1cc33b5bf7ad00589183fab12ce192cdd.tar.bz2
drakx-dc6d19b1cc33b5bf7ad00589183fab12ce192cdd.tar.xz
drakx-dc6d19b1cc33b5bf7ad00589183fab12ce192cdd.zip
move start_interface and stop_interface from net_monitor to network::tools, use it in net_monitor and net_applet
-rw-r--r--perl-install/network/tools.pm17
-rw-r--r--perl-install/standalone/net_applet6
-rwxr-xr-xperl-install/standalone/net_monitor31
3 files changed, 28 insertions, 26 deletions
diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm
index 536870973..cfd92734b 100644
--- a/perl-install/network/tools.pm
+++ b/perl-install/network/tools.pm
@@ -9,7 +9,7 @@ use vars qw(@ISA @EXPORT @EXPORT_OK);
use MDK::Common::System qw(getVarsFromSh);
@ISA = qw(Exporter);
-@EXPORT = qw(connect_backend connected connected_bg disconnect_backend is_dynamic_ip passwd_by_login read_secret_backend set_cnx_script test_connected write_cnx_script remove_initscript write_secret_backend);
+@EXPORT = qw(connect_backend connected connected_bg disconnect_backend is_dynamic_ip passwd_by_login read_secret_backend set_cnx_script test_connected write_cnx_script remove_initscript write_secret_backend start_interface stop_interface);
our $connect_prog = "/etc/sysconfig/network-scripts/net_cnx_pg";
our $connect_file = "/etc/sysconfig/network-scripts/net_cnx_up";
@@ -82,6 +82,21 @@ sub disconnect_backend {
run_program::rooted($::prefix, "ifdown $netc->{NET_INTERFACE} &");
}
+sub bg_command_as_root {
+ my ($name, @args) = @_;
+ run_program::raw({ detach => 1 }, [ 'consolehelper', $name ], @args);
+}
+
+sub start_interface {
+ my ($intf) = @_;
+ bg_command_as_root('/sbin/ifup', $intf);
+}
+
+sub stop_interface {
+ my ($intf) = @_;
+ bg_command_as_root('/sbin/ifdown', $intf);
+}
+
sub connected() { gethostbyname("mandrakesoft.com") ? 1 : 0 }
# request a ref on a bg_connect and a ref on a scalar
diff --git a/perl-install/standalone/net_applet b/perl-install/standalone/net_applet
index d19a1d9b8..90f67e59f 100644
--- a/perl-install/standalone/net_applet
+++ b/perl-install/standalone/net_applet
@@ -40,10 +40,8 @@ my %appletstate = (
);
my %actions = (
- 'upNetwork' => { name => sub { N("Connect %s", $_[0]) },
- launch => sub { system("/usr/sbin/net_monitor --connect --defaultintf $_[0] &") } },
- 'downNetwork' => { name => sub { N("Disconnect %s", $_[0]) },
- launch => sub { system("/usr/sbin/net_monitor --disconnect --defaultintf $_[0] &") } },
+ 'upNetwork' => { name => sub { N("Connect %s", $_[0]) }, launch => \&network::tools::start_interface },
+ 'downNetwork' => { name => sub { N("Disconnect %s", $_[0]) }, launch => \&network::tools::stop_interface },
'monitorNetwork' => { name => N("Monitor Network"), launch => sub { system("/usr/sbin/net_monitor --defaultintf $_[0] &") } },
'confNetwork' => { name => N("Configure Network"), launch => sub { system("/usr/sbin/drakconnect --skip-wizard &") } },
'refresh' => { name => N("Refresh"), launch => sub { checkNetwork() } },
diff --git a/perl-install/standalone/net_monitor b/perl-install/standalone/net_monitor
index 4603c80ae..6b2e3baf3 100755
--- a/perl-install/standalone/net_monitor
+++ b/perl-install/standalone/net_monitor
@@ -41,9 +41,15 @@ my $connect = "@ARGV" =~ /--connect/;
my $disconnect = "@ARGV" =~ /--disconnect/;
my ($default_intf) = "@ARGV" =~ /--defaultintf (\w+)/;
+my $netcnx = {};
+my $netc = {};
+my $intf = {};
+network::netconnect::read_net_conf($netcnx, $netc, $intf);
+$default_intf or ($default_intf, undef, undef, undef) = get_internet_connection($netc, $intf);
+
if ($force) {
- $connect and start_connection();
- $disconnect and stop_connection();
+ $connect and network::tools::start_interface($default_intf);
+ $disconnect and network::tools::stop_interface($default_intf);
$connect = $disconnect = 0;
}
$quiet and exit(0);
@@ -66,9 +72,6 @@ my $colora = gtkcolor(655, 50400, 655);
my $isconnected = -1;
my @interfaces;
my $monitor = {};
-my $netcnx = {};
-my $netc = {};
-my $intf = {};
my $c_time = 0;
my $ct_tag;
@@ -84,7 +87,6 @@ my $cfg_file = $< ? "$ENV{HOME}/.net_monitorrc" : "/etc/sysconfig/net_monitorrc"
my %config = getVarsFromSh($cfg_file);
my $use_same_scale = text2bool($config{use_same_scale});
-network::netconnect::read_net_conf($netcnx, $netc, $intf);
MDK::Common::Globals::init(in => $in);
gtkadd($window1->{window},
@@ -174,19 +176,6 @@ sub main_quit() {
ugtk2->exit(0);
}
-sub bg_command_as_root {
- my $name = shift;
- run_program::raw({ detach => 1 }, [ 'consolehelper', $name ], @_);
-}
-
-sub start_connection() {
- $default_intf and bg_command_as_root('/sbin/ifup', $default_intf);
-}
-
-sub stop_connection() {
- $default_intf and bg_command_as_root('/sbin/ifdown', $default_intf);
-}
-
sub connection() {
$during_connection = 1;
my $wasconnected = $isconnected;
@@ -262,9 +251,9 @@ sub connection() {
gtkflush();
if ($wasconnected == 1) {
- $tool_pid = stop_connection();
+ $tool_pid = network::tools::start_interface($default_intf);
} else {
- $tool_pid = start_connection();
+ $tool_pid = network::tools::stop_interface($default_intf);
}
}