diff options
author | Arnaud Desmons <adesmons@mandriva.com> | 2002-08-01 15:00:28 +0000 |
---|---|---|
committer | Arnaud Desmons <adesmons@mandriva.com> | 2002-08-01 15:00:28 +0000 |
commit | 1964f241d506956d99e349bc6a9e2a861293a8b2 (patch) | |
tree | 9e6086498151c48c5f199908920fd8ca0aca9f80 | |
parent | 26714a58852da69c9db247db677e166342d152c5 (diff) | |
download | drakwizard-1964f241d506956d99e349bc6a9e2a861293a8b2.tar drakwizard-1964f241d506956d99e349bc6a9e2a861293a8b2.tar.gz drakwizard-1964f241d506956d99e349bc6a9e2a861293a8b2.tar.bz2 drakwizard-1964f241d506956d99e349bc6a9e2a861293a8b2.tar.xz drakwizard-1964f241d506956d99e349bc6a9e2a861293a8b2.zip |
Pixel line's optimisations and bug fixes
-rw-r--r-- | dns_wizard/scripts/Dnsconf.pm | 104 |
1 files changed, 35 insertions, 69 deletions
diff --git a/dns_wizard/scripts/Dnsconf.pm b/dns_wizard/scripts/Dnsconf.pm index e01cc685..744f6cc7 100644 --- a/dns_wizard/scripts/Dnsconf.pm +++ b/dns_wizard/scripts/Dnsconf.pm @@ -4,29 +4,25 @@ package Dnsconf; require "__WIZ_HOME__/common/scripts/Vareqval.pm"; use MDK::Common; use strict; +use standalone; sub up_serial { my ($file) = @_; - my $serial_nbm = `date +%Y%m%d00` or die "date not found: $!"; - my $tmp = `mktemp /tmp/Dnsconf.XXXXXX` or die "can't make a temp file: $!"; - open(OLD, "< $file") or die "can't open $file: $!"; - open(NEW, "> $tmp") or die "can't open $tmp: $!"; - while (<OLD>) { - if (/^([[:space:]]*)([0-9]*)([[:space:]]*;[[:space:]]*Serial.*)$/) { + my $serial_nbm = `date +%Y%m%d00` or die "date not found: $!"; + output($file, map { + my $line = $_; + if (/^(\s*)(\d*)(\s*;\s*Serial.*)$/) { my $serial_f = $2; $serial_f++; if ($serial_f <= $serial_nbm) { $serial_f = $serial_nbm; chomp($serial_f); - $_ = "$1$serial_f$3\n"; + $line = "$1$serial_f$3\n"; } } - print NEW $_; - } - close(OLD) or die "can't close $file: $!"; - close(NEW) or die "can't close $tmp: $!"; - system("mv $tmp $file"); + $line; + } cat_($file)); } sub do_it { @@ -35,9 +31,9 @@ sub do_it { die "wiz_domain_name not in /etc/sysconfig/mdk_serv"; my $wiz_host_name = $mdk{wiz_host_name} if defined $mdk{wiz_host_name} or die "wiz_host_name not in /etc/sysconfig/mdk_serv"; - my $device = $mdk{wiz_device} if defined $mdk{wiz_host_name} or die "wiz_device not in /etc/sysconfig/mdk_serv"; + my %mdk = Vareqval->get("/etc/sysconfig/network-scripts/ifcfg-".$device); my $wiz_ip_net = $mdk{NETWORK} if defined $mdk{NETWORK} or die "NETWORK not in /etc/sysconfig/network-scripts/ifcfg-$device"; @@ -56,87 +52,59 @@ sub do_it { $file = "/etc/named.conf"; MDK::Common::cp_af($file, $file.".orig"); -# now putting ${file} configuration" + standalone::explanations("Now putting $file configuration"); - my $tmp = `mktemp /tmp/Dnsconf.XXXXXX` or die "can't make a temp file: $!"; - open(OLD, "< __WIZ_HOME__/dns_wizard/scripts/host.conf.default") or die "can't open default: $!"; - open(NEW, "> $tmp") or die "can't open $tmp: $!"; my $ispns1 = $ENV{wiz_ext_dns1} || "// __ISPN1__"; my $ispns2 = $ENV{wiz_ext_dns2} || "// __ISPN2__"; - while (<OLD>) { + + output($file, map { s|__ISPNS1__|$ispns1|g; s|__ISPNS2__|$ispns2|g; s|__dname__|$wiz_domain_name|g; s|__revnet__|$reversnet|g; s|__net__|$s_trunc|g; - print NEW $_; - } - close(OLD); - close(NEW); - system("mv $tmp $file"); + $_; + } cat_("__WIZ_HOME__/dns_wizard/scripts/named.conf.default")); # Bug fix for bind 9: - if (! -f "/etc/rndc.key") {system("touch /etc/rndc.key") or die "can not touch /etc/rndc.key: $!"}; + if (! -f "/etc/rndc.key") { system("touch /etc/rndc.key") or die "can not touch /etc/rndc.key"}; # root.hints $file="/var/named/root.hints"; MDK::Common::cp_af($file, $file . ".orig"); MDK::Common::cp_af("__WIZ_HOME__/dns_wizard/scripts/root.hints.default", $file); + +# 127.0.0.rev $file="/var/named/127.0.0.rev"; MDK::Common::cp_af($file, $file . ".orig"); - my $tmp = `mktemp /tmp/Dnsconf.XXXXXX` or - die "can't make a temp file: $!"; - open(NEW, "> $tmp") or - die "can't open $tmp: $!"; - open(OLD, "< __WIZ_HOME__/dns_wizard/scripts/127.0.0.rev.default") or - die "can't open default: $!"; - while (<OLD>) { - s|__hname__|$wiz_host_name|; - print NEW $_; - } - close(OLD); - close(NEW); - system("mv $tmp $file"); + output($file, map { + s|__hname__|$wiz_host_name|g; + $_; + } cat_("__WIZ_HOME__/dns_wizard/scripts/127.0.0.rev.default")); up_serial($file); -#ipnet.rev +# $ipnet.rev $file = "/var/named/$s_trunc.rev"; MDK::Common::cp_af($file, $file.".orig"); - my $tmp = `mktemp /tmp/Dnsconf.XXXXXX` or - die "can't make a temp file: $!"; - open(NEW, "> $tmp") or - die "can't open $tmp: $!"; - open(OLD, "< __WIZ_HOME__/dns_wizard/scripts/ipnet.rev.default") or - die "can't open default: $!"; - while (<OLD>) { + output($file, map { s|__dname__|$wiz_domain_name|g; s|__hname__|$wiz_host_name|g; s|__revnet__|$reversnet|g; - s|__nb__|$ds|; - print NEW $_; - } - close(OLD); - close(NEW); - system("mv $tmp $file"); + s|__nb__|$ds|g; + $_; + } cat_("__WIZ_HOME__/dns_wizard/scripts/ipnet.rev.default")); up_serial($file); +# $domain.db $file = "/var/named/$wiz_domain_name.db"; MDK::Common::cp_af($file, $file.".orig"); - my $tmp = `mktemp /tmp/Dnsconf.XXXXXX` or - die "can't make a temp file: $!"; - open(NEW, "> $tmp") or - die "can't open $tmp: $!"; - open(OLD, "< __WIZ_HOME__/dns_wizard/scripts/domain.db.default") or - die "can't open default: $!"; - while (<OLD>) { + output($file, map { s|__dname__|$wiz_domain_name|g; s|__hname__|$wiz_host_name|g; s|__ip__|$wiz_ip_server|g; - s|__host__|$ENV{host}|g; - print NEW $_; - } - close(OLD); - close(NEW); - system("mv $tmp $file"); + s|__host__|$host|g; + s|__nb__|$ds|g; + $_; + } cat_("__WIZ_HOME__/dns_wizard/scripts/domain.db.default")); up_serial($file); #resolv.conf @@ -145,14 +113,12 @@ sub do_it { open(NEW, "> $file"); print NEW "domain $wiz_domain_name\n"; print NEW "nameserver $wiz_ip_server\n"; - - system("/sbin/chkconfig --level 235 named on") or die "error on running /sbin/chkconfig: $!"; - - system("/etc/rc.d/init.d/named restart") or die "error on restarting /etc/rc.d/init.d/named: $!"; + system("/sbin/chkconfig --level 235 named on"); + system("/etc/rc.d/init.d/named restart"); %mdk = Vareqval->get("/etc/sysconfig/mdk_serv"); $mdk{wiz_caching_dns} = "1"; Vareqval->commit("/etc/sysconfig/mdk_serv", \%mdk); - 1; + 10; } 1; |