summaryrefslogtreecommitdiffstats
path: root/client_wizard
diff options
context:
space:
mode:
authorArnaud Desmons <adesmons@mandriva.com>2002-07-30 09:21:05 +0000
committerArnaud Desmons <adesmons@mandriva.com>2002-07-30 09:21:05 +0000
commite57b3f0e3a3c87d77aba1c2b13d36a6bab293197 (patch)
tree5f934e96d8f2e0752a3247e0efc8ec8c3336e994 /client_wizard
parenta648d376af26dd6efa8ed634b93b71efe268fb52 (diff)
downloaddrakwizard-e57b3f0e3a3c87d77aba1c2b13d36a6bab293197.tar
drakwizard-e57b3f0e3a3c87d77aba1c2b13d36a6bab293197.tar.gz
drakwizard-e57b3f0e3a3c87d77aba1c2b13d36a6bab293197.tar.bz2
drakwizard-e57b3f0e3a3c87d77aba1c2b13d36a6bab293197.tar.xz
drakwizard-e57b3f0e3a3c87d77aba1c2b13d36a6bab293197.zip
first perl traduction
Diffstat (limited to 'client_wizard')
-rw-r--r--client_wizard/scripts/Clientconf.pm74
1 files changed, 74 insertions, 0 deletions
diff --git a/client_wizard/scripts/Clientconf.pm b/client_wizard/scripts/Clientconf.pm
new file mode 100644
index 00000000..6917eda3
--- /dev/null
+++ b/client_wizard/scripts/Clientconf.pm
@@ -0,0 +1,74 @@
+#!/usr/bin/perl
+
+package Clientconf;
+require "__WIZ_HOME__/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;