Make sure $webguiRoot is setup consistently in all utility scripts.

Some scripts had a hardcoded use lib "../lib" and "../.." on
Session/Config method calls. This was changed to a BEGIN prologue
where @INC gets $webguiRoot added, and the method calls use
$webguiRoot instead.

This eases the creation of patches for filesystem reorganization of
the installed files (e.g. for Debian packages).
This commit is contained in:
Ernesto Hernández-Novich 2008-06-09 15:23:26 +00:00
parent 8dc4216edd
commit 8be24aec80
8 changed files with 59 additions and 17 deletions

View file

@ -8,7 +8,13 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
use lib "../lib"; our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use Getopt::Long; use Getopt::Long;
use Pod::Usage; use Pod::Usage;
use strict; use strict;
@ -46,7 +52,7 @@ finish($session);
#------------------------------------------------- #-------------------------------------------------
sub start { sub start {
my $session = WebGUI::Session->open("../",$configFile); my $session = WebGUI::Session->open($webguiRoot,$configFile);
$session->user({userId=>3}); $session->user({userId=>3});
return $session; return $session;
} }

View file

@ -8,7 +8,13 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
use lib "../lib"; our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use strict; use strict;
use Getopt::Long; use Getopt::Long;
use Pod::Usage; use Pod::Usage;
@ -84,7 +90,7 @@ sub start {
pod2usage("$0: Must specify a --configFile"); pod2usage("$0: Must specify a --configFile");
} }
my $session = WebGUI::Session->open("..",$configFile); my $session = WebGUI::Session->open($webguiRoot,$configFile);
$session->user({userId=>3}); $session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session); my $versionTag = WebGUI::VersionTag->getWorking($session);

View file

@ -8,7 +8,13 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
use lib "../lib"; our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use strict; use strict;
use Getopt::Long; use Getopt::Long;
use Pod::Usage; use Pod::Usage;
@ -84,7 +90,7 @@ sub start {
pod2usage("$0: Must specify a --configFile"); pod2usage("$0: Must specify a --configFile");
} }
my $session = WebGUI::Session->open("..",$configFile); my $session = WebGUI::Session->open($webguiRoot,$configFile);
$session->user({userId=>3}); $session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session); my $versionTag = WebGUI::VersionTag->getWorking($session);

View file

@ -8,7 +8,13 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
use lib "../lib"; our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use strict; use strict;
use Getopt::Long; use Getopt::Long;
use Pod::Usage; use Pod::Usage;
@ -23,7 +29,7 @@ GetOptions(
pod2usage( verbose => 2 ) if $help; pod2usage( verbose => 2 ) if $help;
pod2usage() if $configFile eq ''; pod2usage() if $configFile eq '';
my $config = WebGUI::Config->new("..",$configFile); my $config = WebGUI::Config->new($webguiRoot,$configFile);
use File::Find; use File::Find;
print "\tRemoving unnecessary .wgaccess files.\n"; print "\tRemoving unnecessary .wgaccess files.\n";

View file

@ -8,8 +8,14 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use strict; use strict;
use lib '../lib';
use Getopt::Long; use Getopt::Long;
use WebGUI::Asset; use WebGUI::Asset;
use WebGUI::Config; use WebGUI::Config;
@ -39,7 +45,7 @@ GetOptions(
pod2usage( verbose => 2 ) if $help; pod2usage( verbose => 2 ) if $help;
if ($configFile) { if ($configFile) {
my $session = WebGUI::Session->open("..", $configFile); my $session = WebGUI::Session->open($webguiRoot, $configFile);
if ($indexsite) { if ($indexsite) {
reindexSite($session); reindexSite($session);
} elsif ($updatesite) { } elsif ($updatesite) {
@ -59,10 +65,10 @@ if ($configFile) {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub reindexAllSites { sub reindexAllSites {
my $configs = WebGUI::Config->readAllConfigs(".."); my $configs = WebGUI::Config->readAllConfigs($webguiRoot);
foreach my $site (keys %{$configs}) { foreach my $site (keys %{$configs}) {
print "Indexing ".$site."...\n"; print "Indexing ".$site."...\n";
my $session = WebGUI::Session->open("..",$site); my $session = WebGUI::Session->open($webguiRoot,$site);
reindexSite($session); reindexSite($session);
$session->var->end; $session->var->end;
$session->close; $session->close;

View file

@ -8,10 +8,16 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use Pod::Usage; use Pod::Usage;
use strict; use strict;
use warnings; use warnings;
use lib '../lib';
use Getopt::Long; use Getopt::Long;
use POE::Component::IKC::ClientLite; use POE::Component::IKC::ClientLite;
use Spectre::Admin; use Spectre::Admin;
@ -42,7 +48,7 @@ pod2usage( verbose => 2 ) if $help;
pod2usage() unless ($ping||$shutdown||$daemon||$run||$test||$status); pod2usage() unless ($ping||$shutdown||$daemon||$run||$test||$status);
require File::Spec; require File::Spec;
my $config = WebGUI::Config->new(File::Spec->rel2abs(".."),"spectre.conf",1); my $config = WebGUI::Config->new($webguiRoot,"spectre.conf",1);
unless (defined $config) { unless (defined $config) {
print <<STOP; print <<STOP;

View file

@ -8,6 +8,13 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
#----------------------------------------- #-----------------------------------------
# A little utility to generate WebGUI # A little utility to generate WebGUI
# thumbnails. # thumbnails.
@ -32,7 +39,6 @@ BEGIN {
} }
} }
use lib "../lib";
use WebGUI::Utility; use WebGUI::Utility;
my $thumbnailSize; my $thumbnailSize;

View file

@ -149,7 +149,7 @@ if ($history) {
print "\nDisplaying upgrade history for each site.\n"; print "\nDisplaying upgrade history for each site.\n";
foreach my $file (keys %config) { foreach my $file (keys %config) {
print "\n".$file."\n"; print "\n".$file."\n";
my $session = WebGUI::Session->open("../..",$file); my $session = WebGUI::Session->open($webguiRoot,$file);
my $sth = $session->db->read("select * from webguiVersion order by dateApplied asc, webguiVersion asc"); my $sth = $session->db->read("select * from webguiVersion order by dateApplied asc, webguiVersion asc");
while (my $data = $sth->hashRef) { while (my $data = $sth->hashRef) {
print "\t".sprintf("%-8s %-15s %-15s", print "\t".sprintf("%-8s %-15s %-15s",
@ -237,7 +237,7 @@ foreach my $filename (keys %config) {
$notRun = 0; $notRun = 0;
sleep 1; # Sleep a second to avoid adding asset revisions too quickly sleep 1; # Sleep a second to avoid adding asset revisions too quickly
} }
my $session = WebGUI::Session->open("../..",$filename); my $session = WebGUI::Session->open($webguiRoot,$filename);
print "\tSetting site upgrade completed..." unless ($quiet); print "\tSetting site upgrade completed..." unless ($quiet);
$session->setting->remove('specialState'); $session->setting->remove('specialState');
$session->close(); $session->close();