From fd4ddf1cf5b7d5f67f0aa5d676e5f90158fb57e7 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Tue, 19 Aug 2014 16:00:52 +0300 Subject: 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. --- vhostcname/vhostcname | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/vhostcname/vhostcname b/vhostcname/vhostcname index d8f76ed..eddb9fd 100755 --- a/vhostcname/vhostcname +++ b/vhostcname/vhostcname @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#!/usr/bin/perl # Copyright (C) 2014 Sergey Poznyakoff # # This program is free software; you can redistribute it and/or modify @@ -233,13 +233,6 @@ 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); @@ -346,14 +339,11 @@ if ($#ARGV == -1) { } 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") { -- cgit v1.2.1