From f589c6c8db6a460fb5a46b1c7cb9493d4bc49a87 Mon Sep 17 00:00:00 2001 From: Arnaud Desmons Date: Mon, 2 Sep 2002 14:04:53 +0000 Subject: use of drakconnect db --- client_wizard/client.wiz | 2 +- client_wizard/scripts/Clientconf.pm | 73 ++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 38 deletions(-) (limited to 'client_wizard') diff --git a/client_wizard/client.wiz b/client_wizard/client.wiz index f27bd316..560ce447 100644 --- a/client_wizard/client.wiz +++ b/client_wizard/client.wiz @@ -80,7 +80,7 @@ new(); +my $wiz_domain_name = $o->get("DomainName"); +my $wiz_ip_server = $o->get_from_known_dev("IP"); 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 () { - 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: $!"; - MDK::Common::cp_af($tmp, $file); - MDK::Common::rm_rf($tmp); + $line; + } cat_($file)); +} + +sub test { + !$ENV{wiz_client_name} and return 1; + !$ENV{wiz_client_ip} and return 1; + my $s_trunc = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + my $ds = "$4" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + my $dc = "$4" if $ENV{wiz_client_ip} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + my $sc_trunc = "$1.$2.$3" if $ENV{wiz_client_ip} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + !$sc_trunc and return 1; + !$dc and return 1; + !$ds and return 1; + !$s_trunc and return 1; + ($s_trunc != $sc_trunc) and return 1; + ($dc == $ds || $dc < 0 || $dc > 255) and return 1; + return 10; } 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 $wiz_ip_net = "$1.$2.$3.0" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + my $s_trunc = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + my $ds = "$4" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + my $dc = "$4" if $ENV{wiz_client_ip} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + 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"; + print NEW "\n$ENV{wiz_client_name} IN A $ENV{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"; + print NEW "\n$dc IN PTR $ENV{wiz_client_name}. ; $date"; close(NEW) or die "can not close $file"; up_serial($file); system("/etc/rc.d/init.d/named restart"); -- cgit v1.2.1