From ae20503dae765b850d6acf6e30220b9688f30cac Mon Sep 17 00:00:00 2001 From: mingchen Date: Wed, 15 Aug 2007 19:08:27 +0000 Subject: *Added the ability to run commands after all regions have started up *By default, it is set to startup_commands.txt. Simply add a list of commands separated by a new line to be run or change the file by changing the path of a startup commands file in OpenSim.ini --- OpenSim/Framework/Console/LogBase.cs | 10 ++++++++-- OpenSim/Region/Application/OpenSimMain.cs | 31 +++++++++++++++++++++++++++++++ bin/OpenSim.ini | 1 + bin/startup_commands.txt | 0 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 bin/startup_commands.txt diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs index 2b831fe..5f16303 100644 --- a/OpenSim/Framework/Console/LogBase.cs +++ b/OpenSim/Framework/Console/LogBase.cs @@ -409,9 +409,15 @@ namespace OpenSim.Framework.Console public void MainLogPrompt() { - string[] tempstrarray; + string tempstr = this.CmdPrompt(this.componentname + "# "); - tempstrarray = tempstr.Split(' '); + MainLogRunCommand(tempstr); + } + + public void MainLogRunCommand(string command) + { + string[] tempstrarray; + tempstrarray = command.Split(' '); string cmd = tempstrarray[0]; Array.Reverse(tempstrarray); Array.Resize(ref tempstrarray, tempstrarray.Length - 1); diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 9f95e01..2ca3f46 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -64,6 +64,8 @@ namespace OpenSim protected string m_storageDLL = "OpenSim.DataStore.NullStorage.dll"; + protected string m_startupCommandsFile = ""; + protected List m_udpServers = new List(); protected List m_regionData = new List(); protected List m_localScenes = new List(); @@ -105,6 +107,8 @@ namespace OpenSim m_storageDLL = configSource.Configs["Startup"].GetString("storage_plugin", "OpenSim.DataStore.NullStorage.dll"); + m_startupCommandsFile = configSource.Configs["Startup"].GetString("startup_console_commands_file", ""); + standaloneAuthenticate = configSource.Configs["Startup"].GetBoolean("standalone_authenticate", false); welcomeMessage = configSource.Configs["Startup"].GetString("standalone_welcome", "Welcome to OpenSim"); } @@ -184,6 +188,33 @@ namespace OpenSim { this.m_udpServers[i].ServerListener(); } + + //Run Startup Commands + if (m_startupCommandsFile != "") + { + MainLog.Instance.Verbose("Running startup command script (" + 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 + { + MainLog.Instance.Verbose("No startup command script specified. Moving on..."); + } } private static void CreateDefaultRegionInfoXml(string fileName) diff --git a/bin/OpenSim.ini b/bin/OpenSim.ini index c2cbdec..4e9b79a 100644 --- a/bin/OpenSim.ini +++ b/bin/OpenSim.ini @@ -2,5 +2,6 @@ gridmode = false physics = basicphysics storage_plugin = "OpenSim.DataStore.NullStorage.dll" +startup_console_commands_file = "startup_commands.txt" standalone_authenticate = false standalone_welcome = "Welcome to OpenSim" \ No newline at end of file diff --git a/bin/startup_commands.txt b/bin/startup_commands.txt new file mode 100644 index 0000000..e69de29 -- cgit v1.1