Skip to content

Commit

Permalink
Item12952: must restor OS after bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
crawford committed Sep 1, 2014
1 parent 24b6011 commit e25ec0d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 34 deletions.
58 changes: 32 additions & 26 deletions core/lib/Foswiki.pm
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,35 @@ sub _getLibDir {
return $foswikiLibDir;
}

sub _workOutOS {
unless ( ( $Foswiki::cfg{DetailedOS} = $^O ) ) {
require Config;
$Foswiki::cfg{DetailedOS} = $Config::Config{'osname'};
}
$Foswiki::cfg{OS} = 'UNIX';
if ( $Foswiki::cfg{DetailedOS} =~ /darwin/i ) { # MacOS X
$Foswiki::cfg{OS} = 'UNIX';
}
elsif ( $Foswiki::cfg{DetailedOS} =~ /Win/i ) {
$Foswiki::cfg{OS} = 'WINDOWS';
}
elsif ( $Foswiki::cfg{DetailedOS} =~ /vms/i ) {
$Foswiki::cfg{OS} = 'VMS';
}
elsif ( $Foswiki::cfg{DetailedOS} =~ /bsdos/i ) {
$Foswiki::cfg{OS} = 'UNIX';
}
elsif ( $Foswiki::cfg{DetailedOS} =~ /dos/i ) {
$Foswiki::cfg{OS} = 'DOS';
}
elsif ( $Foswiki::cfg{DetailedOS} =~ /^MacOS$/i ) { # MacOS 9 or earlier
$Foswiki::cfg{OS} = 'MACINTOSH';
}
elsif ( $Foswiki::cfg{DetailedOS} =~ /os2/i ) {
$Foswiki::cfg{OS} = 'OS2';
}
}

