diff options
-rw-r--r-- | Common/OpenSim.GenericConfig/Xml/XmlConfig.cs | 59 | ||||
-rw-r--r-- | OpenSim/OpenSim/OpenSimMain.cs | 202 |
2 files changed, 125 insertions, 136 deletions
diff --git a/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs b/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs index 40c252f..c526aec 100644 --- a/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs +++ b/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs | |||
@@ -49,45 +49,32 @@ namespace OpenSim.GenericConfig | |||
49 | public void LoadData() | 49 | public void LoadData() |
50 | { | 50 | { |
51 | doc = new XmlDocument(); | 51 | doc = new XmlDocument(); |
52 | try | ||
53 | { | ||
54 | if (System.IO.File.Exists(fileName)) | ||
55 | { | ||
56 | XmlTextReader reader = new XmlTextReader(fileName); | ||
57 | reader.WhitespaceHandling = WhitespaceHandling.None; | ||
58 | doc.Load(reader); | ||
59 | reader.Close(); | ||
60 | } | ||
61 | else | ||
62 | { | ||
63 | createdFile = true; | ||
64 | rootNode = doc.CreateNode(XmlNodeType.Element, "Root", ""); | ||
65 | doc.AppendChild(rootNode); | ||
66 | configNode = doc.CreateNode(XmlNodeType.Element, "Config", ""); | ||
67 | rootNode.AppendChild(configNode); | ||
68 | } | ||
69 | 52 | ||
70 | } | 53 | if (System.IO.File.Exists(fileName)) |
71 | catch (Exception e) | ||
72 | { | ||
73 | Console.WriteLine(e.Message); | ||
74 | return; | ||
75 | } | ||
76 | try | ||
77 | { | 54 | { |
78 | rootNode = doc.FirstChild; | 55 | XmlTextReader reader = new XmlTextReader(fileName); |
79 | if (rootNode.Name != "Root") | 56 | reader.WhitespaceHandling = WhitespaceHandling.None; |
80 | throw new Exception("Error: Invalid .xml File. Missing <Root>"); | 57 | doc.Load(reader); |
81 | 58 | reader.Close(); | |
82 | configNode = rootNode.FirstChild; | ||
83 | if (configNode.Name != "Config") | ||
84 | throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>"); | ||
85 | |||
86 | } | 59 | } |
87 | catch (Exception e) | 60 | else |
88 | { | 61 | { |
89 | Console.WriteLine(e.Message); | 62 | createdFile = true; |
63 | rootNode = doc.CreateNode(XmlNodeType.Element, "Root", ""); | ||
64 | doc.AppendChild(rootNode); | ||
65 | configNode = doc.CreateNode(XmlNodeType.Element, "Config", ""); | ||
66 | rootNode.AppendChild(configNode); | ||
90 | } | 67 | } |
68 | |||
69 | |||
70 | rootNode = doc.FirstChild; | ||
71 | if (rootNode.Name != "Root") | ||
72 | throw new Exception("Error: Invalid .xml File. Missing <Root>"); | ||
73 | |||
74 | configNode = rootNode.FirstChild; | ||
75 | if (configNode.Name != "Config") | ||
76 | throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>"); | ||
77 | |||
91 | if (createdFile) | 78 | if (createdFile) |
92 | { | 79 | { |
93 | this.Commit(); | 80 | this.Commit(); |
@@ -108,7 +95,7 @@ namespace OpenSim.GenericConfig | |||
108 | { | 95 | { |
109 | if (configNode.Attributes[attributeName] != null) | 96 | if (configNode.Attributes[attributeName] != null) |
110 | { | 97 | { |
111 | ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; | 98 | ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; |
112 | } | 99 | } |
113 | else | 100 | else |
114 | { | 101 | { |
@@ -131,6 +118,6 @@ namespace OpenSim.GenericConfig | |||
131 | rootNode = null; | 118 | rootNode = null; |
132 | doc = null; | 119 | doc = null; |
133 | } | 120 | } |
134 | 121 | ||
135 | } | 122 | } |
136 | } | 123 | } |
diff --git a/OpenSim/OpenSim/OpenSimMain.cs b/OpenSim/OpenSim/OpenSimMain.cs index ea7f31e..5915b81 100644 --- a/OpenSim/OpenSim/OpenSimMain.cs +++ b/OpenSim/OpenSim/OpenSimMain.cs | |||
@@ -63,6 +63,8 @@ namespace OpenSim | |||
63 | private CheckSumServer checkServer; | 63 | private CheckSumServer checkServer; |
64 | protected CommunicationsManager commsManager; | 64 | protected CommunicationsManager commsManager; |
65 | 65 | ||
66 | private bool m_silent; | ||
67 | private string m_logFilename = "region-console-" + Guid.NewGuid().ToString() + ".log"; | ||
66 | 68 | ||
67 | public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile) | 69 | public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile) |
68 | { | 70 | { |
@@ -71,8 +73,7 @@ namespace OpenSim | |||
71 | m_loginserver = startLoginServer; | 73 | m_loginserver = startLoginServer; |
72 | m_physicsEngine = physicsEngine; | 74 | m_physicsEngine = physicsEngine; |
73 | m_config = configFile; | 75 | m_config = configFile; |
74 | m_console = new ConsoleBase("region-console-" + Guid.NewGuid().ToString() + ".log", "Region", this, silent); | 76 | m_silent = silent; |
75 | OpenSim.Framework.Console.MainConsole.Instance = m_console; | ||
76 | } | 77 | } |
77 | 78 | ||
78 | /// <summary> | 79 | /// <summary> |
@@ -81,19 +82,18 @@ namespace OpenSim | |||
81 | public override void StartUp() | 82 | public override void StartUp() |
82 | { | 83 | { |
83 | this.serversData = new NetworkServersInfo(); | 84 | this.serversData = new NetworkServersInfo(); |
84 | try | 85 | |
85 | { | 86 | this.localConfig = new XmlConfig(m_config); |
86 | this.localConfig = new XmlConfig(m_config); | 87 | this.localConfig.LoadData(); |
87 | this.localConfig.LoadData(); | 88 | |
88 | } | ||
89 | catch (Exception e) | ||
90 | { | ||
91 | Console.WriteLine(e.Message); | ||
92 | } | ||
93 | if (this.configFileSetup) | 89 | if (this.configFileSetup) |
94 | { | 90 | { |
95 | this.SetupFromConfigFile(this.localConfig); | 91 | this.SetupFromConfigFile(this.localConfig); |
96 | } | 92 | } |
93 | |||
94 | m_console = new ConsoleBase(m_logFilename, "Region", this, m_silent); | ||
95 | OpenSim.Framework.Console.MainConsole.Instance = m_console; | ||
96 | |||
97 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Loading configuration"); | 97 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Loading configuration"); |
98 | this.serversData.InitConfig(this.m_sandbox, this.localConfig); | 98 | this.serversData.InitConfig(this.m_sandbox, this.localConfig); |
99 | this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change | 99 | this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change |
@@ -216,7 +216,7 @@ namespace OpenSim | |||
216 | else | 216 | else |
217 | { | 217 | { |
218 | AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); //new AuthenticateSessionsRemote(); | 218 | AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); //new AuthenticateSessionsRemote(); |
219 | this.AuthenticateSessionsHandler.Add (authen); | 219 | this.AuthenticateSessionsHandler.Add(authen); |
220 | authenBase = authen; | 220 | authenBase = authen; |
221 | } | 221 | } |
222 | Console.WriteLine("Loading region config file"); | 222 | Console.WriteLine("Loading region config file"); |
@@ -265,7 +265,7 @@ namespace OpenSim | |||
265 | { | 265 | { |
266 | 266 | ||
267 | // we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server | 267 | // we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server |
268 | 268 | ||
269 | 269 | ||
270 | httpServer.AddRestHandler("GET", "/simstatus/", | 270 | httpServer.AddRestHandler("GET", "/simstatus/", |
271 | delegate(string request, string path, string param) | 271 | delegate(string request, string path, string param) |
@@ -284,102 +284,104 @@ namespace OpenSim | |||
284 | 284 | ||
285 | private void SetupFromConfigFile(IGenericConfig configData) | 285 | private void SetupFromConfigFile(IGenericConfig configData) |
286 | { | 286 | { |
287 | try | 287 | // Log filename |
288 | string attri = ""; | ||
289 | attri = configData.GetAttribute("LogFilename"); | ||
290 | if (String.IsNullOrEmpty(attri)) | ||
288 | { | 291 | { |
289 | // SandBoxMode | 292 | } |
290 | string attri = ""; | 293 | else |
291 | attri = configData.GetAttribute("SandBox"); | 294 | { |
292 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | 295 | m_logFilename = attri; |
293 | { | 296 | } |
294 | this.m_sandbox = false; | ||
295 | configData.SetAttribute("SandBox", "false"); | ||
296 | } | ||
297 | else | ||
298 | { | ||
299 | this.m_sandbox = Convert.ToBoolean(attri); | ||
300 | } | ||
301 | 297 | ||
302 | // LoginServer | 298 | // SandBoxMode |
303 | attri = ""; | 299 | attri = ""; |
304 | attri = configData.GetAttribute("LoginServer"); | 300 | attri = configData.GetAttribute("SandBox"); |
305 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | 301 | if ((attri == "") || ((attri != "false") && (attri != "true"))) |
306 | { | 302 | { |
307 | this.m_loginserver = false; | 303 | this.m_sandbox = false; |
308 | configData.SetAttribute("LoginServer", "false"); | 304 | configData.SetAttribute("SandBox", "false"); |
309 | } | 305 | } |
310 | else | 306 | else |
311 | { | 307 | { |
312 | this.m_loginserver = Convert.ToBoolean(attri); | 308 | this.m_sandbox = Convert.ToBoolean(attri); |
313 | } | 309 | } |
314 | 310 | ||
315 | // Sandbox User accounts | 311 | // LoginServer |
316 | attri = ""; | 312 | attri = ""; |
317 | attri = configData.GetAttribute("UserAccount"); | 313 | attri = configData.GetAttribute("LoginServer"); |
318 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | 314 | if ((attri == "") || ((attri != "false") && (attri != "true"))) |
319 | { | 315 | { |
320 | this.user_accounts = false; | 316 | this.m_loginserver = false; |
321 | configData.SetAttribute("UserAccounts", "false"); | 317 | configData.SetAttribute("LoginServer", "false"); |
322 | } | 318 | } |
323 | else if (attri == "true") | 319 | else |
324 | { | 320 | { |
325 | this.user_accounts = Convert.ToBoolean(attri); | 321 | this.m_loginserver = Convert.ToBoolean(attri); |
326 | } | 322 | } |
327 | 323 | ||
328 | // Grid mode hack to use local asset server | 324 | // Sandbox User accounts |
329 | attri = ""; | 325 | attri = ""; |
330 | attri = configData.GetAttribute("LocalAssets"); | 326 | attri = configData.GetAttribute("UserAccount"); |
331 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | 327 | if ((attri == "") || ((attri != "false") && (attri != "true"))) |
332 | { | 328 | { |
333 | this.gridLocalAsset = false; | 329 | this.user_accounts = false; |
334 | configData.SetAttribute("LocalAssets", "false"); | 330 | configData.SetAttribute("UserAccounts", "false"); |
335 | } | 331 | } |
336 | else if (attri == "true") | 332 | else if (attri == "true") |
337 | { | 333 | { |
338 | this.gridLocalAsset = Convert.ToBoolean(attri); | 334 | this.user_accounts = Convert.ToBoolean(attri); |
339 | } | 335 | } |
340 | 336 | ||
337 | // Grid mode hack to use local asset server | ||
338 | attri = ""; | ||
339 | attri = configData.GetAttribute("LocalAssets"); | ||
340 | if ((attri == "") || ((attri != "false") && (attri != "true"))) | ||
341 | { | ||
342 | this.gridLocalAsset = false; | ||
343 | configData.SetAttribute("LocalAssets", "false"); | ||
344 | } | ||
345 | else if (attri == "true") | ||
346 | { | ||
347 | this.gridLocalAsset = Convert.ToBoolean(attri); | ||
348 | } | ||
341 | 349 | ||
342 | attri = ""; | ||
343 | attri = configData.GetAttribute("PhysicsEngine"); | ||
344 | switch (attri) | ||
345 | { | ||
346 | default: | ||
347 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating"); | ||
348 | Environment.Exit(1); | ||
349 | break; | ||
350 | |||
351 | case "": | ||
352 | this.m_physicsEngine = "basicphysics"; | ||
353 | configData.SetAttribute("PhysicsEngine", "basicphysics"); | ||
354 | OpenSim.Region.Scenes.Avatar.PhysicsEngineFlying = false; | ||
355 | break; | ||
356 | |||
357 | case "basicphysics": | ||
358 | this.m_physicsEngine = "basicphysics"; | ||
359 | configData.SetAttribute("PhysicsEngine", "basicphysics"); | ||
360 | OpenSim.Region.Scenes.Avatar.PhysicsEngineFlying = false; | ||
361 | break; | ||
362 | |||
363 | case "RealPhysX": | ||
364 | this.m_physicsEngine = "RealPhysX"; | ||
365 | OpenSim.Region.Scenes.Avatar.PhysicsEngineFlying = true; | ||
366 | break; | ||
367 | |||
368 | case "OpenDynamicsEngine": | ||
369 | this.m_physicsEngine = "OpenDynamicsEngine"; | ||
370 | OpenSim.Region.Scenes.Avatar.PhysicsEngineFlying = true; | ||
371 | break; | ||
372 | } | ||
373 | 350 | ||
374 | configData.Commit(); | 351 | attri = ""; |
375 | } | 352 | attri = configData.GetAttribute("PhysicsEngine"); |
376 | catch (Exception e) | 353 | switch (attri) |
377 | { | 354 | { |
378 | Console.WriteLine(e.Message); | 355 | default: |
379 | Console.WriteLine("\nSorry, a fatal error occurred while trying to initialise the configuration data"); | 356 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating"); |
380 | Console.WriteLine("Can not continue starting up"); | 357 | Environment.Exit(1); |
381 | Environment.Exit(1); | 358 | break; |
359 | |||
360 | case "": | ||
361 | this.m_physicsEngine = "basicphysics"; | ||
362 | configData.SetAttribute("PhysicsEngine", "basicphysics"); | ||
363 | OpenSim.Region.Scenes.Avatar.PhysicsEngineFlying = false; | ||
364 | break; | ||
365 | |||
366 | case "basicphysics": | ||
367 | this.m_physicsEngine = "basicphysics"; | ||
368 | configData.SetAttribute("PhysicsEngine", "basicphysics"); | ||
369 | OpenSim.Region.Scenes.Avatar.PhysicsEngineFlying = false; | ||
370 | break; | ||
371 | |||
372 | case "RealPhysX": | ||
373 | this.m_physicsEngine = "RealPhysX"; | ||
374 | OpenSim.Region.Scenes.Avatar.PhysicsEngineFlying = true; | ||
375 | break; | ||
376 | |||
377 | case "OpenDynamicsEngine": | ||
378 | this.m_physicsEngine = "OpenDynamicsEngine"; | ||
379 | OpenSim.Region.Scenes.Avatar.PhysicsEngineFlying = true; | ||
380 | break; | ||
382 | } | 381 | } |
382 | |||
383 | configData.Commit(); | ||
384 | |||
383 | } | 385 | } |
384 | 386 | ||
385 | /// <summary> | 387 | /// <summary> |