upgrade.pl and testEnvironment.pl now use the same config file reader as

the rest of WebGUI
This commit is contained in:
JT Smith 2005-03-31 21:22:57 +00:00
parent ddc63b91b3
commit 4e6e41ce2c
5 changed files with 108 additions and 108 deletions

View file

@ -1,8 +1,11 @@
6.6.0 6.6.0
- Added a new admin panel for inline content editing. - Added a new admin panel for inline content editing.
- Tweaked the preloader so WebGUI uses a little less memory per process. - Tweaked the preloader so WebGUI uses a little less memory per process.
- upgrade.pl and testEnvironment.pl now use the same config file reader as
the rest of WebGUI
- fix [ 1173101 ] Template in ^LoginToggle(); - fix [ 1173101 ] Template in ^LoginToggle();
6.5.5 6.5.5
- fix [ 1171569 ] add/edit sql report help link has wrong namespace - fix [ 1171569 ] add/edit sql report help link has wrong namespace
- Fixed a bug in the collaboration system that caused replies to fail. - Fixed a bug in the collaboration system that caused replies to fail.

View file

@ -84,16 +84,43 @@ The path to the WebGUI installation.
=cut =cut
sub loadAllConfigs { sub loadAllConfigs {
my $webguiPath = shift;
my $configs = readAllConfigs($webguiPath);
foreach my $filename (keys %{$configs}) {
unless ($filename =~ /^demo\d/) {
print "\tLoading ".$filename."\n";
$config{$filename} = $configs->{$filename};
}
}
}
#-------------------------------------------------------------------
=head2 readAllConfigs ( webguiRoot )
Reads all the config file data for all defined sites and returns a hash reference containing the resulting data by config file name.
Example: $configs->{$filename};
=head3 webguiRoot
The path to the WebGUI installation.
=cut
sub readAllConfigs {
my $webguiPath = shift; my $webguiPath = shift;
opendir(DIR,$webguiPath."/etc"); opendir(DIR,$webguiPath."/etc");
my @files = readdir(DIR); my @files = readdir(DIR);
closedir(DIR); closedir(DIR);
my %configs;
foreach my $file (@files) { foreach my $file (@files) {
if ($file =~ /\.conf$/ && !($file =~ /^demo\d/)) { if ($file =~ /\.conf$/ && !($file =~ /^logs.conf$/)) {
print "\tLoading ".$file."\n"; $configs{$file} = readConfig($webguiPath,$file);
$config{$file} = readConfig($webguiPath,$file);
} }
} }
return \%configs;
} }

View file

@ -15,6 +15,7 @@ package WebGUI::ErrorHandler;
=cut =cut
use FileHandle; use FileHandle;
use Log::Log4perl;
use strict; use strict;
use WebGUI::Session; use WebGUI::Session;

View file

@ -74,81 +74,12 @@ checkModule("DBIx::FullTextSearch",0.73);
################################### ###################################
printTest("WebGUI modules"); printTest("WebGUI modules");
if (eval { require WebGUI } && eval { require WebGUI::SQL }) { if (eval { require WebGUI } && eval { require WebGUI::SQL } && eval { require WebGUI::Config }) {
printResult("OK"); printResult("OK");
} else { } else {
failAndExit("Not Found. Perhaps you're running this script from the wrong place."); failAndExit("Not Found. Perhaps you're running this script from the wrong place.");
} }
printTest("Locating WebGUI configs");
my (@files, $file, $dir, $error);
if ($os eq "Windowsish") {
$dir = $webguiRoot."\\etc\\";
} else {
$dir = $webguiRoot."/etc/";
}
opendir (DIR,$dir) or $error = "Can't open etc (".$dir.") directory!";
if (opendir(DIR,$dir)) {
printResult("OK");
@files = readdir(DIR);
foreach $file (@files) {
if ($file =~ /(.*?)\.conf$/) {
my $prereq = 1;
###################################
# Checking Config File
###################################
printTest("Found config file");
printResult($file);
printTest("Verifying file");
my ($config);
$config = Parse::PlainConfig->new('DELIM' => '=',
'FILE' => $dir.$file,
'PURGE' => 1);
unless (defined $config) {
printResult("Couldn't open the config file.");
$prereq = 0;
} elsif ($config->get('dsn') !~ /\DBI\:\w+\:\w+/) {
printResult("DSN is improperly formatted.");
$prereq = 0;
} else {
printResult("OK");
}
if ($prereq) {
###################################
# Checking uploads folder
###################################
printTest("Uploads folder");
if (opendir(DIR,$config->get('uploadsPath'))) {
printResult("OK");
closedir(DIR);
} else {
printResult("Appears to be missing!");
}
###################################
# Checking database
###################################
printTest("Database connection");
my ($dbh, $test);
unless (eval {$dbh = DBI->connect($config->get('dsn'),$config->get('dbuser'),$config->get('dbpass'))}) {
printResult("Can't connect with info provided!");
} else {
printResult("OK");
$dbh->disconnect();
}
}
print "\n";
}
}
closedir(DIR);
} else {
failAndExit($error);
}
################################### ###################################
# Checking Version # Checking Version
################################### ###################################
@ -160,6 +91,52 @@ if ($version eq $WebGUI::VERSION."-".$WebGUI::STATUS) {
printResult("You are using ".$WebGUI::VERSION."-".$WebGUI::STATUS." and ".$version." is available."); printResult("You are using ".$WebGUI::VERSION."-".$WebGUI::STATUS." and ".$version." is available.");
} }
printTest("Locating WebGUI configs");
my $configs = WebGUI::Config::readAllConfigs($webguiRoot);
printResult("OK");
foreach my $filename (keys %{$configs}) {
print "\n";
###################################
# Checking Config File
###################################
printTest("Checking config file");
printResult($filename);
###################################
# Checking uploads folder
###################################
printTest("Verifying uploads folder");
if (opendir(DIR,$configs->{$filename}{uploadsPath})) {
printResult("OK");
closedir(DIR);
} else {
printResult("Appears to be missing!");
}
printTest("Verifying DSN");
my $dsnok = 0;
if ($configs->{$filename}{dsn} !~ /\DBI\:\w+\:\w+/) {
printResult("DSN is improperly formatted.");
} else {
printResult("OK");
$dsnok = 1;
}
###################################
# Checking database
###################################
if ($dsnok) {
printTest("Verifying database connection");
my ($dbh, $test);
unless (eval {$dbh = DBI->connect($configs->{$filename}{dsn},$configs->{$filename}{dbuser},$configs->{$filename}{dbpass})}) {
printResult("Can't connect with info provided!");
} else {
printResult("OK");
$dbh->disconnect();
}
}
}
print "\nTesting complete!\n\n"; print "\nTesting complete!\n\n";

