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;
@ -78,6 +79,31 @@ namespace OpenSim
m_config.Source.Merge(new IniConfigSource(Application.iniFilePath)); m_config.Source.Merge(new IniConfigSource(Application.iniFilePath));
} }
else else
{
Uri configUri;
if (Uri.TryCreate(startupConfig.GetString("inifile", "OpenSim.ini"), UriKind.Absolute, out configUri) && configUri.Scheme == Uri.UriSchemeHttp)
{
Console.WriteLine("[CONFIG] {0} is a URI, fetching ...", startupConfig.GetString("inifile", "OpenSim.ini"));
// The ini file path is a http URI
// 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 // check for a xml config file
Application.iniFilePath = Path.Combine(Util.configDir(), "OpenSim.xml"); Application.iniFilePath = Path.Combine(Util.configDir(), "OpenSim.xml");
@ -90,6 +116,7 @@ namespace OpenSim
m_config.Source.Merge(new XmlConfigSource(Application.iniFilePath)); m_config.Source.Merge(new XmlConfigSource(Application.iniFilePath));
} }
} }
}
m_config.Source.Merge(configSource); m_config.Source.Merge(configSource);