29 using System.Collections.Generic;
31 using System.Reflection;
32 using System.Threading;
52 private static readonly ILog m_log =
54 MethodBase.GetCurrentMethod().DeclaringType);
69 bool iniFileExists =
false;
71 List<string> sources =
new List<string>();
73 string masterFileName = startupConfig.GetString(
"inimaster",
"OpenSimDefaults.ini");
75 if (masterFileName ==
"none")
76 masterFileName = String.Empty;
78 if (IsUri(masterFileName))
80 if (!sources.Contains(masterFileName))
81 sources.Add(masterFileName);
85 string masterFilePath = Path.GetFullPath(
86 Path.Combine(Util.configDir(), masterFileName));
88 if (masterFileName != String.Empty)
90 if (File.Exists(masterFilePath))
92 if (!sources.Contains(masterFilePath))
93 sources.Add(masterFilePath);
97 m_log.ErrorFormat(
"Master ini file {0} not found", Path.GetFullPath(masterFilePath));
103 string iniFileName = startupConfig.GetString(
"inifile", Path.Combine(
".",
"OpenSim.ini"));
105 if (IsUri(iniFileName))
107 if (!sources.Contains(iniFileName))
108 sources.Add(iniFileName);
112 if (File.Exists(iniFileName))
114 if (!sources.Contains(iniFileName))
115 sources.Add(iniFileName);
120 m_config.Merge(DefaultConfig());
122 m_log.Info(
"[CONFIG] Reading configuration settings");
124 if (sources.Count == 0)
126 m_log.FatalFormat(
"[CONFIG] Could not load any configuration");
127 m_log.FatalFormat(
"[CONFIG] Did you copy the OpenSim.ini.example file to OpenSim.ini?");
131 for (
int i = 0 ; i < sources.Count ; i++)
133 if (ReadConfig(sources[i]))
134 iniFileExists =
true;
135 AddIncludes(sources);
140 m_log.FatalFormat(
"[CONFIG] Could not load any configuration");
141 m_log.FatalFormat(
"[CONFIG] Configuration exists, but there was an error loading it!");
152 private void AddIncludes(List<string> sources)
155 foreach (IConfig config
in m_config.Configs)
158 string[] keys = config.GetKeys();
159 foreach (
string k
in keys)
161 if (k.StartsWith(
"Include-"))
164 string file = config.GetString(k);
167 if (!sources.Contains(file))
172 string basepath = Path.GetFullPath(
".");
174 string chunkWithoutWildcards = file;
175 string chunkWithWildcards = string.Empty;
176 int wildcardIndex = file.IndexOfAny(
new char[] {
'*',
'?' });
177 if (wildcardIndex != -1)
179 chunkWithoutWildcards = file.Substring(0, wildcardIndex);
180 chunkWithWildcards = file.Substring(wildcardIndex);
182 string path = Path.Combine(basepath, chunkWithoutWildcards);
183 path = Path.GetFullPath(path) + chunkWithWildcards;
184 string[] paths = Util.Glob(path);
185 foreach (
string p
in paths)
187 if (!sources.Contains(p))
200 bool IsUri(
string file)
204 return Uri.TryCreate(file, UriKind.Absolute,
205 out configUri) && configUri.Scheme == Uri.UriSchemeHttp;
213 private bool ReadConfig(
string iniPath)
215 bool success =
false;
219 m_log.InfoFormat(
"[CONFIG] Reading configuration file {0}",
220 Path.GetFullPath(iniPath));
222 m_config.Merge(
new IniConfigSource(iniPath));
227 m_log.InfoFormat(
"[CONFIG] {0} is a http:// URI, fetching ...",
235 XmlReader r = XmlReader.Create(iniPath);
236 XmlConfigSource cs =
new XmlConfigSource(r);
243 m_log.FatalFormat(
"[CONFIG] Exception reading config from URI {0}\n" + e.ToString(), iniPath);
254 private static IConfigSource DefaultConfig()
256 IConfigSource defaultConfig =
new IniConfigSource();
259 IConfig config = defaultConfig.Configs[
"Startup"];
262 config = defaultConfig.AddConfig(
"Startup");
264 config.Set(
"region_info_source",
"filesystem");
265 config.Set(
"allow_regionless",
false);
267 config.Set(
"gridmode",
false);
268 config.Set(
"physics",
"OpenDynamicsEngine");
269 config.Set(
"meshing",
"Meshmerizer");
270 config.Set(
"physical_prim",
true);
271 config.Set(
"serverside_object_permissions",
true);
272 config.Set(
"storage_prim_inventories",
true);
273 config.Set(
"startup_console_commands_file", String.Empty);
274 config.Set(
"shutdown_console_commands_file", String.Empty);
275 config.Set(
"DefaultScriptEngine",
"XEngine");
276 config.Set(
"clientstack_plugin",
"OpenSim.Region.ClientStack.LindenUDP.dll");
278 config.Set(
"EventQueue",
true);
281 return defaultConfig;
OpenSimConfigSource m_config
A source of Configuration data
Interactive OpenSim region server