From 18ba10b51c1a37fadd6c750c06f5672cfb15438a Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 2 Jan 2009 05:52:01 +0000 Subject: [PATCH] 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. --- .../Region/Application/ConfigurationLoader.cs | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs index 12cb0ea070..d55ad32a78 100644 --- a/OpenSim/Region/Application/ConfigurationLoader.cs +++ b/OpenSim/Region/Application/ConfigurationLoader.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.Text; +using System.Xml; using System.Threading; using System.IO; using OpenSim.Framework; @@ -79,15 +80,41 @@ namespace OpenSim } else { - // check for a xml config file - Application.iniFilePath = Path.Combine(Util.configDir(), "OpenSim.xml"); + Uri configUri; - 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(); - m_config.Source.Merge(new XmlConfigSource(Application.iniFilePath)); + // 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 + 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)); + } } }