From ffa59a9266aecbe121d27b565761187190a43102 Mon Sep 17 00:00:00 2001 From: George Clark Date: Fri, 7 Nov 2014 12:57:00 -0500 Subject: [PATCH] Item13079: Fix initial configuration from shell --- core/lib/Foswiki/Configure/Load.pm | 36 ++++++++++++++++++++++-------- core/tools/configure | 13 ++++++----- 2 files changed, 34 insertions(+), 15 deletions(-) mode change 100644 => 100755 core/tools/configure diff --git a/core/lib/Foswiki/Configure/Load.pm b/core/lib/Foswiki/Configure/Load.pm index 3c12a498f2..a1d5ec57d3 100644 --- a/core/lib/Foswiki/Configure/Load.pm +++ b/core/lib/Foswiki/Configure/Load.pm @@ -32,11 +32,6 @@ our $ITEMREGEX = qr/(?:\{(?:'(?:\\.|[^'])+'|"(?:\\.|[^"])+"|[A-Za-z0-9_]+)\})+/; our $TRUE = 1; our $FALSE = 0; -# Bootstrap works out the correct values of these keys -my @BOOTSTRAP = - qw( {DataDir} {DefaultUrlHost} {PubUrlPath} {ToolsDir} {WorkingDir} - {PubDir} {TemplateDir} {ScriptDir} {ScriptUrlPath} {ScriptUrlPaths}{view} {ScriptSuffix} {LocalesDir} ); - # Configuration items that have been deprecated and must be mapped to # new configuration items. The value is mapped unchanged. our %remap = ( @@ -306,6 +301,30 @@ sub _handleExpand { =begin TML +---++ StaticMethod setBootstrap() + +This routine is called to initialize the bootstrap process. It sets the list of +configuration parameters that will need to be set and "protected" during bootstrap. + +If any keys will be set during bootstrap / initial creation of LocalSite.cfg, they +should be added here so that they are preserved when the %Foswiki::cfg hash is +wiped and re-initialized from the Foswiki spec. + +=cut + +sub setBootstrap { + + # Bootstrap works out the correct values of these keys + my @BOOTSTRAP = + qw( {DataDir} {DefaultUrlHost} {PubUrlPath} {ToolsDir} {WorkingDir} + {PubDir} {TemplateDir} {ScriptDir} {ScriptUrlPath} {ScriptUrlPaths}{view} {ScriptSuffix} {LocalesDir} ); + + $Foswiki::cfg{isBOOTSTRAPPING} = 1; + push( @{ $Foswiki::cfg{BOOTSTRAP} }, @BOOTSTRAP ); +} + +=begin TML + ---++ StaticMethod bootstrapConfig( $noload ) This routine is called from Foswiki.pm BEGIN block to discover the mandatory @@ -564,9 +583,8 @@ EPITAPH _workOutOS(); - $Foswiki::cfg{isVALID} = 1; - $Foswiki::cfg{isBOOTSTRAPPING} = 1; - push( @{ $Foswiki::cfg{BOOTSTRAP} }, @BOOTSTRAP ); + $Foswiki::cfg{isVALID} = 1; + Foswiki::Configure::Load::setBootstrap(); eval 'require Foswiki::Plugins::ConfigurePlugin'; die "LocalSite.cfg load failed, and ConfigurePlugin could not be loaded: $@" @@ -596,7 +614,7 @@ BOOTS ---++ StaticMethod findDependencies(\%cfg) -> \%deps - * =\%cfg= configuration hash to scan; defaults to %Foswiki::cfg + * =\%cfg= configuration hash to scan; defaults to %Foswiki::cfg Recursively locate references to other keys in the values of keys. Returns a hash containing two keys: diff --git a/core/tools/configure b/core/tools/configure old mode 100644 new mode 100755 index 00a7a8995d..2c77235e71 --- a/core/tools/configure +++ b/core/tools/configure @@ -197,22 +197,23 @@ unless ( $Foswiki::cfg{isVALID} ) { %Foswiki::cfg = (); print STDERR "LocalSite.cfg load failed\n" . Foswiki::Configure::Reporter::stripStacktrace($@); + Foswiki::Configure::Load::readConfig( 0, 0, 1 ); print "** Enter values for critical configuration items.\n"; print "** type a new value or hit return to accept the value in brackets.\n"; _prompt( $root, '{DefaultUrlHost}', 'http://localhost' ); - _prompt( $root, '{ScriptUrlPath}' ); - _prompt( $root, '{PubUrlPath}' ); + _prompt( $root, '{ScriptUrlPath}', '/foswiki/bin' ); + _prompt( $root, '{PubUrlPath}', '/foswiki/pub' ); _prompt( $root, '{ScriptDir}', "$bin/../bin" ); - _prompt( $root, '{DataDir}', "$bin/../pub" ); + _prompt( $root, '{DataDir}', "$bin/../data" ); _prompt( $root, '{PubDir}', "$bin/../pub" ); _prompt( $root, '{TemplateDir}', "$bin/../templates" ); _prompt( $root, '{LocalesDir}', "$bin/../locale" ); _prompt( $root, '{WorkingDir}', "$bin/../working" ); _prompt( $root, '{ToolsDir}', $bin ); - Foswiki::Configure::Load::readConfig( 0, 0, 1 ); - $Foswiki::cfg{isVALID} = 1; - $Foswiki::cfg{isBOOTSTRAPPING} = 1; + + Foswiki::Configure::Load::setBootstrap(); + $Foswiki::cfg{isVALID} = 1; } if ( $reporter->has_level('errors') ) {