aboutsummaryrefslogtreecommitdiff
path: root/vhostcname/vhostcname
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2014-04-07 18:33:20 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2014-04-07 18:44:34 +0300
commit4b33ead863f88572adb078ce32564442b2065134 (patch)
treec34e249792fb69537f335af703f33e2070b85274 /vhostcname/vhostcname
parentc0b781cba4750d1458aa1f95736c3c4ad9df8c41 (diff)
downloaddnstools-4b33ead863f88572adb078ce32564442b2065134.tar.gz
dnstools-4b33ead863f88572adb078ce32564442b2065134.tar.bz2
vhostcname improvements
* vhostcname/vhostcname: Remove the shebang. (ns_update): Ignore error codes supplied with the 'ignore' keyword. (update_cnames_from_hash): Ignore NXDOMAIN and NXRRSET. (nscleanup): Ignore NXRRSET Print the "removing ..." line only if debug is on.
Diffstat (limited to 'vhostcname/vhostcname')
-rwxr-xr-xvhostcname/vhostcname28
1 files changed, 21 insertions, 7 deletions
diff --git a/vhostcname/vhostcname b/vhostcname/vhostcname
index 22307b7..0f1cf95 100755
--- a/vhostcname/vhostcname
+++ b/vhostcname/vhostcname
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+# -*- perl -*-
# Copyright (C) 2014 Sergey Poznyakoff <gray@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
@@ -143,6 +143,7 @@ sub ns_update {
my $name = shift;
my $domain = shift;
my %hash = @_;
+ my %ignorerr;
print STDERR "$script: updating $name in $domain: ".
join(',', map { "$_ => $hash{$_}" } keys %hash) .
@@ -152,13 +153,21 @@ sub ns_update {
my $update = new Net::DNS::Update($domain);
while (my ($k, $v) = each %hash) {
- $update->push($k => $v);
+ if ($k eq 'ignore') {
+ $ignorerr{$v} = 1;
+ } else {
+ $update->push($k => $v);
+ }
}
$update->sign_tsig($nskey) if defined($nskey);
my $reply = $resolver->send($update);
if ($reply) {
if ($reply->header->rcode eq 'NOERROR') {
print STDERR "$script: update successful\n" if ($debug>3);
+ } elsif ($ignorerr{$reply->header->rcode}) {
+ print STDERR "$script: ignoring " . $reply->header->rcode . ': ' .
+ join(',', map { "$_ => $hash{$_}" } keys %hash) . "\n"
+ if ($debug>3);
} else {
err("updating $name failed: ",
join(',', map { "$_ => $hash{$_}" } keys %hash),
@@ -200,8 +209,9 @@ sub update_cnames_from_hash {
} else {
ns_update($resolver, $name, $hash{$name},
prereq => yxdomain($name),
- update => rr_del($name));
- print "$name $ttl CNAME $host\n";
+ update => rr_del($name),
+ ignore => 'NXDOMAIN');
+ print STDERR "$script: $name $ttl CNAME $host\n" if ($debug);
delete $hash{$name}
unless ns_update($resolver, $name, $hash{$name},
update => rr_add("$name $ttl CNAME $host"));
@@ -211,7 +221,8 @@ sub update_cnames_from_hash {
foreach $name (keys %oldhash) {
ns_update($resolver, $name, $oldhash{$name},
prereq => yxrrset("$name CNAME"),
- update => rr_del("$name CNAME"));
+ update => rr_del("$name CNAME"),
+ ignore => 'NXRRSET');
}
write_cname_list($cnamelist, %hash);
@@ -236,10 +247,13 @@ sub nscleanup {
my %hash = read_cname_list($cnamelist);
foreach my $name (keys %hash) {
+ print STDERR "$script: removing $name from $hash{$name}\n"
+ if ($debug);
delete $hash{$name}
if ns_update($resolver, $name, $hash{$name},
prereq => yxrrset("$name CNAME"),
- update => rr_del("$name CNAME"));
+ update => rr_del("$name CNAME"),
+ ignore => 'NXRRSET');
}
write_cname_list($cnamelist, %hash);
@@ -368,7 +382,7 @@ For example, on Debian-based GNU/Linux:
ln -sf /usr/bin/vhostcname /etc/init.d
update-rc.d vhostcname defaults
-The program can also be used as a B<dircond>(8) handler. This use
+The program can also be ised as a B<dircond>(8) handler. This use
allows for immediate updates of the DNS records upon any modifications
to the Apache configuration files. The following example shows the
corresponding B<dircond.conf>(5) entry:

Return to:

Send suggestions and report system problems to the System administrator.