aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/Configger/Main.cs
diff options
context:
space:
mode:
authorMelanie2010-02-08 15:21:35 +0000
committerMelanie2010-02-08 15:21:35 +0000
commit70a0d7aa4677c240ad12527adde6725df946e572 (patch)
treef5fb26c626a2b13c057fd4a0d902346501e176c0 /OpenSim/Tools/Configger/Main.cs
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim into mysql-p... (diff)
downloadopensim-SC_OLD-70a0d7aa4677c240ad12527adde6725df946e572.zip
opensim-SC_OLD-70a0d7aa4677c240ad12527adde6725df946e572.tar.gz
opensim-SC_OLD-70a0d7aa4677c240ad12527adde6725df946e572.tar.bz2
opensim-SC_OLD-70a0d7aa4677c240ad12527adde6725df946e572.tar.xz
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.
Diffstat (limited to '')
-rw-r--r--OpenSim/Tools/Configger/Main.cs108
1 files changed, 108 insertions, 0 deletions
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 @@
1using Nini.Config;
2using System;
3
4namespace Careminster
5{
6 public class Configger
7 {
8 public static int Main(string[] args)
9 {
10 ArgvConfigSource argvConfig = new ArgvConfigSource(args);
11 argvConfig.AddSwitch("Startup", "format", "f");
12
13 IConfig startupConfig = argvConfig.Configs["Startup"];
14
15 string format = startupConfig.GetString("format", "ini");
16
17 ConfigurationLoader loader = new ConfigurationLoader();
18
19 IConfigSource s = loader.LoadConfigSettings();
20
21 if (format == "mysql")
22 {
23 foreach (IConfig c in s.Configs)
24 {
25 foreach (string k in c.GetKeys())
26 {
27 string v = c.GetString(k);
28
29 if (k.StartsWith("Include-"))
30 continue;
31 Console.WriteLine("insert ignore into config (section, name, value) values ('{0}', '{1}', '{2}');", c.Name, k, v);
32 }
33 }
34 }
35 else if (format == "xml")
36 {
37 Console.WriteLine("<Nini>");
38
39 foreach (IConfig c in s.Configs)
40 {
41 int count = 0;
42
43 foreach (string k in c.GetKeys())
44 {
45 if (k.StartsWith("Include-"))
46 continue;
47
48 count++;
49 }
50
51 if (count > 0)
52 {
53 Console.WriteLine("<Section Name=\"{0}\">", c.Name);
54
55 foreach (string k in c.GetKeys())
56 {
57 string v = c.GetString(k);
58
59 if (k.StartsWith("Include-"))
60 continue;
61 Console.WriteLine(" <Key Name=\"{0}\" Value=\"{1}\" />", k, v);
62
63 Console.WriteLine("</Section>");
64 }
65 }
66 }
67 Console.WriteLine("</Nini>");
68 }
69 else if (format == "ini")
70 {
71 foreach (IConfig c in s.Configs)
72 {
73 int count = 0;
74
75 foreach (string k in c.GetKeys())
76 {
77 if (k.StartsWith("Include-"))
78 continue;
79
80 count++;
81 }
82
83 if (count > 0)
84 {
85 Console.WriteLine("[{0}]", c.Name);
86
87 foreach (string k in c.GetKeys())
88 {
89 string v = c.GetString(k);
90
91 if (k.StartsWith("Include-"))
92 continue;
93 Console.WriteLine("{0} = \"{1}\"", k, v);
94 }
95
96 Console.WriteLine();
97 }
98 }
99 }
100 else
101 {
102 Console.WriteLine("Error: unknown format: {0}", format);
103 }
104
105 return 0;
106 }
107 }
108}