Skip to content

Commit

Permalink
Item12802: exclude server aliases running a command on all hosts; add…
Browse files Browse the repository at this point in the history
…ed =quiet= commandline parameter |

git-svn-id: http://svn.foswiki.org/trunk/VirtualHostingContrib@17405 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Mar 18, 2014
1 parent fa87f9d commit 8cf7445
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 15 deletions.
11 changes: 9 additions & 2 deletions bin/virtualhosts.fcgi
Expand Up @@ -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';
Expand All @@ -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() =~ /^(.*)$/;
Expand All @@ -47,14 +51,15 @@ 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,
'pidfile|p=s' => \$pidfile,
'manager|M=s' => \$manager,
'daemon|d' => \$detach,
'help|?' => \$help,
'quiet|q' => \$quiet,
);

pod2usage(1) if $help;
Expand All @@ -69,6 +74,7 @@ $Foswiki::engine->run(
pidfile => $pidfile,
manager => $manager,
detach => $detach,
quiet => $quiet,
}
);

Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion 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
<!--
One line description, required for extensions repository catalog.
Expand Down Expand Up @@ -490,6 +490,7 @@ Many thanks to [[http://colivre.coop.br/][Colivre]] for supporting this work.
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 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 |
Expand Down
5 changes: 3 additions & 2 deletions lib/Foswiki/Contrib/VirtualHostingContrib.pm
Expand Up @@ -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.';

Expand Down
8 changes: 5 additions & 3 deletions lib/Foswiki/Contrib/VirtualHostingContrib/VirtualHost.pm
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion 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;

Expand Down
2 changes: 1 addition & 1 deletion 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;
Expand Down
3 changes: 2 additions & 1 deletion 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;
Expand Down
2 changes: 1 addition & 1 deletion 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;
Expand Down
2 changes: 1 addition & 1 deletion 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;
Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
3 changes: 2 additions & 1 deletion 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;
Expand Down

0 comments on commit 8cf7445

Please sign in to comment.