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
- Added a new admin panel for inline content editing.
- 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();
6.5.5
- fix [ 1171569 ] add/edit sql report help link has wrong namespace
- 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
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;
opendir(DIR,$webguiPath."/etc");
my @files = readdir(DIR);
closedir(DIR);
my %configs;
foreach my $file (@files) {
if ($file =~ /\.conf$/ && !($file =~ /^demo\d/)) {
print "\tLoading ".$file."\n";
$config{$file} = readConfig($webguiPath,$file);
if ($file =~ /\.conf$/ && !($file =~ /^logs.conf$/)) {
$configs{$file} = readConfig($webguiPath,$file);
}
}
return \%configs;
}

View file

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

View file

@ -74,81 +74,12 @@ checkModule("DBIx::FullTextSearch",0.73);
###################################
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");
} else {
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
###################################
@ -160,6 +91,52 @@ if ($version eq $WebGUI::VERSION."-".$WebGUI::STATUS) {
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";

View file

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