Add the ability to read the ini file from a URI. If the -inifile option

is a http:// URI, it will be fetched and parsed as an XML config.
0.6.2-post-fixes
Melanie Thielker 2009-01-02 05:52:01 +00:00
parent d8ebf2fc9d
commit 18ba10b51c
1 changed files with 33 additions and 6 deletions

View File

@ -28,6 +28,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Xml;
using System.Threading; using System.Threading;
using System.IO; using System.IO;
using OpenSim.Framework; using OpenSim.Framework;
@ -79,15 +80,41 @@ namespace OpenSim
} }
else else
{ {
// check for a xml config file Uri configUri;
Application.iniFilePath = Path.Combine(Util.configDir(), "OpenSim.xml");
if (File.Exists(Application.iniFilePath)) if (Uri.TryCreate(startupConfig.GetString("inifile", "OpenSim.ini"), UriKind.Absolute, out configUri) && configUri.Scheme == Uri.UriSchemeHttp)
{ {
iniFileExists = true; Console.WriteLine("[CONFIG] {0} is a URI, fetching ...", startupConfig.GetString("inifile", "OpenSim.ini"));
m_config.Source = new XmlConfigSource(); // The ini file path is a http URI
m_config.Source.Merge(new XmlConfigSource(Application.iniFilePath)); // Try to read it
//
try
{
XmlReader r = XmlReader.Create(startupConfig.GetString("inifile", "OpenSim.ini"));
XmlConfigSource cs = new XmlConfigSource(r);
m_config.Source.Merge(cs);
iniFileExists = true;
Console.WriteLine("[CONFIG] Uri fetch complete");
}
catch (Exception e)
{
Console.WriteLine("Exception {0} reading config from URI {1}", e.ToString(), startupConfig.GetString("inifile", "OpenSim.ini"));
}
}
else
{
// check for a xml config file
Application.iniFilePath = Path.Combine(Util.configDir(), "OpenSim.xml");
if (File.Exists(Application.iniFilePath))
{
iniFileExists = true;
m_config.Source = new XmlConfigSource();
m_config.Source.Merge(new XmlConfigSource(Application.iniFilePath));
}
} }
} }