Small bit of refactoring to the startup command script code (moved it into a separate method), so that I could add a new CLI command of "command-script <fileName>", so that as well as the startup command script still being processed on startup. A user can create other command scripts and use the single command ("command-script <filename>") to run them at any time. Could be useful for trying out various configurations etc.

afrisby
MW 2007-08-24 16:17:57 +00:00
parent 487a54ffc0
commit 4276a352bc
2 changed files with 32 additions and 22 deletions

View File

@ -205,24 +205,7 @@ namespace OpenSim
//Run Startup Commands //Run Startup Commands
if (m_startupCommandsFile != "") if (m_startupCommandsFile != "")
{ {
MainLog.Instance.Verbose("Running startup command script (" + m_startupCommandsFile + ")"); RunCommandScript(m_startupCommandsFile);
if (File.Exists(m_startupCommandsFile))
{
StreamReader readFile = File.OpenText(m_startupCommandsFile);
string currentCommand = "";
while ((currentCommand = readFile.ReadLine()) != null)
{
if (currentCommand != "")
{
MainLog.Instance.Verbose("Running '" + currentCommand + "'");
MainLog.Instance.MainLogRunCommand(currentCommand);
}
}
}
else
{
MainLog.Instance.Error("Startup command script missing. Will not run startup commands");
}
} }
else else
{ {
@ -230,6 +213,28 @@ namespace OpenSim
} }
} }
private void RunCommandScript(string fileName)
{
MainLog.Instance.Verbose("Running command script (" + fileName + ")");
if (File.Exists(fileName))
{
StreamReader readFile = File.OpenText(fileName);
string currentCommand = "";
while ((currentCommand = readFile.ReadLine()) != null)
{
if (currentCommand != "")
{
MainLog.Instance.Verbose("Running '" + currentCommand + "'");
MainLog.Instance.MainLogRunCommand(currentCommand);
}
}
}
else
{
MainLog.Instance.Error("Command script missing. Can not run commands");
}
}
private static void CreateDefaultRegionInfoXml(string fileName) private static void CreateDefaultRegionInfoXml(string fileName)
{ {
new RegionInfo("DEFAULT REGION CONFIG", fileName); new RegionInfo("DEFAULT REGION CONFIG", fileName);
@ -403,6 +408,13 @@ namespace OpenSim
} }
break; break;
case "command-script":
if (cmdparams.Length > 0)
{
RunCommandScript(cmdparams[0]);
}
break;
case "permissions": case "permissions":
// Treats each user as a super-admin when disabled // Treats each user as a super-admin when disabled
foreach (Scene scene in m_localScenes) foreach (Scene scene in m_localScenes)

View File

@ -207,8 +207,7 @@ namespace OpenSim.Region.Environment.LandManagement
if (x > 63 || y > 63 || x < 0 || y < 0) if (x > 63 || y > 63 || x < 0 || y < 0)
{ {
return null; throw new Exception("Error: Parcel not found at point " + x + ", " + y);
//throw new Exception("Error: Parcel not found at point " + x + ", " + y);
} }
else else
{ {
@ -221,8 +220,7 @@ namespace OpenSim.Region.Environment.LandManagement
{ {
if (x > 256 || y > 256 || x < 0 || y < 0) if (x > 256 || y > 256 || x < 0 || y < 0)
{ {
return null; throw new Exception("Error: Parcel not found at point " + x + ", " + y);
//throw new Exception("Error: Parcel not found at point " + x + ", " + y);
} }
else else
{ {