Skip to content

Commit

Permalink
Item13079: Fix initial configuration from shell
Browse files Browse the repository at this point in the history
  • Loading branch information
gac410 committed Nov 7, 2014
1 parent bba8fec commit ffa59a9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
36 changes: 27 additions & 9 deletions core/lib/Foswiki/Configure/Load.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: $@"
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 7 additions & 6 deletions core/tools/configure
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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') ) {
Expand Down

0 comments on commit ffa59a9

Please sign in to comment.