diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-08-19 16:00:52 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-08-19 16:00:52 +0300 |
commit | fd4ddf1cf5b7d5f67f0aa5d676e5f90158fb57e7 (patch) | |
tree | d842e1485a9cca2441a652dc109d4c61702909c0 | |
parent | a192ca696d9531f3f80223cbe31ec361583b921c (diff) | |
download | dnstools-fd4ddf1cf5b7d5f67f0aa5d676e5f90158fb57e7.tar.gz dnstools-fd4ddf1cf5b7d5f67f0aa5d676e5f90158fb57e7.tar.bz2 |
Fixes in vhostcname
* vhostcname (nssetup): Remove. Use update_cnames_from_hash instead.
(main): Call update_cnames_from_hash even if no cnames were gathered,
so that it can generate the proper delete requests.
Call nscleanup only if one of '*start' commands was given.
-rwxr-xr-x | vhostcname/vhostcname | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/vhostcname/vhostcname b/vhostcname/vhostcname index d8f76ed..eddb9fd 100755 --- a/vhostcname/vhostcname +++ b/vhostcname/vhostcname @@ -1,7 +1,7 @@ -#! /usr/bin/perl +#!/usr/bin/perl # Copyright (C) 2014 Sergey Poznyakoff <gray@gnu.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. @@ -230,19 +230,12 @@ sub update_cnames_from_hash { } sub update_cnames_from_dir($) { update_cnames_from_hash(get_cnames(shift)); } -sub nssetup { - if (-f $cnamelist) { - unlink($cnamelist) or abend(1, "can't unlink $cnamelist: $!"); - } - &update_cnames_from_hash; -} - sub nscleanup { print STDERR "$script: Removing DNS CNAME records\n" if ($debug); my $resolver = new Net::DNS::Resolver; $resolver->nameservers($nameserver) if defined($nameserver); @@ -343,20 +336,17 @@ if ($#ARGV == -1) { } update_cnames_from_dir($update_dir) if defined($update_dir); } elsif ($#ARGV != 0) { abend(3, "too many arguments"); } elsif ($ARGV[0] =~ /^start|restart|force-restart|reload$/) { - nscleanup unless ($ARGV[0] eq "start"); + nscleanup if ($ARGV[0] =~ /start$/); my %cnames = get_cnames(-d "$confdir/sites-enabled" ? "$confdir/sites-enabled" : $confdir); - if (keys(%cnames) > 0) { - nssetup(%cnames); - } elsif ($debug) { - print STDERR "$script: no cnames defined\n"; - } + update_cnames_from_hash(%cnames); + print STDERR "$script: no cnames defined\n" unless (keys(%cnames) > 0); } elsif ($ARGV[0] eq "stop") { nscleanup; } elsif ($ARGV[0] eq "status") { err("status command ignored"); } else { abend(3, "invalid command, try $script --help for more info"); |