diff --git a/lib/WebGUI/Config.pm b/lib/WebGUI/Config.pm index af9777cef..ec594ee74 100644 --- a/lib/WebGUI/Config.pm +++ b/lib/WebGUI/Config.pm @@ -16,6 +16,7 @@ package WebGUI::Config; use strict; use Class::InsideOut qw(readonly id register); +use Cwd (); use base 'Config::JSON'; my %config = (); @@ -148,14 +149,14 @@ A boolean value that when set to true tells the config system not to store the c sub new { my $class = shift; - my $webguiPath = shift; + my $webguiPath = Cwd::realpath(shift); my $filename = shift; my $noCache = shift; my $fullPath = $webguiPath.'/etc/'.$filename; if (exists $config{$filename}) { return $config{$filename}; } else { - my $self = Config::JSON->new($webguiPath."/etc/".$filename); + my $self = Config::JSON->new($fullPath); register($self, $class); $webguiRoot{id $self} = $webguiPath; $config{$filename} = $self unless $noCache; @@ -181,9 +182,9 @@ The path to the WebGUI installation. sub readAllConfigs { my $class = shift; my $webguiPath = shift; - opendir(DIR,$webguiPath."/etc"); - my @files = readdir(DIR); - closedir(DIR); + opendir my $dh, $webguiPath."/etc"; + my @files = readdir $dh; + closedir $dh; my %configs; foreach my $file (@files) { next @@ -191,12 +192,14 @@ sub readAllConfigs { || $file =~ /^\./ || $file eq 'log.conf' || $file eq 'spectre.conf'; - $configs{$file} = eval{WebGUI::Config->new($webguiPath,$file)}; + eval { + $configs{$file} = WebGUI::Config->new($webguiPath,$file) + }; if ($@) { warn "Config file ".$file." looks to be corrupt or have a syntax error."; } - } - return \%configs; + } + return \%configs; } diff --git a/sbin/upgrade.pl b/sbin/upgrade.pl index 1857cf393..ddfd74be6 100644 --- a/sbin/upgrade.pl +++ b/sbin/upgrade.pl @@ -226,12 +226,18 @@ foreach my $filename (keys %config) { } } if ($upgrade{$upgrade}{pl} ne "") { - my $cmd = $perl." ".$upgrade{$upgrade}{pl}." --configFile=".$filename; - $cmd .= " --quiet" if ($quiet); - if (system($cmd)) { - print "\tProcessing upgrade executable failed!\n"; - fatalError(); - } + my $pid = fork; + if (!$pid) { + @ARGV = ("--configFile=$filename", $quiet ? ('--quiet') : ()); + $0 = $upgrade{$upgrade}{pl}; + do $0; + exit; + } + waitpid $pid, 0; + if ($?) { + print "\tProcessing upgrade executable failed!\n"; + fatalError(); + } } $config{$filename}{version} = $upgrade{$upgrade}{to}; $notRun = 0;