1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#!/usr/bin/perl
package Clientconf;
require "/usr/share/wizards/common/scripts/Vareqval.pm";
use MDK::Common;
use strict;
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: $!";
chomp($tmp);
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_f = $2;
$serial_f++;
if ($serial_f <= $serial_nbm) {
$serial_f = $serial_nbm;
chomp($serial_f);
$_ = "$1$serial_f$3\n";
}
}
print NEW $_;
}
close(OLD) or die "can't close $file: $!";
close(NEW) or die "can't close $tmp: $!";
MDK::Common::cp_af($tmp, $file);
MDK::Common::rm_rf($tmp);
}
sub do_it {
my $date = `date`;
chomp($date);
my %mdk = Vareqval->get("/etc/sysconfig/mdk_serv");
my $wiz_domain_name = $mdk{wiz_domain_name} if defined $mdk{wiz_domain_name} or
die "wiz_domain_name not in /etc/sysconfig/mdk_serv";
my $wiz_device = $mdk{wiz_device} if defined $mdk{wiz_device} or
die "wiz_device not in /etc/sysconfig/mdk_serv";
%mdk = Vareqval->get("/etc/sysconfig/network-scripts/ifcfg-".$wiz_device);
my $wiz_ip_net = $mdk{NETWORK} if defined $mdk{NETWORK} or
die "NETWORK not in /etc/sysconfig/network-scripts/ifcfg-".$wiz_device;
my $wiz_ip_server = $mdk{IPADDR} if defined $mdk{IPADDR} or
die "IPADDR not in /etc/sysconfig/network-scripts/ifcfg-".$wiz_device;
my $wiz_client_ip = $ENV{wiz_client_ip} if defined $ENV{wiz_client_ip} or
die "wiz_client_ip not in env";
my $wiz_client_name = $ENV{wiz_client_name} if defined $ENV{wiz_client_name} or
die "wiz_client_name not in env";
my $s_trunc = "$1.$2.$3" if $wiz_ip_net =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/ or
die "bad wiz_ip_net";
my $ds = "$4" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/ or
die "bad wiz_ip_server";
my $dc = "$4" if $wiz_client_ip =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/ or
die "bad wiz_client_ip";
my $file="/var/named/$wiz_domain_name.db";
MDK::Common::cp_af($file, $file.".orig");
open(NEW, ">> $file") or die "can not open $file";
print NEW "\n$wiz_client_name IN A $wiz_client_ip ; $date";
close(NEW) or die "can not close $file";
up_serial($file);
my $file="/var/named/$s_trunc.rev";
MDK::Common::cp_af($file, $file.".orig");
open(NEW, ">> $file") or die "can not open $file";
print NEW "\n$dc IN PTR $wiz_client_name. ; $date";
close(NEW) or die "can not close $file";
up_serial($file);
system("/etc/rc.d/init.d/named restart");
10;
}
1;
|