aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/ConfigurationLoader.cs
diff options
context:
space:
mode:
authorMelanie2014-01-28 21:02:20 +0000
committerMelanie2014-01-28 21:02:20 +0000
commitc6e9db58669d773c85041db99b19b942f70324f7 (patch)
tree99f69fb669332cff69a45ce6f7473aed6d965a0d /OpenSim/Region/Application/ConfigurationLoader.cs
parentMerge branch 'master' into careminster (diff)
parentMerge branch 'justincc-master' (diff)
downloadopensim-SC-c6e9db58669d773c85041db99b19b942f70324f7.zip
opensim-SC-c6e9db58669d773c85041db99b19b942f70324f7.tar.gz
opensim-SC-c6e9db58669d773c85041db99b19b942f70324f7.tar.bz2
opensim-SC-c6e9db58669d773c85041db99b19b942f70324f7.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Framework/RegionSettings.cs OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs OpenSim/Region/Framework/Interfaces/IInterregionComms.cs OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Application/ConfigurationLoader.cs70
1 files changed, 46 insertions, 24 deletions
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index e3e0c01..52e520c 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -124,7 +124,7 @@ namespace OpenSim
124 else 124 else
125 { 125 {
126 Application.iniFilePath = Path.GetFullPath( 126 Application.iniFilePath = Path.GetFullPath(
127 Path.Combine(Util.configDir(), iniFileName)); 127 Path.Combine(Util.configDir(), iniFileName));
128 128
129 if (!File.Exists(Application.iniFilePath)) 129 if (!File.Exists(Application.iniFilePath))
130 { 130 {
@@ -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,33 +169,38 @@ 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)))
172 {
173 overrideSources.Add(Path.GetFullPath(filePath));
174 // put it in sources too, to avoid circularity
155 sources.Add(Path.GetFullPath(filePath)); 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 180
164 m_log.Info("[CONFIG]: Reading configuration settings"); 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 }
165 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!");
@@ -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 }