From aaa0924dc7523cd7a918f1c5aa5b46b8b93499f1 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Thu, 15 Apr 2010 14:02:39 -0500 Subject: [PATCH] allow running sbin scripts from any directory --- sbin/_utility.skeleton | 14 +- sbin/changeIobStatus.pl | 372 ++++++++++++++++++++-------------------- sbin/diskUsage.pl | 10 +- sbin/fileImport.pl | 15 +- sbin/galleryImport.pl | 12 +- sbin/generateContent.pl | 12 +- sbin/installClass.pl | 10 +- sbin/maintenanceMode.pl | 11 +- sbin/purgeWGAccess.pl | 10 +- sbin/rebuildLineage.pl | 13 +- sbin/search.pl | 10 +- sbin/spectre.pl | 10 +- sbin/syncToCdn.pl | 12 +- sbin/testCodebase.pl | 14 +- sbin/testEnvironment.pl | 11 +- sbin/thumbnailer.pl | 9 +- sbin/upgrade.pl | 10 +- sbin/userImport.pl | 10 +- 18 files changed, 310 insertions(+), 255 deletions(-) mode change 100644 => 100755 sbin/syncToCdn.pl diff --git a/sbin/_utility.skeleton b/sbin/_utility.skeleton index 18c08945e..7c8d45b11 100644 --- a/sbin/_utility.skeleton +++ b/sbin/_utility.skeleton @@ -10,15 +10,19 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -$|++; # disable output buffering -our ($webguiRoot, $configFile, $help, $man); +use strict; +use File::Basename (); +use File::Spec; +my $webguiRoot; BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } -use strict; +$|++; # disable output buffering + +our ($configFile, $help, $man); use Pod::Usage; use Getopt::Long; use WebGUI::Session; diff --git a/sbin/changeIobStatus.pl b/sbin/changeIobStatus.pl index e42b76b6a..3769e333a 100755 --- a/sbin/changeIobStatus.pl +++ b/sbin/changeIobStatus.pl @@ -1,185 +1,187 @@ -#!/usr/bin/env perl - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2009 Plain Black Corporation. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - -our ($webguiRoot); - -BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); -} - -use Getopt::Long; -use Pod::Usage; -use strict; -use WebGUI::Session; -use WebGUI::User; -use WebGUI::Inbox; - -$|=1; - -my $configFile; -my $help; -my $quiet; -my $whatsHappening = "Automatically signed out."; -my $newStatus = "Out"; -my $currentStatus = "In"; -my $userMessage = "You were logged out of the In/Out Board automatically."; -my $userMessageFile; - - -GetOptions( - 'configfile=s'=>\$configFile, - 'help'=>\$help, - 'quiet'=>\$quiet, - 'whatsHappening:s'=>\$whatsHappening, - 'userMessage:s'=>\$userMessage, - 'userMessageFile:s'=>\$userMessageFile, - 'currentStatus:s'=>\$currentStatus, - 'newStatus:s'=>\$newStatus -); - -pod2usage( verbose => 2 ) if $help; -pod2usage() unless $configFile; - -print "Starting up...\n" unless ($quiet); -my $session = WebGUI::Session->open($webguiRoot,$configFile); - -if ($userMessageFile) { - print "Opening message file.." unless ($quiet); - if (open(FILE,"<".$userMessageFile)) { - print "OK\n" unless ($quiet); - my $contents; - while () { - $contents .= $_; - } - close(FILE); - if (length($contents) == 0) { - print "Message file empty, reverting to original message.\n"; - } else { - $userMessage = $contents; - } - } else { - print "Failed to open message file.\n"; - } -} - -print "Searching for users with a status of $currentStatus ...\n" unless ($quiet); -my $userList; -my $now = time(); -my $inbox = WebGUI::Inbox->new($session); -my $sth = $session->db->read("select userId,assetId from InOutBoard_status where status=?",[$currentStatus]); -while (my ($userId,$assetId) = $sth->array) { - my $user = WebGUI::User->new($session, $userId); - print "\tFound user ".$user->username."\n" unless ($quiet); - $userList .= $user->username." (".$userId.")\n"; - $session->db->write("update InOutBoard_status set dateStamp=?, message=?, status=? where userId=? and assetId=?",[$now, $whatsHappening, $newStatus, $userId, $assetId]); - $session->db->write("insert into InOutBoard_statusLog (userId, createdBy, dateStamp, message, status, assetId) values (?,?,?,?,?,?)", - [$userId,3,$now, $whatsHappening, $newStatus, $assetId]); - $inbox->addMessage({ - userId=>$userId, - subject=>"IOB Update", - message=>$userMessage - }); -} - -if (length($userList) > 0) { - print "Alerting admins of changes\n" unless ($quiet); - my $message = "The following users had their status changed:\n\n".$userList; - $inbox->addMessage({ - groupId=>3, - subject=>"IOB Update", - message=>$userMessage - }); -} - -print "Cleaning up..." unless ($quiet); -$session->var->end; -$session->close; -print "OK\n" unless ($quiet); - -__END__ - -=head1 NAME - -changeIobStatus - Automate WebGUI's InOut Board User status switching. - -=head1 SYNOPSIS - - changeIobStatus --configFile config.conf - [--currentStatus status] - [--newStatus status] - [--userMessage text|--userMessageFile pathname] - [--whatsHappening text] - [--quiet] - - changeIobStatus --help - -=head1 DESCRIPTION - -This WebGUI utility script helps you switch one or more user status -in the InOut Board (IOB). For instance, you might want to run it -from cron each night to automatically mark out all users that haven't -already marked out. - -=over - -=item B<--configFile config.conf> - -The WebGUI config file to use. Only the file name needs to be specified, -since it will be looked up inside WebGUI's configuration directory. -This parameter is required. - -=item B<--currentStatus status> - -Check users in the IOB having B status. If left unspecified, -it will default to C. - -=item B<--newStatus status> - -Change users status in the IOB to B status. If left unspecified, -it will default to C. - -=item B<--userMessage msg> - -Text of the message to be sent to the user after changing the status. -If left unspecified it will default to - - You were logged out of the In/Out Board automatically. - -=item B<--userMessageFile pathname> - -Pathname to a file whose contents will be sent to the user after changing -the status. Using this option overrides whatever messages is set -with B<--userMessage> (see above). - -=item B<--whatsHappening text> - -The message attached to the InOut Board when changing status. If left -unspecified it defaults to - - Automatically signed out. - -=item B<--quiet> - -Disable all output unless there's an error. - -=item B<--help> - -Shows this documentation, then exits. - -=back - -=head1 AUTHOR - -Copyright 2001-2009 Plain Black Corporation. - -=cut +#!/usr/bin/env perl + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2009 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use File::Basename (); +use File::Spec; + +my $webguiRoot; +BEGIN { + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); +} + +use Getopt::Long; +use Pod::Usage; +use WebGUI::Session; +use WebGUI::User; +use WebGUI::Inbox; + +$|=1; + +my $configFile; +my $help; +my $quiet; +my $whatsHappening = "Automatically signed out."; +my $newStatus = "Out"; +my $currentStatus = "In"; +my $userMessage = "You were logged out of the In/Out Board automatically."; +my $userMessageFile; + + +GetOptions( + 'configfile=s'=>\$configFile, + 'help'=>\$help, + 'quiet'=>\$quiet, + 'whatsHappening:s'=>\$whatsHappening, + 'userMessage:s'=>\$userMessage, + 'userMessageFile:s'=>\$userMessageFile, + 'currentStatus:s'=>\$currentStatus, + 'newStatus:s'=>\$newStatus +); + +pod2usage( verbose => 2 ) if $help; +pod2usage() unless $configFile; + +print "Starting up...\n" unless ($quiet); +my $session = WebGUI::Session->open($webguiRoot,$configFile); + +if ($userMessageFile) { + print "Opening message file.." unless ($quiet); + if (open(FILE,"<".$userMessageFile)) { + print "OK\n" unless ($quiet); + my $contents; + while () { + $contents .= $_; + } + close(FILE); + if (length($contents) == 0) { + print "Message file empty, reverting to original message.\n"; + } else { + $userMessage = $contents; + } + } else { + print "Failed to open message file.\n"; + } +} + +print "Searching for users with a status of $currentStatus ...\n" unless ($quiet); +my $userList; +my $now = time(); +my $inbox = WebGUI::Inbox->new($session); +my $sth = $session->db->read("select userId,assetId from InOutBoard_status where status=?",[$currentStatus]); +while (my ($userId,$assetId) = $sth->array) { + my $user = WebGUI::User->new($session, $userId); + print "\tFound user ".$user->username."\n" unless ($quiet); + $userList .= $user->username." (".$userId.")\n"; + $session->db->write("update InOutBoard_status set dateStamp=?, message=?, status=? where userId=? and assetId=?",[$now, $whatsHappening, $newStatus, $userId, $assetId]); + $session->db->write("insert into InOutBoard_statusLog (userId, createdBy, dateStamp, message, status, assetId) values (?,?,?,?,?,?)", + [$userId,3,$now, $whatsHappening, $newStatus, $assetId]); + $inbox->addMessage({ + userId=>$userId, + subject=>"IOB Update", + message=>$userMessage + }); +} + +if (length($userList) > 0) { + print "Alerting admins of changes\n" unless ($quiet); + my $message = "The following users had their status changed:\n\n".$userList; + $inbox->addMessage({ + groupId=>3, + subject=>"IOB Update", + message=>$userMessage + }); +} + +print "Cleaning up..." unless ($quiet); +$session->var->end; +$session->close; +print "OK\n" unless ($quiet); + +__END__ + +=head1 NAME + +changeIobStatus - Automate WebGUI's InOut Board User status switching. + +=head1 SYNOPSIS + + changeIobStatus --configFile config.conf + [--currentStatus status] + [--newStatus status] + [--userMessage text|--userMessageFile pathname] + [--whatsHappening text] + [--quiet] + + changeIobStatus --help + +=head1 DESCRIPTION + +This WebGUI utility script helps you switch one or more user status +in the InOut Board (IOB). For instance, you might want to run it +from cron each night to automatically mark out all users that haven't +already marked out. + +=over + +=item B<--configFile config.conf> + +The WebGUI config file to use. Only the file name needs to be specified, +since it will be looked up inside WebGUI's configuration directory. +This parameter is required. + +=item B<--currentStatus status> + +Check users in the IOB having B status. If left unspecified, +it will default to C. + +=item B<--newStatus status> + +Change users status in the IOB to B status. If left unspecified, +it will default to C. + +=item B<--userMessage msg> + +Text of the message to be sent to the user after changing the status. +If left unspecified it will default to + + You were logged out of the In/Out Board automatically. + +=item B<--userMessageFile pathname> + +Pathname to a file whose contents will be sent to the user after changing +the status. Using this option overrides whatever messages is set +with B<--userMessage> (see above). + +=item B<--whatsHappening text> + +The message attached to the InOut Board when changing status. If left +unspecified it defaults to + + Automatically signed out. + +=item B<--quiet> + +Disable all output unless there's an error. + +=item B<--help> + +Shows this documentation, then exits. + +=back + +=head1 AUTHOR + +Copyright 2001-2009 Plain Black Corporation. + +=cut diff --git a/sbin/diskUsage.pl b/sbin/diskUsage.pl index d15f3a69c..a8990359f 100755 --- a/sbin/diskUsage.pl +++ b/sbin/diskUsage.pl @@ -10,16 +10,18 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -our ($webguiRoot); +use strict; +use File::Basename (); +use File::Spec; +my $webguiRoot; BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } use Getopt::Long; use Pod::Usage; -use strict; use WebGUI::Session; use WebGUI::Asset; diff --git a/sbin/fileImport.pl b/sbin/fileImport.pl index 29bdfbd92..f0bfe1606 100755 --- a/sbin/fileImport.pl +++ b/sbin/fileImport.pl @@ -10,15 +10,17 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -our ($webguiRoot, @nailable); +use strict; +use File::Basename (); +use File::Spec; -BEGIN { - $webguiRoot = ".."; - @nailable = qw(jpg jpeg png gif); - unshift (@INC, $webguiRoot."/lib"); +my $webguiRoot; +BEGIN { + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } - +my @nailable = qw(jpg jpeg png gif); $| = 1; use File::Path; @@ -27,7 +29,6 @@ use FileHandle; use Getopt::Long; use POSIX; use Pod::Usage; -use strict; use WebGUI::Asset::File; use WebGUI::Asset::File::Image; use WebGUI::Session; diff --git a/sbin/galleryImport.pl b/sbin/galleryImport.pl index 7f6570274..6b4fa3ff7 100755 --- a/sbin/galleryImport.pl +++ b/sbin/galleryImport.pl @@ -10,9 +10,17 @@ # http://www.plainblack.com info@plainblack.com # ------------------------------------------------------------------- -$|=1; -use lib '../lib'; use strict; +use File::Basename (); +use File::Spec; + +my $webguiRoot; +BEGIN { + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); +} + +$|=1; use Carp qw( carp croak ); use File::Find; use Getopt::Long; diff --git a/sbin/generateContent.pl b/sbin/generateContent.pl index 9a58208e6..85182248c 100755 --- a/sbin/generateContent.pl +++ b/sbin/generateContent.pl @@ -10,19 +10,21 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- - -our $webguiRoot; +use strict; +use File::Basename (); +use File::Spec; +my $webguiRoot; BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } use DBI; use FileHandle; use Getopt::Long; use Pod::Usage; -use strict qw(subs vars); +no strict 'refs'; use WebGUI::Session; use WebGUI::Asset; diff --git a/sbin/installClass.pl b/sbin/installClass.pl index 6105cfefe..60e3dc095 100755 --- a/sbin/installClass.pl +++ b/sbin/installClass.pl @@ -11,8 +11,16 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -use lib "../lib"; use strict; +use File::Basename (); +use File::Spec; + +my $webguiRoot; +BEGIN { + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); +} + use Getopt::Long; use Pod::Usage; use WebGUI::Pluggable; diff --git a/sbin/maintenanceMode.pl b/sbin/maintenanceMode.pl index e757056f5..820d6624b 100755 --- a/sbin/maintenanceMode.pl +++ b/sbin/maintenanceMode.pl @@ -10,17 +10,18 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- +use strict; +use File::Basename (); +use File::Spec; -our ($webguiRoot); - +my $webguiRoot; BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } use Getopt::Long; use Pod::Usage; -use strict; use WebGUI::Session; my $help; diff --git a/sbin/purgeWGAccess.pl b/sbin/purgeWGAccess.pl index 9ea4312fd..1f1b15d09 100755 --- a/sbin/purgeWGAccess.pl +++ b/sbin/purgeWGAccess.pl @@ -10,14 +10,16 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -our ($webguiRoot); +use strict; +use File::Basename (); +use File::Spec; +my $webguiRoot; BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } -use strict; use Getopt::Long; use Pod::Usage; use WebGUI::Config; diff --git a/sbin/rebuildLineage.pl b/sbin/rebuildLineage.pl index 355d55ff9..aed1f0f90 100755 --- a/sbin/rebuildLineage.pl +++ b/sbin/rebuildLineage.pl @@ -10,19 +10,20 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -our ($webguiRoot); +use strict; +use File::Basename (); +use File::Spec; -BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); +my $webguiRoot; +BEGIN { + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } - $| = 1; use Getopt::Long; use Pod::Usage; -use strict; use WebGUI::Session; use WebGUI::Utility; diff --git a/sbin/search.pl b/sbin/search.pl index 12e188345..d086e0fa3 100755 --- a/sbin/search.pl +++ b/sbin/search.pl @@ -10,14 +10,16 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -our ($webguiRoot); +use strict; +use File::Basename (); +use File::Spec; +my $webguiRoot; BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } -use strict; use Getopt::Long; use WebGUI::Asset; use WebGUI::Config; diff --git a/sbin/spectre.pl b/sbin/spectre.pl index 99d88217a..309467008 100755 --- a/sbin/spectre.pl +++ b/sbin/spectre.pl @@ -10,15 +10,17 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -our ($webguiRoot); +use strict; +use File::Basename (); +use File::Spec; +my $webguiRoot; BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } use Pod::Usage; -use strict; use warnings; use Getopt::Long; use POE::Component::IKC::ClientLite; diff --git a/sbin/syncToCdn.pl b/sbin/syncToCdn.pl old mode 100644 new mode 100755 index 4f3ef30ac..822a984db --- a/sbin/syncToCdn.pl +++ b/sbin/syncToCdn.pl @@ -1,3 +1,5 @@ +#!/usr/bin/env perl + #------------------------------------------------------------------- # WebGUI is Copyright 2001-2009 Plain Black Corporation. #------------------------------------------------------------------- @@ -8,14 +10,16 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -our $webguiRoot; +use strict; +use File::Basename (); +use File::Spec; +my $webguiRoot; BEGIN { - $webguiRoot = ".."; - unshift( @INC, $webguiRoot . "/lib" ); + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } -use strict; use Fcntl ':flock'; use Getopt::Long; use WebGUI::Session; diff --git a/sbin/testCodebase.pl b/sbin/testCodebase.pl index 7a24fa501..9b1d2dad0 100755 --- a/sbin/testCodebase.pl +++ b/sbin/testCodebase.pl @@ -10,9 +10,18 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- +use strict; +use File::Basename (); +use File::Spec; + +my $webguiRoot; +BEGIN { + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); +} + $|=1; -use strict; use FindBin; use File::Spec qw[]; use Getopt::Long; @@ -48,14 +57,13 @@ if (! -e $configFile) { ##Probably given the name of the config file with no path, ##attempt to prepend the path to it. warn "Config file $configFile does not exist, assuming that you supplied a bare config and are running from inside the sbin directory\n"; - $configFile = File::Spec->canonpath($FindBin::Bin.'/../etc/'.$configFile); + $configFile = File::Spec->canonpath($webguiRoot . '/etc/' . $configFile); } die "Unable to use $configFile as a WebGUI config file\n" unless(-e $configFile and -f _); my (undef, $directories, $file) = File::Spec->splitpath($configFile); -my $webguiRoot = File::Spec->canonpath(File::Spec->catdir($directories, File::Spec->updir)); my $webguiTest = File::Spec->catdir($webguiRoot, 't'); my $prefix = "WEBGUI_CONFIG=".$configFile; diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index 3205eb8e2..2f23c263d 100755 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -10,15 +10,16 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- +use strict; +use File::Basename (); +use File::Spec; -our $webguiRoot; - +my $webguiRoot; BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } -use strict; use CPAN; use Getopt::Long; use Pod::Usage; diff --git a/sbin/thumbnailer.pl b/sbin/thumbnailer.pl index 88ac1013f..881f1d85c 100755 --- a/sbin/thumbnailer.pl +++ b/sbin/thumbnailer.pl @@ -10,11 +10,14 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -our ($webguiRoot); +use strict; +use File::Basename (); +use File::Spec; +my $webguiRoot; BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } #----------------------------------------- diff --git a/sbin/upgrade.pl b/sbin/upgrade.pl index 7e1e9a332..5c3941d83 100755 --- a/sbin/upgrade.pl +++ b/sbin/upgrade.pl @@ -10,14 +10,16 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -our ($webguiRoot); +use strict; +use File::Basename (); +use File::Spec; +my $webguiRoot; BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } -use strict; use Cwd (); use File::Path (); use Getopt::Long (); diff --git a/sbin/userImport.pl b/sbin/userImport.pl index 55c9719bb..ccad6badc 100755 --- a/sbin/userImport.pl +++ b/sbin/userImport.pl @@ -10,14 +10,16 @@ # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- -our ($webguiRoot); +use strict; +use File::Basename (); +use File::Spec; +my $webguiRoot; BEGIN { - $webguiRoot = ".."; - unshift (@INC, $webguiRoot."/lib"); + $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); + unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } -use strict; use Digest::MD5; use Getopt::Long; use Pod::Usage;