From 70a0d7aa4677c240ad12527adde6725df946e572 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 8 Feb 2010 15:21:35 +0000 Subject: Adding the Careminster "Configger" tool to OpenSim. The tool will, when launched in place of OpenSim, dump the config to stdout. Use -f xml, -f ini or -f mysql to get a condensed ini file, an xml file suitable for webloading, or a set of mysql insert statements. --- OpenSim/Tools/Configger/Main.cs | 108 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 OpenSim/Tools/Configger/Main.cs (limited to 'OpenSim/Tools/Configger/Main.cs') diff --git a/OpenSim/Tools/Configger/Main.cs b/OpenSim/Tools/Configger/Main.cs new file mode 100644 index 0000000..c85f0d2 --- /dev/null +++ b/OpenSim/Tools/Configger/Main.cs @@ -0,0 +1,108 @@ +using Nini.Config; +using System; + +namespace Careminster +{ + public class Configger + { + public static int Main(string[] args) + { + ArgvConfigSource argvConfig = new ArgvConfigSource(args); + argvConfig.AddSwitch("Startup", "format", "f"); + + IConfig startupConfig = argvConfig.Configs["Startup"]; + + string format = startupConfig.GetString("format", "ini"); + + ConfigurationLoader loader = new ConfigurationLoader(); + + IConfigSource s = loader.LoadConfigSettings(); + + if (format == "mysql") + { + foreach (IConfig c in s.Configs) + { + foreach (string k in c.GetKeys()) + { + string v = c.GetString(k); + + if (k.StartsWith("Include-")) + continue; + Console.WriteLine("insert ignore into config (section, name, value) values ('{0}', '{1}', '{2}');", c.Name, k, v); + } + } + } + else if (format == "xml") + { + Console.WriteLine(""); + + foreach (IConfig c in s.Configs) + { + int count = 0; + + foreach (string k in c.GetKeys()) + { + if (k.StartsWith("Include-")) + continue; + + count++; + } + + if (count > 0) + { + Console.WriteLine("
", c.Name); + + foreach (string k in c.GetKeys()) + { + string v = c.GetString(k); + + if (k.StartsWith("Include-")) + continue; + Console.WriteLine(" ", k, v); + + Console.WriteLine("
"); + } + } + } + Console.WriteLine("
"); + } + else if (format == "ini") + { + foreach (IConfig c in s.Configs) + { + int count = 0; + + foreach (string k in c.GetKeys()) + { + if (k.StartsWith("Include-")) + continue; + + count++; + } + + if (count > 0) + { + Console.WriteLine("[{0}]", c.Name); + + foreach (string k in c.GetKeys()) + { + string v = c.GetString(k); + + if (k.StartsWith("Include-")) + continue; + Console.WriteLine("{0} = \"{1}\"", k, v); + } + + Console.WriteLine(); + } + } + } + else + { + Console.WriteLine("Error: unknown format: {0}", format); + } + + return 0; + } + } +} -- cgit v1.1