diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2003-02-20 17:30:10 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2003-02-20 17:30:10 +0000 |
commit | 153d56e9f939b4dd48e65d68074e72356a6223f4 (patch) | |
tree | 535ffdeaf2528a5962f53e0e0807b2f460579efb /perl-install | |
parent | 2e920d5604415e2b83af4dd8a81c288a9427d965 (diff) | |
download | drakx-backup-do-not-use-153d56e9f939b4dd48e65d68074e72356a6223f4.tar drakx-backup-do-not-use-153d56e9f939b4dd48e65d68074e72356a6223f4.tar.gz drakx-backup-do-not-use-153d56e9f939b4dd48e65d68074e72356a6223f4.tar.bz2 drakx-backup-do-not-use-153d56e9f939b4dd48e65d68074e72356a6223f4.tar.xz drakx-backup-do-not-use-153d56e9f939b4dd48e65d68074e72356a6223f4.zip |
- read_resolv_conf() reads DOMAINNAME & DOMAINNAME2
- read_resolv_conf() reads /etc/resolv.conf by default
- read_resolv_conf_raw() created
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/network/network.pm | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index e8a331314..ab5e2c1ae 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -25,12 +25,21 @@ sub read_conf { +{ getVarsFromSh($file) }; } -sub read_resolv_conf { + +sub read_resolv_conf_raw { my ($file) = @_; - my @l = map { if_(/^\s*nameserver\s+(\S+)/, $1) } cat_($file); + $file ||= "$::prefix/etc/resolv.conf"; + { nameserver => [ cat_($file) =~ /^\s*nameserver\s+(\S+)/mg ], + search => [ cat_($file) =~ /^\s*search\s+(\S+)/mg ] }; +} - my %netc = mapn { $_[0] => $_[1] } [ qw(dnsServer dnsServer2 dnsServer3) ], \@l; - \%netc; +sub read_resolv_conf { + my ($file) = @_; + my $resolv_conf = read_resolv_conf_raw($file); + +{ + (mapn { $_[0] => $_[1] } [ qw(dnsServer dnsServer2 dnsServer3) ], $resolv_conf->{nameserver}), + (mapn { $_[0] => $_[1] } [ qw(DOMAINNAME DOMAINNAME2 DOMAINNAME3) ], $resolv_conf->{search}), + }; } sub read_interface_conf { @@ -74,8 +83,8 @@ sub write_conf { my ($file, $netc) = @_; if ($netc->{HOSTNAME}) { - $netc->{HOSTNAME} =~ /\.(.*)$/; - $1 and $netc->{DOMAINNAME} = $1; + $netc->{HOSTNAME} =~ /\.(.+)$/; + $netc->{DOMAINNAME} = $1; } ($netc->{DOMAINNAME}) ||= 'localdomain'; add2hash($netc, { @@ -84,7 +93,7 @@ sub write_conf { if_(!$netc->{DHCP}, HOSTNAME => "localhost.$netc->{DOMAINNAME}"), }); - setVarsInSh($file, $netc, if_(!$netc->{DHCP}, 'HOSTNAME'), qw(NETWORKING FORWARD_IPV4 DOMAINNAME GATEWAY GATEWAYDEV NISDOMAIN)); + setVarsInSh($file, $netc, if_(!$netc->{DHCP}, 'HOSTNAME'), qw(NETWORKING FORWARD_IPV4 GATEWAY GATEWAYDEV NISDOMAIN)); } sub write_zeroconf { @@ -451,7 +460,7 @@ sub read_all_conf { my ($prefix, $netc, $intf) = @_; $netc ||= {}; $intf ||= {}; add2hash($netc, read_conf("$prefix/etc/sysconfig/network")) if -r "$prefix/etc/sysconfig/network"; - add2hash($netc, read_resolv_conf("$prefix/etc/resolv.conf")) if -r "$prefix/etc/resolv.conf"; + add2hash($netc, read_resolv_conf()); add2hash($netc, read_tmdns_conf("$prefix/etc/tmdns.conf")) if -r "$prefix/etc/tmdns.conf"; foreach (all("$prefix/etc/sysconfig/network-scripts")) { if (/ifcfg-(\w+)/ && $1 ne 'lo') { |