From 599a6d32eebc451f9284db8e6abf2946f236d5e9 Mon Sep 17 00:00:00 2001
From: Brian McBee
Date: Fri, 3 Aug 2007 18:01:55 +0000
Subject: Changes to prepare for future possible configuration of separate
logdir, configdir, datadir.
---
.../Configuration/XML/XmlConfiguration.cs | 6 ++++
OpenSim/Framework/Console/LogBase.cs | 1 +
OpenSim/Framework/Data.DB4o/DB4oUserData.cs | 4 ++-
OpenSim/Framework/General/Types/EstateSettings.cs | 6 ++--
OpenSim/Framework/General/Util.cs | 34 ++++++++++++++++++++++
OpenSim/Grid/AssetServer/Main.cs | 12 ++++++--
OpenSim/Grid/GridServer/Main.cs | 10 +++++--
OpenSim/Grid/UserServer/Main.cs | 9 ++++--
OpenSim/Region/Application/OpenSimMain.cs | 26 +++++++++++++----
.../GridInterfaces/Local/LocalAssetServer.cs | 4 +--
prebuild.xml | 1 +
11 files changed, 95 insertions(+), 18 deletions(-)
diff --git a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs
index 72faed6..ffb24ff 100644
--- a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs
+++ b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs
@@ -31,6 +31,7 @@ using System.Xml;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Configuration.Interfaces;
+using OpenSim.Framework.Utilities;
namespace OpenSim.Framework.Configuration
{
@@ -119,6 +120,11 @@ namespace OpenSim.Framework.Configuration
public void Commit()
{
+ if (!Directory.Exists(Util.configDir()))
+ {
+ Directory.CreateDirectory(Util.configDir());
+ }
+
doc.Save(fileName);
}
diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs
index a088af8..a090377 100644
--- a/OpenSim/Framework/Console/LogBase.cs
+++ b/OpenSim/Framework/Console/LogBase.cs
@@ -63,6 +63,7 @@ namespace OpenSim.Framework.Console
}
System.Console.WriteLine("Logs will be saved to current directory in " + LogFile);
+
Log = File.AppendText(LogFile);
Log.WriteLine("========================================================================");
Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString());
diff --git a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs
index 1a3bcb9..ef4211e 100644
--- a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs
+++ b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs
@@ -26,7 +26,9 @@
*
*/
using System;
+using System.IO;
using libsecondlife;
+using OpenSim.Framework.Utilities;
namespace OpenSim.Framework.Data.DB4o
{
@@ -45,7 +47,7 @@ namespace OpenSim.Framework.Data.DB4o
///
public void Initialise()
{
- manager = new DB4oUserManager("userprofiles.yap");
+ manager = new DB4oUserManager(Path.Combine(Util.dataDir(),"userprofiles.yap"));
}
///
diff --git a/OpenSim/Framework/General/Types/EstateSettings.cs b/OpenSim/Framework/General/Types/EstateSettings.cs
index 11594fd..ae61752 100644
--- a/OpenSim/Framework/General/Types/EstateSettings.cs
+++ b/OpenSim/Framework/General/Types/EstateSettings.cs
@@ -25,9 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
-
+using System.IO;
using libsecondlife;
using OpenSim.Framework.Configuration;
+using OpenSim.Framework.Utilities;
+
namespace OpenSim.Framework.Types
{
public class EstateSettings
@@ -554,7 +556,7 @@ namespace OpenSim.Framework.Types
private ConfigurationMember configMember;
public EstateSettings()
{
- configMember = new ConfigurationMember("estate_settings.xml", "ESTATE SETTINGS", this.loadConfigurationOptions, this.handleIncomingConfiguration);
+ configMember = new ConfigurationMember(Path.Combine(Util.configDir(),"estate_settings.xml"), "ESTATE SETTINGS", this.loadConfigurationOptions, this.handleIncomingConfiguration);
configMember.performConfigurationRetrieve();
}
diff --git a/OpenSim/Framework/General/Util.cs b/OpenSim/Framework/General/Util.cs
index b9f8e9c..f3e2a01 100644
--- a/OpenSim/Framework/General/Util.cs
+++ b/OpenSim/Framework/General/Util.cs
@@ -26,6 +26,7 @@
*
*/
using System;
+using System.IO;
using System.Security.Cryptography;
using System.Net;
using System.Text;
@@ -275,6 +276,39 @@ namespace OpenSim.Framework.Utilities
return null;
}
+ //
+ // directory locations
+ //
+ public static string homeDir()
+ {
+ string temp;
+// string personal=(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
+// temp = Path.Combine(personal,".OpenSim");
+ temp=".";
+ return temp;
+ }
+
+ public static string configDir()
+ {
+ string temp;
+ temp = ".";
+ return temp;
+ }
+
+ public static string dataDir()
+ {
+ string temp;
+ temp = ".";
+ return temp;
+ }
+
+ public static string logDir()
+ {
+ string temp;
+ temp = ".";
+ return temp;
+ }
+
public Util()
{
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs
index 92d5490..b581a1e 100644
--- a/OpenSim/Grid/AssetServer/Main.cs
+++ b/OpenSim/Grid/AssetServer/Main.cs
@@ -34,6 +34,7 @@ using libsecondlife;
using OpenSim.Framework.Console;
using OpenSim.Framework.Types;
using OpenSim.Framework.Servers;
+using OpenSim.Framework.Utilities;
namespace OpenSim.Grid.AssetServer
{
@@ -71,7 +72,11 @@ namespace OpenSim.Grid.AssetServer
private OpenAsset_Main()
{
- m_console = new LogBase("opengrid-AssetServer-console.log", "OpenAsset", this, false);
+ if(!Directory.Exists(Util.logDir()))
+ {
+ Directory.CreateDirectory(Util.logDir());
+ }
+ m_console = new LogBase((Path.Combine(Util.logDir(),"opengrid-AssetServer-console.log")), "OpenAsset", this, false);
MainLog.Instance = m_console;
}
@@ -154,10 +159,11 @@ namespace OpenSim.Grid.AssetServer
public void setupDB()
{
- bool yapfile = File.Exists("gridassets.yap");
+ string yappath=(Path.Combine(Util.dataDir(),"gridassets.yap"));
+ bool yapfile = File.Exists(yappath);
try
{
- db = Db4oFactory.OpenFile("gridassets.yap");
+ db = Db4oFactory.OpenFile(yappath);
MainLog.Instance.Verbose("storage", "Main.cs:setupDB() - creation");
}
catch (Exception e)
diff --git a/OpenSim/Grid/GridServer/Main.cs b/OpenSim/Grid/GridServer/Main.cs
index f9accab..ecf3b9d 100644
--- a/OpenSim/Grid/GridServer/Main.cs
+++ b/OpenSim/Grid/GridServer/Main.cs
@@ -27,6 +27,7 @@
*/
using System;
+using System.IO;
using System.Reflection;
using System.Threading;
using System.Timers;
@@ -34,6 +35,7 @@ using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Configuration;
+using OpenSim.Framework.Utilities;
using Timer=System.Timers.Timer;
@@ -84,7 +86,11 @@ namespace OpenSim.Grid.GridServer
private OpenGrid_Main()
{
- m_console = new LogBase("opengrid-gridserver-console.log", "OpenGrid", this, false);
+ if (!Directory.Exists(Util.logDir()))
+ {
+ Directory.CreateDirectory(Util.logDir());
+ }
+ m_console = new LogBase((Path.Combine(Util.logDir(),"opengrid-gridserver-console.log")), "OpenGrid", this, false);
MainLog.Instance = m_console;
@@ -104,7 +110,7 @@ namespace OpenSim.Grid.GridServer
public void Startup()
{
- this.Cfg = new GridConfig("GRID SERVER","GridServer_Config.xml"); //Yeah srsly, that's it.
+ this.Cfg = new GridConfig("GRID SERVER",(Path.Combine(Util.configDir(),"GridServer_Config.xml"))); //Yeah srsly, that's it.
if (setuponly) Environment.Exit(0);
m_console.Verbose( "Main.cs:Startup() - Connecting to Storage Server");
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 32d8da9..04f45b0 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Reflection;
using libsecondlife;
using OpenSim.Framework.Console;
@@ -64,7 +65,11 @@ namespace OpenSim.Grid.UserServer
private OpenUser_Main()
{
- m_console = new LogBase("opengrid-userserver-console.log", "OpenUser", this , false);
+ if (!Directory.Exists(Util.logDir()))
+ {
+ Directory.CreateDirectory(Util.logDir());
+ }
+ m_console = new LogBase((Path.Combine(Util.logDir(),"opengrid-userserver-console.log")), "OpenUser", this , false);
MainLog.Instance = m_console;
}
@@ -80,7 +85,7 @@ namespace OpenSim.Grid.UserServer
public void Startup()
{
- this.Cfg = new UserConfig("USER SERVER", "UserServer_Config.xml");
+ this.Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
MainLog.Instance.Verbose("Main.cs:Startup() - Establishing data connection");
m_userManager = new UserManager();
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index f830978..fbd6790 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -68,7 +68,7 @@ namespace OpenSim
protected List m_localScenes = new List();
private bool m_silent;
- private string m_logFilename = "region-console-" + Guid.NewGuid().ToString() + ".log";
+ private string m_logFilename = ("region-console-" + Guid.NewGuid().ToString() + ".log");
public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngineName, bool useConfigFile, bool silent, string configFileName)
:base( )
@@ -87,7 +87,11 @@ namespace OpenSim
///
public override void StartUp()
{
- m_log = new LogBase(m_logFilename, "Region", this, m_silent);
+ if (!Directory.Exists(Util.logDir()))
+ {
+ Directory.CreateDirectory(Util.logDir());
+ }
+ m_log = new LogBase(Path.Combine(Util.logDir(),m_logFilename), "Region", this, m_silent);
MainLog.Instance = m_log;
base.StartUp();
@@ -106,12 +110,17 @@ namespace OpenSim
m_commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer , m_assetCache);
}
- string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions");
+
+ string path = Path.Combine(Util.configDir(), "Regions");
+ if (!Directory.Exists(path))
+ {
+ Directory.CreateDirectory(path);
+ }
string[] configFiles = Directory.GetFiles(path, "*.xml");
if (configFiles.Length == 0)
{
- string path2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions");
+ string path2 = Path.Combine(Util.configDir(), "Regions");
string path3 = Path.Combine(path2, "default.xml");
RegionInfo regionInfo = new RegionInfo("DEFAULT REGION CONFIG", path3);
@@ -154,14 +163,19 @@ namespace OpenSim
protected override void Initialize()
{
- m_networkServersInfo = new NetworkServersInfo("NETWORK SERVERS INFO", "network_servers_information.xml");
+ m_networkServersInfo = new NetworkServersInfo("NETWORK SERVERS INFO", Path.Combine(Util.configDir(),"network_servers_information.xml"));
m_httpServerPort = m_networkServersInfo.HttpListenerPort;
m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey);
}
protected override LogBase CreateLog()
{
- return new LogBase(m_logFilename, "Region", this, m_silent);
+ if (!Directory.Exists(Util.logDir()))
+ {
+ Directory.CreateDirectory(Util.logDir());
+ }
+
+ return new LogBase((Path.Combine(Util.logDir(),m_logFilename)), "Region", this, m_silent);
}
# region Setup methods
diff --git a/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs b/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs
index 38bf9bf..ea4824b 100644
--- a/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs
+++ b/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs
@@ -62,10 +62,10 @@ namespace OpenSim.Region.GridInterfaces.Local
{
bool yapfile;
this._assetRequests = new BlockingQueue();
- yapfile = File.Exists("regionassets.yap");
+ yapfile = File.Exists(Path.Combine(Util.dataDir(),"regionassets.yap"));
MainLog.Instance.Verbose("Local Asset Server class created");
- db = Db4oFactory.OpenFile("regionassets.yap");
+ db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(),"regionassets.yap"));
MainLog.Instance.Verbose("Db4 Asset database creation");
if (!yapfile)
diff --git a/prebuild.xml b/prebuild.xml
index f19248c..ab00e20 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -367,6 +367,7 @@
+
--
cgit v1.1