From 3e71c71cbffb0de454759e2bbd0ff840dfa480bc Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 3 Oct 2012 16:07:11 -0400 Subject: Add modular configuration for Robust connectors We can provide modular ini for connectors... look for our configuration in the following places... 1) in the default ini/-inifile 2) in the named file (ConfigName) located in the configured directory (see Robust[.HG].ini [Start] section for ConfigDirectory) 3) in the repository named in the connector (ConfigURL) In this case, the file will be written into the configured directory with the specified See example connector/service @ https://github.com/BlueWall/SlipStream for testing. --- OpenSim/Server/Base/ServerUtils.cs | 38 +++++++++++++++++++++++++++++++ OpenSim/Server/Base/ServicesServerBase.cs | 8 +++++++ 2 files changed, 46 insertions(+) (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 42c82cf..4a696c4 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -33,6 +33,7 @@ using System.Xml.Serialization; using System.Text; using System.Collections.Generic; using log4net; +using Nini.Config; using OpenSim.Framework; using OpenMetaverse; @@ -333,5 +334,42 @@ namespace OpenSim.Server.Base return ret; } + + public static IConfig GetConfig(string configFile, string configName) + { + IConfig config; + + if (File.Exists(configFile)) + { + IConfigSource configsource = new IniConfigSource(configFile); + config = configsource.Configs[configName]; + } + else + config = null; + + return config; + } + + public static IConfigSource LoadInitialConfig(string url) + { + IConfigSource source = new XmlConfigSource(); + m_log.InfoFormat("[CONFIG]: {0} is a http:// URI, fetching ...", url); + + // The ini file path is a http URI + // Try to read it + try + { + XmlReader r = XmlReader.Create(url); + IConfigSource cs = new XmlConfigSource(r); + source.Merge(cs); + } + catch (Exception e) + { + m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), url); + Environment.Exit(1); + } + + return source; + } } } diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index 0cff6ed..2f12288 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs @@ -64,6 +64,12 @@ namespace OpenSim.Server.Base get { return m_Config; } } + public string ConfigDirectory + { + get; + private set; + } + // Run flag // private bool m_Running = true; @@ -153,6 +159,8 @@ namespace OpenSim.Server.Base startupConfig = m_Config.Configs["Startup"]; } + ConfigDirectory = startupConfig.GetString("ConfigDirectory", "."); + prompt = startupConfig.GetString("Prompt", prompt); // Allow derived classes to load config before the console is -- cgit v1.1