View file

@ -20,8 +20,8 @@ BEGIN {
use DBI; use DBI;
use File::Path; use File::Path;
use Getopt::Long; use Getopt::Long;
use Parse::PlainConfig;
use strict; use strict;
use WebGUI::Config;
use WebGUI::SQL; use WebGUI::SQL;
my $help; my $help;
@ -140,47 +140,39 @@ if ($^O =~ /^Win/i) {
$slash = "/"; $slash = "/";
} }
our $upgradesPath = $webguiRoot.$slash."docs".$slash."upgrades".$slash; our $upgradesPath = $webguiRoot.$slash."docs".$slash."upgrades".$slash;
our $configsPath = $webguiRoot.$slash."etc".$slash;
our (%upgrade, %config); our (%upgrade, %config);
## Find site configs. ## Find site configs.
print "\nGetting site configs...\n" unless ($quiet); print "\nGetting site configs...\n" unless ($quiet);
opendir (DIR,$configsPath) or die "Can't open $configsPath\n"; my $configs = WebGUI::Config::readAllConfigs($webguiRoot);
my @files=readdir(DIR); foreach my $filename (keys %{$configs}) {
closedir(DIR); print "\tProcessing $filename.\n" unless ($quiet);
foreach my $file (@files) { $config{$filename}{configFile} = $filename;
if ($file =~ /(.*?)\.conf$/ && $file ne "some_other_site.conf") { $config{$filename}{dsn} = $configs->{$filename}{dsn};
print "\tFound $file.\n" unless ($quiet); my $temp = _parseDSN($config{$filename}{dsn}, ['database', 'host', 'port']);
$config{$file}{configFile} = $file; if ($temp->{'driver'} eq "mysql") {
my $config = Parse::PlainConfig->new('DELIM' => '=', $config{$filename}{db} = $temp->{'database'};
'FILE' => $configsPath.$config{$file}{configFile}, $config{$filename}{host} = $temp->{'host'};
'PURGE' => 1); $config{$filename}{port} = $temp->{'port'};
$config{$file}{dsn} = $config->get('dsn'); $config{$filename}{dbuser} = $configs->{$filename}{dbuser};
my $temp = _parseDSN($config{$file}{dsn}, ['database', 'host', 'port']); $config{$filename}{dbpass} = $configs->{$filename}{dbpass};
if ($temp->{'driver'} eq "mysql") { $config{$filename}{mysqlCLI} = $configs->{$filename}{mysqlCLI};
$config{$file}{db} = $temp->{'database'}; $config{$filename}{mysqlDump} = $configs->{$filename}{mysqlDump};
$config{$file}{host} = $temp->{'host'}; $config{$filename}{backupPath} = $configs->{$filename}{backupPath};
$config{$file}{port} = $temp->{'port'}; my $dbh = DBI->connect($config{$filename}{dsn},$config{$filename}{dbuser},$config{$filename}{dbpass});
$config{$file}{dbuser} = $config->get('dbuser'); ($config{$filename}{version}) = WebGUI::SQL->quickArray("select webguiVersion from webguiVersion
$config{$file}{dbpass} = $config->get('dbpass'); order by dateApplied desc, webguiVersion desc limit 1",$dbh);
$config{$file}{mysqlCLI} = $config->get('mysqlCLI'); unless ($history) {
$config{$file}{mysqlDump} = $config->get('mysqlDump'); print "\tPreparing site for upgrade.\n" unless ($quiet);
$config{$file}{backupPath} = $config->get('backupPath'); $dbh->do("replace into settings (name,value) values ('specialState','upgrading')") unless ($history);
my $dbh = DBI->connect($config{$file}{dsn},$config{$file}{dbuser},$config{$file}{dbpass}); rmtree($configs->{$filename}{uploadsPath}.$slash."temp");
($config{$file}{version}) = WebGUI::SQL->quickArray("select webguiVersion from webguiVersion
order by dateApplied desc, webguiVersion desc limit 1",$dbh);
unless ($history) {
print "\tPreparing site for upgrade.\n" unless ($quiet);
$dbh->do("replace into settings (name,value) values ('specialState','upgrading')") unless ($history);
rmtree($config->get("uploadsPath").$slash."temp");
}
$dbh->disconnect;
} else {
delete $config{$file};
print "\tSkipping non-MySQL database.\n" unless ($quiet);
} }
$dbh->disconnect;
} else {
delete $config{$filename};
print "\tSkipping non-MySQL database.\n" unless ($quiet);
} }
} }