summaryrefslogtreecommitdiffstats
path: root/client_wizard/scripts
diff options
context:
space:
mode:
authorArnaud Desmons <adesmons@mandriva.com>2002-09-02 14:04:53 +0000
committerArnaud Desmons <adesmons@mandriva.com>2002-09-02 14:04:53 +0000
commitf589c6c8db6a460fb5a46b1c7cb9493d4bc49a87 (patch)
tree8a058bac5b007cb3edd8e98cb5367ed6eec44e7c /client_wizard/scripts
parent1f6123d9e2715ca4b2fb6e92f26ff2747e46fe66 (diff)
downloaddrakwizard-f589c6c8db6a460fb5a46b1c7cb9493d4bc49a87.tar
drakwizard-f589c6c8db6a460fb5a46b1c7cb9493d4bc49a87.tar.gz
drakwizard-f589c6c8db6a460fb5a46b1c7cb9493d4bc49a87.tar.bz2
drakwizard-f589c6c8db6a460fb5a46b1c7cb9493d4bc49a87.tar.xz
drakwizard-f589c6c8db6a460fb5a46b1c7cb9493d4bc49a87.zip
use of drakconnect db
Diffstat (limited to 'client_wizard/scripts')
-rw-r--r--client_wizard/scripts/Clientconf.pm73
1 files changed, 36 insertions, 37 deletions
diff --git a/client_wizard/scripts/Clientconf.pm b/client_wizard/scripts/Clientconf.pm
index 6917eda3..6c567a16 100644
--- a/client_wizard/scripts/Clientconf.pm
+++ b/client_wizard/scripts/Clientconf.pm
@@ -2,70 +2,69 @@
package Clientconf;
require "__WIZ_HOME__/common/scripts/Vareqval.pm";
+require "__WIZ_HOME__/common/scripts/DrakconnectConf.pm";
use MDK::Common;
use strict;
+use standalone;
+
+my $o = DrakconnectConf->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 (<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: $!";
- 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");