From 8be24aec80918a7a6c8e7a238f02cf1aa2b21d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20Hern=C3=A1ndez-Novich?= Date: Mon, 9 Jun 2008 15:23:26 +0000 Subject: [PATCH] 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). --- sbin/diskUsage.pl | 10 ++++++++-- sbin/migrateCollabToGallery.pl | 10 ++++++++-- sbin/migrateFolderToGallery.pl | 10 ++++++++-- sbin/purgeWGAccess.pl | 10 ++++++++-- sbin/search.pl | 14 ++++++++++---- sbin/spectre.pl | 10 ++++++++-- sbin/thumbnailer.pl | 8 +++++++- sbin/upgrade.pl | 4 ++-- 8 files changed, 59 insertions(+), 17 deletions(-) diff --git a/sbin/diskUsage.pl b/sbin/diskUsage.pl index b39a1be86..f7413ce67 100644 --- a/sbin/diskUsage.pl +++ b/sbin/diskUsage.pl @@ -8,7 +8,13 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -use lib "../lib"; +our ($webguiRoot); + +BEGIN { + $webguiRoot = ".."; + unshift (@INC, $webguiRoot."/lib"); +} + use Getopt::Long; use Pod::Usage; use strict; @@ -46,7 +52,7 @@ finish($session); #------------------------------------------------- sub start { - my $session = WebGUI::Session->open("../",$configFile); + my $session = WebGUI::Session->open($webguiRoot,$configFile); $session->user({userId=>3}); return $session; } diff --git a/sbin/migrateCollabToGallery.pl b/sbin/migrateCollabToGallery.pl index 2f6acd8f2..f447f1cd3 100644 --- a/sbin/migrateCollabToGallery.pl +++ b/sbin/migrateCollabToGallery.pl @@ -8,7 +8,13 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -use lib "../lib"; +our ($webguiRoot); + +BEGIN { + $webguiRoot = ".."; + unshift (@INC, $webguiRoot."/lib"); +} + use strict; use Getopt::Long; use Pod::Usage; @@ -84,7 +90,7 @@ sub start { pod2usage("$0: Must specify a --configFile"); } - my $session = WebGUI::Session->open("..",$configFile); + my $session = WebGUI::Session->open($webguiRoot,$configFile); $session->user({userId=>3}); my $versionTag = WebGUI::VersionTag->getWorking($session); diff --git a/sbin/migrateFolderToGallery.pl b/sbin/migrateFolderToGallery.pl index f550aecaf..782c40d0b 100644 --- a/sbin/migrateFolderToGallery.pl +++ b/sbin/migrateFolderToGallery.pl @@ -8,7 +8,13 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -use lib "../lib"; +our ($webguiRoot); + +BEGIN { + $webguiRoot = ".."; + unshift (@INC, $webguiRoot."/lib"); +} + use strict; use Getopt::Long; use Pod::Usage; @@ -84,7 +90,7 @@ sub start { pod2usage("$0: Must specify a --configFile"); } - my $session = WebGUI::Session->open("..",$configFile); + my $session = WebGUI::Session->open($webguiRoot,$configFile); $session->user({userId=>3}); my $versionTag = WebGUI::VersionTag->getWorking($session); diff --git a/sbin/purgeWGAccess.pl b/sbin/purgeWGAccess.pl index 6eeb9e512..7d47c6689 100644 --- a/sbin/purgeWGAccess.pl +++ b/sbin/purgeWGAccess.pl @@ -8,7 +8,13 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -use lib "../lib"; +our ($webguiRoot); + +BEGIN { + $webguiRoot = ".."; + unshift (@INC, $webguiRoot."/lib"); +} + use strict; use Getopt::Long; use Pod::Usage; @@ -23,7 +29,7 @@ GetOptions( pod2usage( verbose => 2 ) if $help; pod2usage() if $configFile eq ''; -my $config = WebGUI::Config->new("..",$configFile); +my $config = WebGUI::Config->new($webguiRoot,$configFile); use File::Find; print "\tRemoving unnecessary .wgaccess files.\n"; diff --git a/sbin/search.pl b/sbin/search.pl index 033cda1e6..a3389d956 100644 --- a/sbin/search.pl +++ b/sbin/search.pl @@ -8,8 +8,14 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- +our ($webguiRoot); + +BEGIN { + $webguiRoot = ".."; + unshift (@INC, $webguiRoot."/lib"); +} + use strict; -use lib '../lib'; use Getopt::Long; use WebGUI::Asset; use WebGUI::Config; @@ -39,7 +45,7 @@ GetOptions( pod2usage( verbose => 2 ) if $help; if ($configFile) { - my $session = WebGUI::Session->open("..", $configFile); + my $session = WebGUI::Session->open($webguiRoot, $configFile); if ($indexsite) { reindexSite($session); } elsif ($updatesite) { @@ -59,10 +65,10 @@ if ($configFile) { #------------------------------------------------------------------- sub reindexAllSites { - my $configs = WebGUI::Config->readAllConfigs(".."); + my $configs = WebGUI::Config->readAllConfigs($webguiRoot); foreach my $site (keys %{$configs}) { print "Indexing ".$site."...\n"; - my $session = WebGUI::Session->open("..",$site); + my $session = WebGUI::Session->open($webguiRoot,$site); reindexSite($session); $session->var->end; $session->close; diff --git a/sbin/spectre.pl b/sbin/spectre.pl index fb3e16b66..4a0da5e89 100644 --- a/sbin/spectre.pl +++ b/sbin/spectre.pl @@ -8,10 +8,16 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- +our ($webguiRoot); + +BEGIN { + $webguiRoot = ".."; + unshift (@INC, $webguiRoot."/lib"); +} + use Pod::Usage; use strict; use warnings; -use lib '../lib'; use Getopt::Long; use POE::Component::IKC::ClientLite; use Spectre::Admin; @@ -42,7 +48,7 @@ pod2usage( verbose => 2 ) if $help; pod2usage() unless ($ping||$shutdown||$daemon||$run||$test||$status); 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) { print <open("../..",$file); + my $session = WebGUI::Session->open($webguiRoot,$file); my $sth = $session->db->read("select * from webguiVersion order by dateApplied asc, webguiVersion asc"); while (my $data = $sth->hashRef) { print "\t".sprintf("%-8s %-15s %-15s", @@ -237,7 +237,7 @@ foreach my $filename (keys %config) { $notRun = 0; 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); $session->setting->remove('specialState'); $session->close();