aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMW2008-11-05 20:14:52 +0000
committerMW2008-11-05 20:14:52 +0000
commit571b94f537cc1f431ed52e6a185863ae17357f30 (patch)
treeff5381abcf3237c7a9339a1b5e2904d88f75bfa1
parent* Zap the letters that accidentally crept in to the license in EventQueueThre... (diff)
downloadopensim-SC_OLD-571b94f537cc1f431ed52e6a185863ae17357f30.zip
opensim-SC_OLD-571b94f537cc1f431ed52e6a185863ae17357f30.tar.gz
opensim-SC_OLD-571b94f537cc1f431ed52e6a185863ae17357f30.tar.bz2
opensim-SC_OLD-571b94f537cc1f431ed52e6a185863ae17357f30.tar.xz
moved the initial loading/setting of the config settings to its own class, ConfigurationLoader. To make it easier to customise the loading of those settings and possible in the future move it to a plugin.
-rw-r--r--OpenSim/Framework/ConfigSettings.cs8
-rw-r--r--OpenSim/Region/Application/ConfigurationLoader.cs196
-rw-r--r--OpenSim/Region/Application/OpenSim.cs3
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs183
-rw-r--r--OpenSim/Tools/Export/OpenSimExport.cs2
5 files changed, 216 insertions, 176 deletions
diff --git a/OpenSim/Framework/ConfigSettings.cs b/OpenSim/Framework/ConfigSettings.cs
index 275ab69..3ff02f9 100644
--- a/OpenSim/Framework/ConfigSettings.cs
+++ b/OpenSim/Framework/ConfigSettings.cs
@@ -148,5 +148,13 @@ namespace OpenSim.Framework
148 get { return m_estateConnectionString; } 148 get { return m_estateConnectionString; }
149 set { m_estateConnectionString = value; } 149 set { m_estateConnectionString = value; }
150 } 150 }
151
152 protected bool m_dumpAssetsToFile;
153
154 public bool DumpAssetsToFile
155 {
156 get { return m_dumpAssetsToFile; }
157 set { m_dumpAssetsToFile = value; }
158 }
151 } 159 }
152} 160}
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
new file mode 100644
index 0000000..6fde140
--- /dev/null
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -0,0 +1,196 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Threading;
5using System.IO;
6using OpenSim.Framework;
7using Nini;
8using Nini.Config;
9
10namespace OpenSim
11{
12 public class ConfigurationLoader
13 {
14 protected ConfigSettings m_configSettings;
15 protected OpenSimConfigSource m_config;
16 protected NetworkServersInfo m_networkServersInfo;
17
18 public ConfigurationLoader()
19 {
20
21 }
22
23 public OpenSimConfigSource LoadConfigSettings(IConfigSource configSource, out ConfigSettings configSettings, out NetworkServersInfo networkInfo)
24 {
25 m_configSettings = configSettings = new ConfigSettings();
26 m_networkServersInfo = networkInfo = new NetworkServersInfo();
27 bool iniFileExists = false;
28
29 IConfig startupConfig = configSource.Configs["Startup"];
30
31 string iniFileName = startupConfig.GetString("inifile", "OpenSim.ini");
32 Application.iniFilePath = Path.Combine(Util.configDir(), iniFileName);
33
34 string masterFileName = startupConfig.GetString("inimaster", "");
35 string masterfilePath = Path.Combine(Util.configDir(), masterFileName);
36
37 m_config = new OpenSimConfigSource();
38 m_config.Source = new IniConfigSource();
39 m_config.Source.Merge(DefaultConfig());
40
41 //check for .INI file (either default or name passed in command line)
42 if (File.Exists(masterfilePath))
43 {
44 m_config.Source.Merge(new IniConfigSource(masterfilePath));
45 }
46
47 if (File.Exists(Application.iniFilePath))
48 {
49 iniFileExists = true;
50
51 // From reading Nini's code, it seems that later merged keys replace earlier ones.
52 m_config.Source.Merge(new IniConfigSource(Application.iniFilePath));
53 }
54 else
55 {
56 // check for a xml config file
57 Application.iniFilePath = Path.Combine(Util.configDir(), "OpenSim.xml");
58
59 if (File.Exists(Application.iniFilePath))
60 {
61 iniFileExists = true;
62
63 m_config.Source = new XmlConfigSource();
64 m_config.Source.Merge(new XmlConfigSource(Application.iniFilePath));
65 }
66 }
67
68 m_config.Source.Merge(configSource);
69
70 if (!iniFileExists)
71 m_config.Save("OpenSim.ini");
72
73 ReadConfigSettings();
74
75 return m_config;
76 }
77
78 /// <summary>
79 /// Setup a default config values in case they aren't present in the ini file
80 /// </summary>
81 /// <returns></returns>
82 public static IConfigSource DefaultConfig()
83 {
84 IConfigSource defaultConfig = new IniConfigSource();
85
86 {
87 IConfig config = defaultConfig.Configs["Startup"];
88
89 if (null == config)
90 config = defaultConfig.AddConfig("Startup");
91
92 config.Set("gridmode", false);
93 config.Set("physics", "basicphysics");
94 config.Set("meshing", "ZeroMesher");
95 config.Set("physical_prim", true);
96 config.Set("see_into_this_sim_from_neighbor", true);
97 config.Set("serverside_object_permissions", false);
98 config.Set("storage_plugin", "OpenSim.Data.SQLite.dll");
99 config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3");
100 config.Set("storage_prim_inventories", true);
101 config.Set("startup_console_commands_file", String.Empty);
102 config.Set("shutdown_console_commands_file", String.Empty);
103 config.Set("DefaultScriptEngine", "ScriptEngine.DotNetEngine");
104 config.Set("asset_database", "sqlite");
105 config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
106 }
107
108 {
109 IConfig config = defaultConfig.Configs["StandAlone"];
110
111 if (null == config)
112 config = defaultConfig.AddConfig("StandAlone");
113
114 config.Set("accounts_authenticate", false);
115 config.Set("welcome_message", "Welcome to OpenSimulator");
116 config.Set("inventory_plugin", "OpenSim.Data.SQLite.dll");
117 config.Set("inventory_source", "");
118 config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll");
119 config.Set("user_source", "");
120 config.Set("asset_plugin", "OpenSim.Data.SQLite.dll");
121 config.Set("asset_source", "");
122 config.Set("dump_assets_to_file", false);
123 }
124
125 {
126 IConfig config = defaultConfig.Configs["Network"];
127
128 if (null == config)
129 config = defaultConfig.AddConfig("Network");
130
131 config.Set("default_location_x", 1000);
132 config.Set("default_location_y", 1000);
133 config.Set("http_listener_port", NetworkServersInfo.DefaultHttpListenerPort);
134 config.Set("remoting_listener_port", NetworkServersInfo.RemotingListenerPort);
135 config.Set("grid_server_url", "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString());
136 config.Set("grid_send_key", "null");
137 config.Set("grid_recv_key", "null");
138 config.Set("user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString());
139 config.Set("user_send_key", "null");
140 config.Set("user_recv_key", "null");
141 config.Set("asset_server_url", "http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString());
142 config.Set("inventory_server_url", "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort.ToString());
143 config.Set("secure_inventory_server", "true");
144 }
145
146 return defaultConfig;
147 }
148
149 protected virtual void ReadConfigSettings()
150 {
151 IConfig startupConfig = m_config.Source.Configs["Startup"];
152
153 if (startupConfig != null)
154 {
155 m_configSettings.Standalone = !startupConfig.GetBoolean("gridmode");
156 m_configSettings.PhysicsEngine = startupConfig.GetString("physics");
157 m_configSettings.MeshEngineName = startupConfig.GetString("meshing");
158
159 m_configSettings.PhysicalPrim = startupConfig.GetBoolean("physical_prim");
160
161 m_configSettings.See_into_region_from_neighbor = startupConfig.GetBoolean("see_into_this_sim_from_neighbor");
162
163 m_configSettings.StorageDll = startupConfig.GetString("storage_plugin");
164 if (m_configSettings.StorageDll == "OpenSim.DataStore.MonoSqlite.dll")
165 {
166 m_configSettings.StorageDll = "OpenSim.Data.SQLite.dll";
167 Console.WriteLine("WARNING: OpenSim.DataStore.MonoSqlite.dll is deprecated. Set storage_plugin to OpenSim.Data.SQLite.dll.");
168 Thread.Sleep(3000);
169 }
170
171 m_configSettings.StorageConnectionString = startupConfig.GetString("storage_connection_string");
172 m_configSettings.EstateConnectionString = startupConfig.GetString("estate_connection_string", m_configSettings.StorageConnectionString);
173 m_configSettings.AssetStorage = startupConfig.GetString("asset_database");
174 m_configSettings.ClientstackDll = startupConfig.GetString("clientstack_plugin");
175 }
176
177 IConfig standaloneConfig = m_config.Source.Configs["StandAlone"];
178 if (standaloneConfig != null)
179 {
180 m_configSettings.StandaloneAuthenticate = standaloneConfig.GetBoolean("accounts_authenticate");
181 m_configSettings.StandaloneWelcomeMessage = standaloneConfig.GetString("welcome_message");
182
183 m_configSettings.StandaloneInventoryPlugin = standaloneConfig.GetString("inventory_plugin");
184 m_configSettings.StandaloneInventorySource = standaloneConfig.GetString("inventory_source");
185 m_configSettings.StandaloneUserPlugin = standaloneConfig.GetString("userDatabase_plugin");
186 m_configSettings.StandaloneUserSource = standaloneConfig.GetString("user_source");
187 m_configSettings.StandaloneAssetPlugin = standaloneConfig.GetString("asset_plugin");
188 m_configSettings.StandaloneAssetSource = standaloneConfig.GetString("asset_source");
189
190 m_configSettings.DumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file");
191 }
192
193 m_networkServersInfo.loadFromConfiguration(m_config.Source);
194 }
195 }
196}
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index e710ec2..763aaa5 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -67,7 +67,7 @@ namespace OpenSim
67 { 67 {
68 } 68 }
69 69
70 protected override void ReadConfigSettings() 70 protected override void ReadExtraConfigSettings()
71 { 71 {
72 IConfig startupConfig = m_config.Source.Configs["Startup"]; 72 IConfig startupConfig = m_config.Source.Configs["Startup"];
73 73
@@ -78,7 +78,6 @@ namespace OpenSim
78 78
79 m_timedScript = startupConfig.GetString("timer_Script", "disabled"); 79 m_timedScript = startupConfig.GetString("timer_Script", "disabled");
80 } 80 }
81 base.ReadConfigSettings();
82 } 81 }
83 82
84 /// <summary> 83 /// <summary>
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 61e6f09..93cc0a7 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -76,7 +76,7 @@ namespace OpenSim
76 /// </summary> 76 /// </summary>
77 protected const string DEFAULT_INV_BACKUP_FILENAME = "opensim_inv.tar.gz"; 77 protected const string DEFAULT_INV_BACKUP_FILENAME = "opensim_inv.tar.gz";
78 78
79 protected ConfigSettings m_configSettings = new ConfigSettings(); 79 protected ConfigSettings m_configSettings;
80 80
81 public ConfigSettings ConfigurationSettings 81 public ConfigSettings ConfigurationSettings
82 { 82 {
@@ -84,14 +84,15 @@ namespace OpenSim
84 set { m_configSettings = value; } 84 set { m_configSettings = value; }
85 } 85 }
86 86
87 protected ConfigurationLoader m_configLoader;
88
87 protected GridInfoService m_gridInfoService; 89 protected GridInfoService m_gridInfoService;
88 90
89 protected List<IClientNetworkServer> m_clientServers = new List<IClientNetworkServer>(); 91 protected List<IClientNetworkServer> m_clientServers = new List<IClientNetworkServer>();
90 protected List<RegionInfo> m_regionData = new List<RegionInfo>(); 92 protected List<RegionInfo> m_regionData = new List<RegionInfo>();
91 93
92 public ConsoleCommand CreateAccount = null; 94 public ConsoleCommand CreateAccount = null;
93 protected bool m_dumpAssetsToFile; 95
94
95 protected List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>(); 96 protected List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>();
96 97
97 /// <value> 98 /// <value>
@@ -138,178 +139,14 @@ namespace OpenSim
138 /// <param name="configSource"></param> 139 /// <param name="configSource"></param>
139 public OpenSimBase(IConfigSource configSource) : base() 140 public OpenSimBase(IConfigSource configSource) : base()
140 { 141 {
141 LoadConfigSettings(configSource); 142 m_configLoader = new ConfigurationLoader();
143 m_config = m_configLoader.LoadConfigSettings(configSource, out m_configSettings, out m_networkServersInfo);
144 ReadExtraConfigSettings();
142 } 145 }
143 146
144 protected void LoadConfigSettings(IConfigSource configSource) 147 protected virtual void ReadExtraConfigSettings()
145 { 148 {
146 bool iniFileExists = false;
147
148 IConfig startupConfig = configSource.Configs["Startup"];
149
150 string iniFileName = startupConfig.GetString("inifile", "OpenSim.ini");
151 Application.iniFilePath = Path.Combine(Util.configDir(), iniFileName);
152
153 string masterFileName = startupConfig.GetString("inimaster", "");
154 string masterfilePath = Path.Combine(Util.configDir(), masterFileName);
155
156 m_config = new OpenSimConfigSource();
157 m_config.Source = new IniConfigSource();
158 m_config.Source.Merge(DefaultConfig());
159
160 //check for .INI file (either default or name passed in command line)
161 if (File.Exists(masterfilePath))
162 {
163 m_config.Source.Merge(new IniConfigSource(masterfilePath));
164 }
165
166 if (File.Exists(Application.iniFilePath))
167 {
168 iniFileExists = true;
169
170 // From reading Nini's code, it seems that later merged keys replace earlier ones.
171 m_config.Source.Merge(new IniConfigSource(Application.iniFilePath));
172 }
173 else
174 {
175 // check for a xml config file
176 Application.iniFilePath = Path.Combine(Util.configDir(), "OpenSim.xml");
177
178 if (File.Exists(Application.iniFilePath))
179 {
180 iniFileExists = true;
181
182 m_config.Source = new XmlConfigSource();
183 m_config.Source.Merge(new XmlConfigSource(Application.iniFilePath));
184 }
185 }
186
187 m_config.Source.Merge(configSource);
188
189 if (!iniFileExists)
190 m_config.Save("OpenSim.ini");
191
192 ReadConfigSettings();
193 }
194
195 /// <summary>
196 /// Setup a default config values in case they aren't present in the ini file
197 /// </summary>
198 /// <returns></returns>
199 public static IConfigSource DefaultConfig()
200 {
201 IConfigSource defaultConfig = new IniConfigSource();
202
203 {
204 IConfig config = defaultConfig.Configs["Startup"];
205
206 if (null == config)
207 config = defaultConfig.AddConfig("Startup");
208
209 config.Set("gridmode", false);
210 config.Set("physics", "basicphysics");
211 config.Set("meshing", "ZeroMesher");
212 config.Set("physical_prim", true);
213 config.Set("see_into_this_sim_from_neighbor", true);
214 config.Set("serverside_object_permissions", false);
215 config.Set("storage_plugin", "OpenSim.Data.SQLite.dll");
216 config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3");
217 config.Set("storage_prim_inventories", true);
218 config.Set("startup_console_commands_file", String.Empty);
219 config.Set("shutdown_console_commands_file", String.Empty);
220 config.Set("DefaultScriptEngine", "ScriptEngine.DotNetEngine");
221 config.Set("asset_database", "sqlite");
222 config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
223 }
224
225 {
226 IConfig config = defaultConfig.Configs["StandAlone"];
227
228 if (null == config)
229 config = defaultConfig.AddConfig("StandAlone");
230
231 config.Set("accounts_authenticate", false);
232 config.Set("welcome_message", "Welcome to OpenSimulator");
233 config.Set("inventory_plugin", "OpenSim.Data.SQLite.dll");
234 config.Set("inventory_source", "");
235 config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll");
236 config.Set("user_source", "");
237 config.Set("asset_plugin", "OpenSim.Data.SQLite.dll");
238 config.Set("asset_source", "");
239 config.Set("dump_assets_to_file", false);
240 }
241
242 {
243 IConfig config = defaultConfig.Configs["Network"];
244
245 if (null == config)
246 config = defaultConfig.AddConfig("Network");
247
248 config.Set("default_location_x", 1000);
249 config.Set("default_location_y", 1000);
250 config.Set("http_listener_port", NetworkServersInfo.DefaultHttpListenerPort);
251 config.Set("remoting_listener_port", NetworkServersInfo.RemotingListenerPort);
252 config.Set("grid_server_url", "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString());
253 config.Set("grid_send_key", "null");
254 config.Set("grid_recv_key", "null");
255 config.Set("user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString());
256 config.Set("user_send_key", "null");
257 config.Set("user_recv_key", "null");
258 config.Set("asset_server_url", "http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString());
259 config.Set("inventory_server_url", "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort.ToString());
260 config.Set("secure_inventory_server", "true");
261 }
262
263 return defaultConfig;
264 }
265
266 protected virtual void ReadConfigSettings()
267 {
268 m_networkServersInfo = new NetworkServersInfo();
269
270 IConfig startupConfig = m_config.Source.Configs["Startup"];
271
272 if (startupConfig != null)
273 {
274 m_configSettings.Standalone = !startupConfig.GetBoolean("gridmode");
275 m_configSettings.PhysicsEngine = startupConfig.GetString("physics");
276 m_configSettings.MeshEngineName = startupConfig.GetString("meshing");
277
278 m_configSettings.PhysicalPrim = startupConfig.GetBoolean("physical_prim");
279
280 m_configSettings.See_into_region_from_neighbor = startupConfig.GetBoolean("see_into_this_sim_from_neighbor");
281
282 m_configSettings.StorageDll = startupConfig.GetString("storage_plugin");
283 if (m_configSettings.StorageDll == "OpenSim.DataStore.MonoSqlite.dll")
284 {
285 m_configSettings.StorageDll = "OpenSim.Data.SQLite.dll";
286 Console.WriteLine("WARNING: OpenSim.DataStore.MonoSqlite.dll is deprecated. Set storage_plugin to OpenSim.Data.SQLite.dll.");
287 Thread.Sleep(3000);
288 }
289
290 m_configSettings.StorageConnectionString = startupConfig.GetString("storage_connection_string");
291 m_configSettings.EstateConnectionString = startupConfig.GetString("estate_connection_string", m_configSettings.StorageConnectionString);
292 m_configSettings.AssetStorage = startupConfig.GetString("asset_database");
293 m_configSettings.ClientstackDll = startupConfig.GetString("clientstack_plugin");
294 }
295
296 IConfig standaloneConfig = m_config.Source.Configs["StandAlone"];
297 if (standaloneConfig != null)
298 {
299 m_configSettings.StandaloneAuthenticate = standaloneConfig.GetBoolean("accounts_authenticate");
300 m_configSettings.StandaloneWelcomeMessage = standaloneConfig.GetString("welcome_message");
301
302 m_configSettings.StandaloneInventoryPlugin = standaloneConfig.GetString("inventory_plugin");
303 m_configSettings.StandaloneInventorySource = standaloneConfig.GetString("inventory_source");
304 m_configSettings.StandaloneUserPlugin = standaloneConfig.GetString("userDatabase_plugin");
305 m_configSettings.StandaloneUserSource = standaloneConfig.GetString("user_source");
306 m_configSettings.StandaloneAssetPlugin = standaloneConfig.GetString("asset_plugin");
307 m_configSettings.StandaloneAssetSource = standaloneConfig.GetString("asset_source");
308
309 m_dumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file");
310 }
311 149
312 m_networkServersInfo.loadFromConfiguration(m_config.Source);
313 } 150 }
314 151
315 protected void LoadPlugins() 152 protected void LoadPlugins()
@@ -384,7 +221,7 @@ namespace OpenSim
384 = new CommunicationsLocal( 221 = new CommunicationsLocal(
385 m_networkServersInfo, m_httpServer, m_assetCache, userService, userService, 222 m_networkServersInfo, m_httpServer, m_assetCache, userService, userService,
386 inventoryService, backendService, backendService, userService, 223 inventoryService, backendService, backendService, userService,
387 libraryRootFolder, m_dumpAssetsToFile); 224 libraryRootFolder, m_configSettings.DumpAssetsToFile);
388 225
389 // set up XMLRPC handler for client's initial login request message 226 // set up XMLRPC handler for client's initial login request message
390 m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod); 227 m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);
@@ -613,7 +450,7 @@ namespace OpenSim
613 return 450 return
614 new Scene(regionInfo, circuitManager, m_commsManager, sceneGridService, m_assetCache, 451 new Scene(regionInfo, circuitManager, m_commsManager, sceneGridService, m_assetCache,
615 storageManager, m_httpServer, 452 storageManager, m_httpServer,
616 m_moduleLoader, m_dumpAssetsToFile, m_configSettings.PhysicalPrim, m_configSettings.See_into_region_from_neighbor, m_config.Source, 453 m_moduleLoader, m_configSettings.DumpAssetsToFile, m_configSettings.PhysicalPrim, m_configSettings.See_into_region_from_neighbor, m_config.Source,
617 m_version); 454 m_version);
618 } 455 }
619 456
diff --git a/OpenSim/Tools/Export/OpenSimExport.cs b/OpenSim/Tools/Export/OpenSimExport.cs
index 5c0ff52..570a855 100644
--- a/OpenSim/Tools/Export/OpenSimExport.cs
+++ b/OpenSim/Tools/Export/OpenSimExport.cs
@@ -102,7 +102,7 @@ namespace OpenSimExport
102 { 102 {
103 // no default config files, so set default values, and save it 103 // no default config files, so set default values, and save it
104 Console.WriteLine("We didn't find a config!"); 104 Console.WriteLine("We didn't find a config!");
105 config.Merge(OpenSimBase.DefaultConfig()); 105 config.Merge(ConfigurationLoader.DefaultConfig());
106 config.Merge(configSource); 106 config.Merge(configSource);
107 } 107 }
108 108