diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-04-07 17:04:58 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-04-07 17:04:58 +0300 |
commit | 00db581c2eda92d1eb4b642fc4c2ca5a7016d0e3 (patch) | |
tree | 99caebee2efe8edc8bed084b0c79f38a284ff376 /vhostcname/vhostcname | |
parent | b12e3a907ec855affb3b91ae924e54887b90f3a8 (diff) | |
download | dnstools-00db581c2eda92d1eb4b642fc4c2ca5a7016d0e3.tar.gz dnstools-00db581c2eda92d1eb4b642fc4c2ca5a7016d0e3.tar.bz2 |
Minor changes.
* .gitignore: Update.
* vhostcname/rc.vhostnames: Update
* vhostcname/vhostcname: Fix references to dircond manpage.
Diffstat (limited to 'vhostcname/vhostcname')
-rwxr-xr-x | vhostcname/vhostcname | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/vhostcname/vhostcname b/vhostcname/vhostcname index 1d2562d..637f726 100755 --- a/vhostcname/vhostcname +++ b/vhostcname/vhostcname @@ -40,6 +40,8 @@ my $debug; my $help; # Display help summary my $man; # Ditto in manpage format +my $status = 0; + sub err { print STDERR "$script: "; print STDERR $_ for (@_); @@ -162,6 +164,7 @@ sub ns_update { join(',', map { "$_ => $hash{$_}" } keys %hash), ': ', $reply->header->rcode); + $status = 2; return 0; } } else { @@ -169,6 +172,7 @@ sub ns_update { join(',', map { "$_ => $hash{$_}" } keys %hash), ': ', $resolver->errorstring); + $status = 2; return 0; } return 1; @@ -219,7 +223,7 @@ sub update_cnames_from_dir($) { sub nssetup { if (-f $cnamelist) { - unlink($cnamelist) or abend("can't unlink $cnamelist: $!"); + unlink($cnamelist) or abend(1, "can't unlink $cnamelist: $!"); } &update_cnames_from_hash; } @@ -261,7 +265,7 @@ GetOptions("help" => \$man, "zone|z=s@" => \@zone, "ttl=i" => \$ttl, "server=s" => \$nameserver, - ) or exit(1); + ) or exit(3); pod2usage(-message => "$script: update DNS from Apache virtual host configuration", -exitstatus => 0) if $help; @@ -278,7 +282,8 @@ unless (defined($confdir)) { last; } } - abend(1, "don't know where virtual host configurations are located; use --apache-config-directory option") + abend(3, + "don't know where virtual host configurations are located; use --apache-config-directory option") unless defined($confdir); } @@ -287,7 +292,7 @@ push(@zone, $host) if ($#zone == -1); $debug++ if ($dry_run); if ($#ARGV == -1) { - abend(1, "command not given") unless ($ENV{'DIRCOND_FILE'}); + abend(3, "command not given") unless ($ENV{'DIRCOND_FILE'}); print STDERR "$script: started as dircond handler for " . "$ENV{'DIRCOND_GENEV_NAME'} on $ENV{'DIRCOND_FILE'}\n" if ($debug); @@ -312,7 +317,7 @@ if ($#ARGV == -1) { update_cnames_from_dir($update_dir) if defined($update_dir); } elsif ($#ARGV != 0) { - abend(1, "too many arguments"); + abend(3, "too many arguments"); } elsif ($ARGV[0] =~ /^start|restart|force-restart|reload$/) { nscleanup unless ($ARGV[0] eq "start"); my %cnames = get_cnames(-d "$confdir/sites-enabled" ? @@ -327,9 +332,11 @@ if ($#ARGV == -1) { } elsif ($ARGV[0] eq "status") { err("status command ignored"); } else { - abend(1, "invalid command, try $script --help for more info"); + abend(3, "invalid command, try $script --help for more info"); } +exit($status); + __END__ =head1 NAME @@ -361,7 +368,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 ised as a B<dircond>(1) 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: @@ -483,21 +490,43 @@ optional whitespace around the equals sign. Valid option names are the same as the long command line options, but without the leading B<-->. For example: - zone=vhost.example.com - ns-key=/etc/bind/Kvhost+157+43558.key - ttl=3600 + zone = vhost.example.com + ns-key = /etc/bind/Kvhost+157+43558.key + ttl = 3600 =head1 ENVIRONMENT =over 4 -=item VHOSTCNAME_CONF +=item B<VHOSTCNAME_CONF> The name of the configuration file to use instead of the default F</etc/vhostcname.conf>. =back +=head1 EXIT CODE + +=over 4 + +=item 0 + +Success + +=item 1 + +Operating system error (unable to open file, etc.) + +=item 2 + +Some of the host names could not be registered. + +=item 3 + +Command line usage error + +=back + =head1 BUGS Only one key file can be given. This means that if you use multiple @@ -506,7 +535,7 @@ DNSSEC key. Ditto for the B<--server> option. =head1 SEE ALSO -B<dircond>(1). +B<dircond>(8). =head1 AUTHOR |