From d4e3a7fe81a155be841bc0d182aa7a14083ffa3e Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Sat, 19 Nov 2011 11:01:51 -0500
Subject: Shell Environment Variables in config
Adding updated Nini and support to use shell environment variables in OpenSimulator configuration.
Nini @ https://github.com/BlueWall/Nini-Dev
---
OpenSim/Region/Application/ConfigurationLoader.cs | 20 +++++++++++++++++++-
OpenSim/Region/Application/OpenSimBase.cs | 9 ++++++++-
OpenSim/Tests/ConfigurationLoaderTest.cs | 4 +++-
bin/Nini.dll | Bin 61440 -> 55808 bytes
4 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index d0f6ab7..4a7c8b0 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -70,7 +70,7 @@ namespace OpenSim
///
/// A configuration that gets passed to modules
public OpenSimConfigSource LoadConfigSettings(
- IConfigSource argvSource, out ConfigSettings configSettings,
+ IConfigSource argvSource, EnvConfigSource envConfigSource, out ConfigSettings configSettings,
out NetworkServersInfo networkInfo)
{
m_configSettings = configSettings = new ConfigSettings();
@@ -195,6 +195,24 @@ namespace OpenSim
// Make sure command line options take precedence
m_config.Source.Merge(argvSource);
+
+ IConfig enVars = m_config.Source.Configs["Environment"];
+
+ if( enVars != null )
+ {
+ string[] env_keys = enVars.GetKeys();
+
+ foreach ( string key in env_keys )
+ {
+ envConfigSource.AddEnv(key, string.Empty);
+ }
+
+ envConfigSource.LoadEnv();
+ m_config.Source.Merge(envConfigSource);
+ m_config.Source.ExpandKeyValues();
+ }
+
+
ReadConfigSettings();
return m_config;
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 553786b..0a78df2 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -108,6 +108,13 @@ namespace OpenSim
get { return m_clientServers; }
}
+ protected EnvConfigSource m_EnvConfigSource = new EnvConfigSource();
+
+ public EnvConfigSource envConfigSource
+ {
+ get { return m_EnvConfigSource; }
+ }
+
protected List m_clientServers = new List();
public uint HttpServerPort
@@ -142,7 +149,7 @@ namespace OpenSim
protected virtual void LoadConfigSettings(IConfigSource configSource)
{
m_configLoader = new ConfigurationLoader();
- m_config = m_configLoader.LoadConfigSettings(configSource, out m_configSettings, out m_networkServersInfo);
+ m_config = m_configLoader.LoadConfigSettings(configSource, envConfigSource, out m_configSettings, out m_networkServersInfo);
ReadExtraConfigSettings();
}
diff --git a/OpenSim/Tests/ConfigurationLoaderTest.cs b/OpenSim/Tests/ConfigurationLoaderTest.cs
index c777acc..067264d 100644
--- a/OpenSim/Tests/ConfigurationLoaderTest.cs
+++ b/OpenSim/Tests/ConfigurationLoaderTest.cs
@@ -109,11 +109,13 @@ namespace OpenSim.Tests
// Prepare call to ConfigurationLoader.LoadConfigSettings()
ConfigurationLoader cl = new ConfigurationLoader();
IConfigSource argvSource = new IniConfigSource();
+ EnvConfigSource envConfigSource = new EnvConfigSource();
argvSource.AddConfig("Startup").Set("inifile", mainIniFile);
ConfigSettings configSettings;
NetworkServersInfo networkInfo;
- OpenSimConfigSource source = cl.LoadConfigSettings(argvSource, out configSettings, out networkInfo);
+ OpenSimConfigSource source = cl.LoadConfigSettings(argvSource, envConfigSource,
+ out configSettings, out networkInfo);
// Remove default config
config = source.Source.Configs["Startup"];
diff --git a/bin/Nini.dll b/bin/Nini.dll
index 745057c..c421005 100755
Binary files a/bin/Nini.dll and b/bin/Nini.dll differ
--
cgit v1.1