summaryrefslogtreecommitdiffstats
path: root/perl-install/network.pm
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2000-09-12 10:01:38 +0000
committerFrancois Pons <fpons@mandriva.com>2000-09-12 10:01:38 +0000
commitc3d511dc3d7729b9410b46b0df70c3a06c1aafc8 (patch)
tree5c537dd081df819149384b720c9b2eb72d73d5e1 /perl-install/network.pm
parenta6f5badbd4ab6f34b5340a45c7a6557395eddc89 (diff)
downloaddrakx-backup-do-not-use-c3d511dc3d7729b9410b46b0df70c3a06c1aafc8.tar
drakx-backup-do-not-use-c3d511dc3d7729b9410b46b0df70c3a06c1aafc8.tar.gz
drakx-backup-do-not-use-c3d511dc3d7729b9410b46b0df70c3a06c1aafc8.tar.bz2
drakx-backup-do-not-use-c3d511dc3d7729b9410b46b0df70c3a06c1aafc8.tar.xz
drakx-backup-do-not-use-c3d511dc3d7729b9410b46b0df70c3a06c1aafc8.zip
*** empty log message ***
Diffstat (limited to 'perl-install/network.pm')
-rw-r--r--perl-install/network.pm40
1 files changed, 19 insertions, 21 deletions
diff --git a/perl-install/network.pm b/perl-install/network.pm
index 4ec01e5fb..0c3466bec 100644
--- a/perl-install/network.pm
+++ b/perl-install/network.pm
@@ -20,19 +20,20 @@ use log;
sub read_conf {
my ($file) = @_;
my %netc = getVarsFromSh($file);
- foreach (0..2) {
- exists $netc{"NS$_"} and $netc{dnsServers}{delete $netc{"NS$_"}} = $_ + 1;
- }
+ $netc{dnsServer} = delete $netc{NS0};
+ $netc{dnsServer2} = delete $netc{NS1};
+ $netc{dnsServer3} = delete $netc{NS2};
\%netc;
}
sub read_resolv_conf {
my ($file) = @_;
- my ($i, %netc);
+ my @l = qw(dnsServer dnsServer2 dnsServer3);
+ my %netc;
local *F; open F, $file or die "cannot open $file: $!";
foreach (<F>) {
- /^\s*nameserver\s+(\S+)/ and $netc{dnsServers}{$1} = ++$i;
+ /^\s*nameserver\s+(\S+)/ and $netc{shift @l} = $1;
}
\%netc;
}
@@ -76,7 +77,10 @@ sub write_conf {
sub write_resolv_conf {
my ($file, $netc) = @_;
- unless ($netc->{DOMAINNAME} || dnsServers($netc)) {
+ #- get the list of used dns.
+ my %used_dns; @used_dns{$netc->{dnsServer}, $netc->{dnsServer2}, $netc->{dnsServer3}} = (1, 2, 3);
+
+ unless ($netc->{DOMAINNAME} || keys %used_dns > 0) {
unlink($file);
log::l("neither domain name nor dns server are configured");
return 0;
@@ -85,16 +89,16 @@ sub write_resolv_conf {
my (%search, %dns, @unknown);
local *F; open F, $file;
foreach (<F>) {
- /^\s*search\s+(.*?)\s*$/ and $search{$1} = $., next;
- /^\s*nameserver\s+(.*?)\s*$/ and $dns{$1} = $., next;
+ /^[#\s]*search\s+(.*?)\s*$/ and $search{$1} = $., next;
+ /^[#\s]*nameserver\s+(.*?)\s*$/ and $dns{$1} = $., next;
/^[#\s]*(\S.*?)\s*$/ and push @unknown, $1;
}
close F; open F, ">$file" or die "cannot write $file: $!";
print F "# search $_\n" foreach grep { $_ ne $netc->{DOMAINNAME} } sort { $search{$a} <=> $search{$b} } keys %search;
print F "search $netc->{DOMAINNAME}\n\n" if $netc->{DOMAINNAME};
- print F "# nameserver $_\n" foreach grep { ! exists $netc->{dnsServers}{$_} } sort { $dns{$a} <=> $dns{$b} } keys %dns;
- print F "nameserver $_\n" foreach dnsServers($netc);
+ print F "# nameserver $_\n" foreach grep { ! exists $used_dns{$_} } sort { $dns{$a} <=> $dns{$b} } keys %dns;
+ print F "nameserver $_\n" foreach sort { $used_dns{$a} <=> $used_dns{$b} } grep { $_ } keys %used_dns;
print F "\n";
print F "# $_\n" foreach @unknown;
@@ -177,7 +181,8 @@ sub resolv($) {
sub dnsServers {
my ($netc) = @_;
- sort { $netc->{dnsServers}{$a} <=> $netc->{dnsServers}{$b} } grep { $_ } keys %{$netc->{dnsServers} || {}};
+ my %used_dns; @used_dns{$netc->{dnsServer}, $netc->{dnsServer2}, $netc->{dnsServer3}} = (1, 2, 3);
+ sort { $used_dns{$a} <=> $used_dns{$b} } grep { $_ } keys %used_dns;
}
sub findIntf {
@@ -305,10 +310,8 @@ notation (for example, 1.2.3.4)."),
sub configureNetworkNet {
my ($in, $netc, $intf, @devices) = @_;
- my ($dns1, $dns2) = dnsServers($netc);
- my ($lvl_dns1, $lvl_dns2) = (delete $netc->{dnsServers}{$dns1}, delete $netc->{dnsServers}{$dns2});
- $dns1 ||= dns($intf->{IPADDR});
- $netc->{GATEWAY} ||= gateway($intf->{IPADDR});
+ $netc->{dnsServer} ||= dns($intf->{IPADDR});
+ $netc->{GATEWAY} ||= gateway($intf->{IPADDR});
$in->ask_from_entries_refH(_("Configuring network"),
_("Please enter your host name.
@@ -316,16 +319,11 @@ Your host name should be a fully-qualified host name,
such as ``mybox.mylab.myco.com''.
You may also enter the IP address of the gateway if you have one"),
[ _("Host name") => \$netc->{HOSTNAME},
- _("First DNS server") => \$dns1,
- _("Second DNS server") => \$dns2,
+ _("DNS server") => \$netc->{dnsServer},
_("Gateway") => \$netc->{GATEWAY},
$::expert ? (_("Gateway device") => {val => \$netc->{GATEWAYDEV}, list => \@devices }) : (),
],
) or return;
-
- my ($old_dns1, $old_dns2) = dnsServers($netc);
- $netc->{dnsServers}{$dns1} = $lvl_dns1 || 1;
- $netc->{dnsServers}{$dns2} = $lvl_dns2 || $lvl_dns1 + 1 || 2;
}
sub miscellaneousNetwork {