aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/ConfigurationLoader.cs
diff options
context:
space:
mode:
authorDev Random2014-01-23 23:05:00 -0500
committerJustin Clark-Casey (justincc)2014-01-27 23:56:10 +0000
commit8c2b41b01dac74ecd4275d558d1bf1462f691b0e (patch)
tree553f82ff7c8730172c03c1db1a6967912a4234ce /OpenSim/Region/Application/ConfigurationLoader.cs
parentminor: remove long unused state queue from "show queues" console reports (diff)
downloadopensim-SC_OLD-8c2b41b01dac74ecd4275d558d1bf1462f691b0e.zip
opensim-SC_OLD-8c2b41b01dac74ecd4275d558d1bf1462f691b0e.tar.gz
opensim-SC_OLD-8c2b41b01dac74ecd4275d558d1bf1462f691b0e.tar.bz2
opensim-SC_OLD-8c2b41b01dac74ecd4275d558d1bf1462f691b0e.tar.xz
Make inidirectory files supercede distro files
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Application/ConfigurationLoader.cs76
1 files changed, 49 insertions, 27 deletions
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index e3e0c01..9634dab 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -139,12 +139,29 @@ namespace OpenSim
139 } 139 }
140 } 140 }
141 141
142 m_config = new OpenSimConfigSource();
143 m_config.Source = new IniConfigSource();
144 m_config.Source.Merge(DefaultConfig());
145
146 m_log.Info("[CONFIG]: Reading configuration settings");
147
148 for (int i = 0 ; i < sources.Count ; i++)
149 {
150 if (ReadConfig(m_config, sources[i]))
151 {
152 iniFileExists = true;
153 AddIncludes(m_config, sources);
154 }
155 }
156
157 // Override distro settings with contents of inidirectory
142 string iniDirName = startupConfig.GetString("inidirectory", "config"); 158 string iniDirName = startupConfig.GetString("inidirectory", "config");
143 string iniDirPath = Path.Combine(Util.configDir(), iniDirName); 159 string iniDirPath = Path.Combine(Util.configDir(), iniDirName);
144 160
145 if (Directory.Exists(iniDirPath)) 161 if (Directory.Exists(iniDirPath))
146 { 162 {
147 m_log.InfoFormat("Searching folder {0} for config ini files", iniDirPath); 163 m_log.InfoFormat("[CONFIG]: Searching folder {0} for config ini files", iniDirPath);
164 List<string> overrideSources = new List<string>();
148 165
149 string[] fileEntries = Directory.GetFiles(iniDirName); 166 string[] fileEntries = Directory.GetFiles(iniDirName);
150 foreach (string filePath in fileEntries) 167 foreach (string filePath in fileEntries)
@@ -152,40 +169,45 @@ namespace OpenSim
152 if (Path.GetExtension(filePath).ToLower() == ".ini") 169 if (Path.GetExtension(filePath).ToLower() == ".ini")
153 { 170 {
154 if (!sources.Contains(Path.GetFullPath(filePath))) 171 if (!sources.Contains(Path.GetFullPath(filePath)))
155 sources.Add(Path.GetFullPath(filePath)); 172 {
173 overrideSources.Add(Path.GetFullPath(filePath));
174 // put it in sources too, to avoid circularity
175 sources.Add(Path.GetFullPath(filePath));
176 }
156 } 177 }
157 } 178 }
158 }
159 179
160 m_config = new OpenSimConfigSource();
161 m_config.Source = new IniConfigSource();
162 m_config.Source.Merge(DefaultConfig());
163
164 m_log.Info("[CONFIG]: Reading configuration settings");
165 180
181 if (overrideSources.Count > 0)
182 {
183 OpenSimConfigSource overrideConfig = new OpenSimConfigSource();
184 overrideConfig.Source = new IniConfigSource();
185
186 for (int i = 0 ; i < overrideSources.Count ; i++)
187 {
188 if (ReadConfig(overrideConfig, overrideSources[i]))
189 {
190 iniFileExists = true;
191 AddIncludes(overrideConfig, overrideSources);
192 }
193 }
194 m_config.Source.Merge(overrideConfig.Source);
195 }
196 }
197
166 if (sources.Count == 0) 198 if (sources.Count == 0)
167 { 199 {
168 m_log.FatalFormat("[CONFIG]: Could not load any configuration"); 200 m_log.FatalFormat("[CONFIG]: Could not load any configuration");
169 Environment.Exit(1); 201 Environment.Exit(1);
170 } 202 }
171 203 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 { 204 {
183 m_log.FatalFormat("[CONFIG]: Could not load any configuration"); 205 m_log.FatalFormat("[CONFIG]: Could not load any configuration");
184 m_log.FatalFormat("[CONFIG]: Configuration exists, but there was an error loading it!"); 206 m_log.FatalFormat("[CONFIG]: Configuration exists, but there was an error loading it!");
185 Environment.Exit(1); 207 Environment.Exit(1);
186 } 208 }
187 209
188 // Make sure command line options take precedence 210 // Make sure command line options take precedence
189 m_config.Source.Merge(argvSource); 211 m_config.Source.Merge(argvSource);
190 212
191 IConfig enVars = m_config.Source.Configs["Environment"]; 213 IConfig enVars = m_config.Source.Configs["Environment"];
@@ -214,10 +236,10 @@ namespace OpenSim
214 /// Adds the included files as ini configuration files 236 /// Adds the included files as ini configuration files
215 /// </summary> 237 /// </summary>
216 /// <param name="sources">List of URL strings or filename strings</param> 238 /// <param name="sources">List of URL strings or filename strings</param>
217 private void AddIncludes(List<string> sources) 239 private void AddIncludes(OpenSimConfigSource configSource, List<string> sources)
218 { 240 {
219 //loop over config sources 241 //loop over config sources
220 foreach (IConfig config in m_config.Source.Configs) 242 foreach (IConfig config in configSource.Source.Configs)
221 { 243 {
222 // Look for Include-* in the key name 244 // Look for Include-* in the key name
223 string[] keys = config.GetKeys(); 245 string[] keys = config.GetKeys();
@@ -284,7 +306,7 @@ namespace OpenSim
284 /// </summary> 306 /// </summary>
285 /// <param name="iniPath">Full path to the ini</param> 307 /// <param name="iniPath">Full path to the ini</param>
286 /// <returns></returns> 308 /// <returns></returns>
287 private bool ReadConfig(string iniPath) 309 private bool ReadConfig(OpenSimConfigSource configSource, string iniPath)
288 { 310 {
289 bool success = false; 311 bool success = false;
290 312
@@ -292,7 +314,7 @@ namespace OpenSim
292 { 314 {
293 m_log.InfoFormat("[CONFIG]: Reading configuration file {0}", Path.GetFullPath(iniPath)); 315 m_log.InfoFormat("[CONFIG]: Reading configuration file {0}", Path.GetFullPath(iniPath));
294 316
295 m_config.Source.Merge(new IniConfigSource(iniPath)); 317 configSource.Source.Merge(new IniConfigSource(iniPath));
296 success = true; 318 success = true;
297 } 319 }
298 else 320 else
@@ -305,7 +327,7 @@ namespace OpenSim
305 { 327 {
306 XmlReader r = XmlReader.Create(iniPath); 328 XmlReader r = XmlReader.Create(iniPath);
307 XmlConfigSource cs = new XmlConfigSource(r); 329 XmlConfigSource cs = new XmlConfigSource(r);
308 m_config.Source.Merge(cs); 330 configSource.Source.Merge(cs);
309 331
310 success = true; 332 success = true;
311 } 333 }