BEGIN {

#Monitor::MARK("Start of BEGIN block in Foswiki.pm");
Expand Down Expand Up @@ -320,32 +349,7 @@ BEGIN {
);
$contextFreeSyntax{IF} = 1;

unless ( ( $Foswiki::cfg{DetailedOS} = $^O ) ) {
require Config;
$Foswiki::cfg{DetailedOS} = $Config::Config{'osname'};
}
$Foswiki::cfg{OS} = 'UNIX';
if ( $Foswiki::cfg{DetailedOS} =~ /darwin/i ) { # MacOS X
$Foswiki::cfg{OS} = 'UNIX';
}
elsif ( $Foswiki::cfg{DetailedOS} =~ /Win/i ) {
$Foswiki::cfg{OS} = 'WINDOWS';
}
elsif ( $Foswiki::cfg{DetailedOS} =~ /vms/i ) {
$Foswiki::cfg{OS} = 'VMS';
}
elsif ( $Foswiki::cfg{DetailedOS} =~ /bsdos/i ) {
$Foswiki::cfg{OS} = 'UNIX';
}
elsif ( $Foswiki::cfg{DetailedOS} =~ /dos/i ) {
$Foswiki::cfg{OS} = 'DOS';
}
elsif ( $Foswiki::cfg{DetailedOS} =~ /^MacOS$/i ) { # MacOS 9 or earlier
$Foswiki::cfg{OS} = 'MACINTOSH';
}
elsif ( $Foswiki::cfg{DetailedOS} =~ /os2/i ) {
$Foswiki::cfg{OS} = 'OS2';
}
_workOutOS();

# Load LocalSite.cfg
if ( Foswiki::Configure::Load::readConfig( 0, 0, 0 ) ) {
Expand Down Expand Up @@ -514,6 +518,8 @@ EPITAPH
# JQueryPlugin. Without the Config.spec, no plugins get registered)
Foswiki::Configure::Load::readConfig( 0, 0, 1 );

_workOutOS();

$Foswiki::cfg{isVALID} = 1;
$Foswiki::cfg{isBOOTSTRAPPING} = 1;
eval 'require Foswiki::Plugins::ConfigurePlugin';
Expand Down
7 changes: 3 additions & 4 deletions core/lib/Foswiki.spec
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ $Foswiki::cfg{PathCheckLimit} = 7000;
# if your webserver requires an extension.
$Foswiki::cfg{ScriptSuffix} = '';

# **URLPATH CHECK='expand nullok notrail' FEEDBACK="label='Verify';wizard='ScriptHash';method='verify';auth=1" MANDATORY**
# **URLPATH CHECK='expand nullok notrail' FEEDBACK="label='Verify';wizard='ScriptHash';method='verify';auth=1" UNDEFINEDOK MANDATORY**
#! n.b. options should match Pluggables/SCRIPTHASH.pm for dynamic path items
# This is the complete path used to access the Foswiki view script including any suffix.
# You should leave this as it is, unless your web server is configured for short URLs
Expand All @@ -113,8 +113,7 @@ $Foswiki::cfg{ScriptSuffix} = '';
# (so you'll have to leave this field empty if your wiki lives at the top level).
# <p></p>
# More information: <a href="http://foswiki.org/Support/ShorterUrlCookbook" target="_new">Shorter URL Cookbook</a>
#$Foswiki::cfg{ScriptUrlPaths}{view} =
# '$Foswiki::cfg{ScriptUrlPath}/view$Foswiki::cfg{ScriptSuffix}';
$Foswiki::cfg{ScriptUrlPaths}{view} = '$Foswiki::cfg{ScriptUrlPath}/view$Foswiki::cfg{ScriptSuffix}';

#! The following plugin must follow all other {ScriptUrlPaths} items
# *SCRIPTHASH*
Expand Down Expand Up @@ -182,7 +181,7 @@ $Foswiki::cfg{ScriptSuffix} = '';
# will not be used by perl for security reasons.
#$Foswiki::cfg{TempfileDir} = '/tmp';

# **PATH EXPERT MANDATORY**
# **PATH EXPERT UNDEFINEDOK MANDATORY**
# You can override the default PATH setting to control
# where Foswiki looks for external programs, such as grep.
# By restricting this path to just a few key
Expand Down
23 changes: 20 additions & 3 deletions core/lib/Foswiki/UI/Configure.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ sub configure {
my $topic = $session->{topicName};
my $web = $session->{webName};
my $query = $session->{request};

my $tmplData =
$session->templates->readTemplate( 'configure', no_oops => 1 );

Expand Down Expand Up @@ -65,19 +66,31 @@ sub configure {
}
}

if ( !defined($tmplData) ) {
unless ( $Foswiki::cfg{Plugins}{ConfigurePlugin}{Enabled} ) {
$tmplData =
CGI::start_html()
. CGI::h1( {}, 'Error' )
. <<MESSAGE . CGI::end_html();
ConfigurePlugin is not enabled (or may not be installed)
<p />
This system cannot be successfully configured via the web unless the
ConfigurePlugin is installed and enabled.
MESSAGE
}
elsif ( !defined($tmplData) ) {

$tmplData =
CGI::start_html()
. CGI::h1( {}, 'Foswiki Installation Error' )
. <<MESSAGE . CGI::end_html();
Template "bootstrap" not found.
Template "configure" not found.
<p />
this system cannot be successfully configured unless the
This system cannot be successfully configured via the web unless the
templates/ directory (containing configure.tmpl) is located
next to the bin/ directory (where the scripts are run from).
MESSAGE
}

my $meta = Foswiki::Meta->new(
$session,
$Foswiki::cfg{SystemWebName},
Expand All @@ -86,6 +99,10 @@ MESSAGE

$tmplData = $meta->expandMacros($tmplData);

# Expand JS bootsrap flag
my $bs = $Foswiki::cfg{isBOOTSTRAPPING} ? 'true' : 'false';
$tmplData =~ s/%BOOTSTRAPPED%/$bs/gs;

$session->writeCompletePage($tmplData);
}

Expand Down
4 changes: 3 additions & 1 deletion core/tools/configure_test
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ else {
}

if ($ok) {
if ( $params->{checker} ) {
if ( exists $params->{checker} ) {

$params->{checker} ||= '';

_addSpecDefaultsToCfg( $root, \%Foswiki::cfg );

Expand Down

0 comments on commit e25ec0d

Please sign in to comment.