aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/ConfigurationLoader.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Application/ConfigurationLoader.cs98
1 files changed, 52 insertions, 46 deletions
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index fc3999f..b19e549 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -82,8 +82,7 @@ namespace OpenSim
82 82
83 List<string> sources = new List<string>(); 83 List<string> sources = new List<string>();
84 84
85 string masterFileName = 85 string masterFileName = startupConfig.GetString("inimaster", "OpenSimDefaults.ini");
86 startupConfig.GetString("inimaster", "OpenSimDefaults.ini");
87 86
88 if (masterFileName == "none") 87 if (masterFileName == "none")
89 masterFileName = String.Empty; 88 masterFileName = String.Empty;
@@ -124,7 +123,7 @@ namespace OpenSim
124 else 123 else
125 { 124 {
126 Application.iniFilePath = Path.GetFullPath( 125 Application.iniFilePath = Path.GetFullPath(
127 Path.Combine(Util.configDir(), iniFileName)); 126 Path.Combine(Util.configDir(), iniFileName));
128 127
129 if (!File.Exists(Application.iniFilePath)) 128 if (!File.Exists(Application.iniFilePath))
130 { 129 {
@@ -139,12 +138,29 @@ namespace OpenSim
139 } 138 }
140 } 139 }
141 140
141 m_config = new OpenSimConfigSource();
142 m_config.Source = new IniConfigSource();
143 m_config.Source.Merge(DefaultConfig());
144
145 m_log.Info("[CONFIG]: Reading configuration settings");
146
147 for (int i = 0 ; i < sources.Count ; i++)
148 {
149 if (ReadConfig(m_config, sources[i]))
150 {
151 iniFileExists = true;
152 AddIncludes(m_config, sources);
153 }
154 }
155
156 // Override distro settings with contents of inidirectory
142 string iniDirName = startupConfig.GetString("inidirectory", "config"); 157 string iniDirName = startupConfig.GetString("inidirectory", "config");
143 string iniDirPath = Path.Combine(Util.configDir(), iniDirName); 158 string iniDirPath = Path.Combine(Util.configDir(), iniDirName);
144 159
145 if (Directory.Exists(iniDirPath)) 160 if (Directory.Exists(iniDirPath))
146 { 161 {
147 m_log.InfoFormat("Searching folder {0} for config ini files", iniDirPath); 162 m_log.InfoFormat("[CONFIG]: Searching folder {0} for config ini files", iniDirPath);
163 List<string> overrideSources = new List<string>();
148 164
149 string[] fileEntries = Directory.GetFiles(iniDirName); 165 string[] fileEntries = Directory.GetFiles(iniDirName);
150 foreach (string filePath in fileEntries) 166 foreach (string filePath in fileEntries)
@@ -152,58 +168,52 @@ namespace OpenSim
152 if (Path.GetExtension(filePath).ToLower() == ".ini") 168 if (Path.GetExtension(filePath).ToLower() == ".ini")
153 { 169 {
154 if (!sources.Contains(Path.GetFullPath(filePath))) 170 if (!sources.Contains(Path.GetFullPath(filePath)))
171 {
172 overrideSources.Add(Path.GetFullPath(filePath));
173 // put it in sources too, to avoid circularity
155 sources.Add(Path.GetFullPath(filePath)); 174 sources.Add(Path.GetFullPath(filePath));
175 }
156 } 176 }
157 } 177 }
158 }
159 178
160 m_config = new OpenSimConfigSource();
161 m_config.Source = new IniConfigSource();
162 m_config.Source.Merge(DefaultConfig());
163 179
164 m_log.Info("[CONFIG]: Reading configuration settings"); 180 if (overrideSources.Count > 0)
181 {
182 OpenSimConfigSource overrideConfig = new OpenSimConfigSource();
183 overrideConfig.Source = new IniConfigSource();
184
185 for (int i = 0 ; i < overrideSources.Count ; i++)
186 {
187 if (ReadConfig(overrideConfig, overrideSources[i]))
188 {
189 iniFileExists = true;
190 AddIncludes(overrideConfig, overrideSources);
191 }
192 }
193 m_config.Source.Merge(overrideConfig.Source);
194 }
195 }
165 196
166 if (sources.Count == 0) 197 if (sources.Count == 0)
167 { 198 {
168 m_log.FatalFormat("[CONFIG]: Could not load any configuration"); 199 m_log.FatalFormat("[CONFIG]: Could not load any configuration");
169 Environment.Exit(1); 200 Environment.Exit(1);
170 } 201 }
171 202 else if (!iniFileExists)
172 for (int i = 0 ; i < sources.Count ; i++)
173 {
174 if (ReadConfig(sources[i]))
175 {
176 iniFileExists = true;
177 AddIncludes(sources);
178 }
179 }
180
181 if (!iniFileExists)
182 { 203 {
183 m_log.FatalFormat("[CONFIG]: Could not load any configuration"); 204 m_log.FatalFormat("[CONFIG]: Could not load any configuration");
184 m_log.FatalFormat("[CONFIG]: Configuration exists, but there was an error loading it!"); 205 m_log.FatalFormat("[CONFIG]: Configuration exists, but there was an error loading it!");
185 Environment.Exit(1); 206 Environment.Exit(1);
186 } 207 }
187 208
209 // Merge OpSys env vars
210 m_log.Info("[CONFIG]: Loading environment variables for Config");
211 Util.MergeEnvironmentToConfig(m_config.Source);
212
188 // Make sure command line options take precedence 213 // Make sure command line options take precedence
189 m_config.Source.Merge(argvSource); 214 m_config.Source.Merge(argvSource);
190 215
191 IConfig enVars = m_config.Source.Configs["Environment"]; 216 m_config.Source.ReplaceKeyValues();
192
193 if( enVars != null )
194 {
195 string[] env_keys = enVars.GetKeys();
196
197 foreach ( string key in env_keys )
198 {
199 envConfigSource.AddEnv(key, string.Empty);
200 }
201
202 envConfigSource.LoadEnv();
203 m_config.Source.Merge(envConfigSource);
204 m_config.Source.ExpandKeyValues();
205 }
206
207 217
208 ReadConfigSettings(); 218 ReadConfigSettings();
209 219
@@ -214,10 +224,10 @@ namespace OpenSim
214 /// Adds the included files as ini configuration files 224 /// Adds the included files as ini configuration files
215 /// </summary> 225 /// </summary>
216 /// <param name="sources">List of URL strings or filename strings</param> 226 /// <param name="sources">List of URL strings or filename strings</param>
217 private void AddIncludes(List<string> sources) 227 private void AddIncludes(OpenSimConfigSource configSource, List<string> sources)
218 { 228 {
219 //loop over config sources 229 //loop over config sources
220 foreach (IConfig config in m_config.Source.Configs) 230 foreach (IConfig config in configSource.Source.Configs)
221 { 231 {
222 // Look for Include-* in the key name 232 // Look for Include-* in the key name
223 string[] keys = config.GetKeys(); 233 string[] keys = config.GetKeys();
@@ -284,7 +294,7 @@ namespace OpenSim
284 /// </summary> 294 /// </summary>
285 /// <param name="iniPath">Full path to the ini</param> 295 /// <param name="iniPath">Full path to the ini</param>
286 /// <returns></returns> 296 /// <returns></returns>
287 private bool ReadConfig(string iniPath) 297 private bool ReadConfig(OpenSimConfigSource configSource, string iniPath)
288 { 298 {
289 bool success = false; 299 bool success = false;
290 300
@@ -292,7 +302,7 @@ namespace OpenSim
292 { 302 {
293 m_log.InfoFormat("[CONFIG]: Reading configuration file {0}", Path.GetFullPath(iniPath)); 303 m_log.InfoFormat("[CONFIG]: Reading configuration file {0}", Path.GetFullPath(iniPath));
294 304
295 m_config.Source.Merge(new IniConfigSource(iniPath)); 305 configSource.Source.Merge(new IniConfigSource(iniPath));
296 success = true; 306 success = true;
297 } 307 }
298 else 308 else
@@ -305,7 +315,7 @@ namespace OpenSim
305 { 315 {
306 XmlReader r = XmlReader.Create(iniPath); 316 XmlReader r = XmlReader.Create(iniPath);
307 XmlConfigSource cs = new XmlConfigSource(r); 317 XmlConfigSource cs = new XmlConfigSource(r);
308 m_config.Source.Merge(cs); 318 configSource.Source.Merge(cs);
309 319
310 success = true; 320 success = true;
311 } 321 }
@@ -337,10 +347,7 @@ namespace OpenSim
337 config.Set("physics", "OpenDynamicsEngine"); 347 config.Set("physics", "OpenDynamicsEngine");
338 config.Set("meshing", "Meshmerizer"); 348 config.Set("meshing", "Meshmerizer");
339 config.Set("physical_prim", true); 349 config.Set("physical_prim", true);
340 config.Set("see_into_this_sim_from_neighbor", true);
341 config.Set("serverside_object_permissions", true); 350 config.Set("serverside_object_permissions", true);
342 config.Set("storage_plugin", "OpenSim.Data.SQLite.dll");
343 config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3");
344 config.Set("storage_prim_inventories", true); 351 config.Set("storage_prim_inventories", true);
345 config.Set("startup_console_commands_file", String.Empty); 352 config.Set("startup_console_commands_file", String.Empty);
346 config.Set("shutdown_console_commands_file", String.Empty); 353 config.Set("shutdown_console_commands_file", String.Empty);
@@ -372,7 +379,6 @@ namespace OpenSim
372 { 379 {
373 m_configSettings.PhysicsEngine = startupConfig.GetString("physics"); 380 m_configSettings.PhysicsEngine = startupConfig.GetString("physics");
374 m_configSettings.MeshEngineName = startupConfig.GetString("meshing"); 381 m_configSettings.MeshEngineName = startupConfig.GetString("meshing");
375 m_configSettings.StorageDll = startupConfig.GetString("storage_plugin");
376 382
377 m_configSettings.ClientstackDll 383 m_configSettings.ClientstackDll
378 = startupConfig.GetString("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll"); 384 = startupConfig.GetString("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");