From 8cf74454af86256d7a00a3fa8916d4eb31f2349a Mon Sep 17 00:00:00 2001 From: MichaelDaum Date: Tue, 18 Mar 2014 15:09:34 +0000 Subject: [PATCH] Item12802: exclude server aliases running a command on all hosts; added =quiet= commandline parameter | git-svn-id: http://svn.foswiki.org/trunk/VirtualHostingContrib@17405 0b4bb1d4-4e5a-0410-9cc4-b2b747904278 --- bin/virtualhosts.fcgi | 11 +++++++++-- data/System/VirtualHostingContrib.txt | 3 ++- lib/Foswiki/Contrib/VirtualHostingContrib.pm | 5 +++-- .../Contrib/VirtualHostingContrib/VirtualHost.pm | 8 +++++--- tools/virtualhosts-convert-charset | 3 ++- tools/virtualhosts-jsonrpc | 2 +- tools/virtualhosts-lighttpd.pl | 3 ++- tools/virtualhosts-rest | 2 +- tools/virtualhosts-statistics | 2 +- tools/virtualhosts-tick-foswiki | 2 +- tools/virtualhosts-view | 3 ++- 11 files changed, 29 insertions(+), 15 deletions(-) diff --git a/bin/virtualhosts.fcgi b/bin/virtualhosts.fcgi index 7f71dc8..579f0b7 100755 --- a/bin/virtualhosts.fcgi +++ b/bin/virtualhosts.fcgi @@ -24,6 +24,7 @@ # As per the GPL, removal of this notice is prohibited. use strict; +use warnings; BEGIN { $Foswiki::cfg{Engine} = 'Foswiki::Engine::FastCGI'; @@ -37,7 +38,10 @@ use Pod::Usage; use Foswiki; use Foswiki::UI; use Foswiki::Contrib::VirtualHostingContrib; -require Cwd; +use Cwd; + +use Error; +$Error::Debug = 1; our ($script) = $0 =~ /^(.*)$/; our ($dir) = Cwd::cwd() =~ /^(.*)$/; @@ -47,7 +51,7 @@ Foswiki::Engine::FastCGI::reExec() unless $@ =~ /^Insecure dependency in eval/; my @argv = @ARGV; -my ( $listen, $nproc, $pidfile, $manager, $detach, $help ); +my ( $listen, $nproc, $pidfile, $manager, $detach, $help, $quiet ); GetOptions( 'listen|l=s' => \$listen, 'nproc|n=i' => \$nproc, @@ -55,6 +59,7 @@ GetOptions( 'manager|M=s' => \$manager, 'daemon|d' => \$detach, 'help|?' => \$help, + 'quiet|q' => \$quiet, ); pod2usage(1) if $help; @@ -69,6 +74,7 @@ $Foswiki::engine->run( pidfile => $pidfile, manager => $manager, detach => $detach, + quiet => $quiet, } ); @@ -84,6 +90,7 @@ foswiki.fcgi [options] -p --pidfile File used to write pid to -M --manager FCGI manager class -d --daemon Detach from terminal and keeps running as a daemon + -q --quiet Disable notification messages -? --help Display this help and exits Note: diff --git a/data/System/VirtualHostingContrib.txt b/data/System/VirtualHostingContrib.txt index b5de237..dee4475 100644 --- a/data/System/VirtualHostingContrib.txt +++ b/data/System/VirtualHostingContrib.txt @@ -1,4 +1,4 @@ -%META:TOPICINFO{author="BaseUserMapping_999" comment="autosave" date="1356278806" format="1.1" version="1"}% +%META:TOPICINFO{author="ProjectContributor" comment="autosave" date="1356278806" format="1.1" version="1"}% ---+!! !VirtualHostingContrib   | +| 18 Mar 2014: | exclude server aliases running a command on all hosts; added =quiet= commandline parameter | | 10 Jul 2013: | added feature to temporarily disable virtual hosts; -- Foswiki:Main/MichaelDaum | | 01 Jul 2013: | added support for !WebStatistics and a couple of other commandline tools | | 04 Jul 2012: | added foswiki maintenance tools for virtual hosting; -- Foswiki:Main/MichaelDaum | diff --git a/lib/Foswiki/Contrib/VirtualHostingContrib.pm b/lib/Foswiki/Contrib/VirtualHostingContrib.pm index 3e6c8e8..e5d0141 100644 --- a/lib/Foswiki/Contrib/VirtualHostingContrib.pm +++ b/lib/Foswiki/Contrib/VirtualHostingContrib.pm @@ -14,9 +14,10 @@ package Foswiki::Contrib::VirtualHostingContrib; use strict; +use warnings; -use version; our $VERSION = version->declare("v1.1.0"); -our $RELEASE = '10 Jul 2013'; +our $VERSION = '1.11'; +our $RELEASE = '1.11'; our $SHORTDESCRIPTION = 'Adds virtual hosting support for Foswiki.'; diff --git a/lib/Foswiki/Contrib/VirtualHostingContrib/VirtualHost.pm b/lib/Foswiki/Contrib/VirtualHostingContrib/VirtualHost.pm index f4e920c..19d6941 100644 --- a/lib/Foswiki/Contrib/VirtualHostingContrib/VirtualHost.pm +++ b/lib/Foswiki/Contrib/VirtualHostingContrib/VirtualHost.pm @@ -70,7 +70,7 @@ sub hostname { sub exists { my ($class, $hostname) = @_; - return -d $Foswiki::cfg{VirtualHostingContrib}{VirtualHostsDir} . "/$hostname/data" + return -d $Foswiki::cfg{VirtualHostingContrib}{VirtualHostsDir} . "/$hostname/data"; } sub enabled { @@ -110,8 +110,10 @@ sub _merge_config { # StaticMethod sub run_on_each { my ($class, $code) = @_; - my @hostnames = map { basename $_} glob($Foswiki::cfg{VirtualHostingContrib}{VirtualHostsDir} . '/*'); - @hostnames = grep { $class->exists($_) && $_ !~ /^_/ } @hostnames; + + my @hostnames = + grep { $class->exists($_) && $_ !~ /^_/ && !defined($Foswiki::cfg{VirtualHostingContrib}{ServerAlias}{$_}) } + map { basename $_} glob($Foswiki::cfg{VirtualHostingContrib}{VirtualHostsDir} . '/*'); for my $hostname (@hostnames) { my $virtual_host = $class->find($hostname); diff --git a/tools/virtualhosts-convert-charset b/tools/virtualhosts-convert-charset index 06af3c5..1fd6b9d 100755 --- a/tools/virtualhosts-convert-charset +++ b/tools/virtualhosts-convert-charset @@ -1,5 +1,6 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # See bottom of file for license and copyright information + use strict; use warnings; diff --git a/tools/virtualhosts-jsonrpc b/tools/virtualhosts-jsonrpc index fb1f350..04e32b5 100755 --- a/tools/virtualhosts-jsonrpc +++ b/tools/virtualhosts-jsonrpc @@ -1,4 +1,4 @@ -#!/usr/bin/perl -wT +#!/usr/bin/env perl # See bottom of file for license and copyright information use strict; use warnings; diff --git a/tools/virtualhosts-lighttpd.pl b/tools/virtualhosts-lighttpd.pl index a8e8e15..3f5fa5a 100755 --- a/tools/virtualhosts-lighttpd.pl +++ b/tools/virtualhosts-lighttpd.pl @@ -1,6 +1,7 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; +use warnings; use File::Basename; use File::Spec; use Cwd; diff --git a/tools/virtualhosts-rest b/tools/virtualhosts-rest index 7475cff..aa1da6e 100755 --- a/tools/virtualhosts-rest +++ b/tools/virtualhosts-rest @@ -1,4 +1,4 @@ -#!/usr/bin/perl -wT +#!/usr/bin/env perl # See bottom of file for license and copyright information use strict; use warnings; diff --git a/tools/virtualhosts-statistics b/tools/virtualhosts-statistics index aca710a..fe6228c 100755 --- a/tools/virtualhosts-statistics +++ b/tools/virtualhosts-statistics @@ -1,4 +1,4 @@ -#!/usr/bin/perl -wT +#!/usr/bin/env perl # See bottom of file for license and copyright information use strict; use warnings; diff --git a/tools/virtualhosts-tick-foswiki b/tools/virtualhosts-tick-foswiki index 22e9bdd..ea26444 100755 --- a/tools/virtualhosts-tick-foswiki +++ b/tools/virtualhosts-tick-foswiki @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl # See bottom of file for license and copyright information # # The Foswiki 'bin' directory must be on your include path when you run diff --git a/tools/virtualhosts-view b/tools/virtualhosts-view index 2719da8..be6e4ef 100755 --- a/tools/virtualhosts-view +++ b/tools/virtualhosts-view @@ -1,4 +1,5 @@ -#!/usr/bin/perl -wT +#!/usr/bin/env perl + # See bottom of file for license and copyright information use strict; use warnings;