aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Base
diff options
context:
space:
mode:
authorRobert Adams2010-06-24 09:11:27 -0700
committerDiva Canto2010-06-27 13:28:27 -0700
commit6cf0b8f6fe0f8d35635e2a96953ce260a200d9c8 (patch)
tree0f7c7a35870ad589050f5057eee426ee040b7e1b /OpenSim/Server/Base
parentAddresses mantis #4789. Not really a fix, because the event is harmless anywa... (diff)
downloadopensim-SC_OLD-6cf0b8f6fe0f8d35635e2a96953ce260a200d9c8.zip
opensim-SC_OLD-6cf0b8f6fe0f8d35635e2a96953ce260a200d9c8.tar.gz
opensim-SC_OLD-6cf0b8f6fe0f8d35635e2a96953ce260a200d9c8.tar.bz2
opensim-SC_OLD-6cf0b8f6fe0f8d35635e2a96953ce260a200d9c8.tar.xz
Add command-script to the Robust console
Diffstat (limited to 'OpenSim/Server/Base')
-rw-r--r--OpenSim/Server/Base/ServicesServerBase.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs
index a5bebb8..dee31bd 100644
--- a/OpenSim/Server/Base/ServicesServerBase.cs
+++ b/OpenSim/Server/Base/ServicesServerBase.cs
@@ -230,6 +230,12 @@ namespace OpenSim.Server.Base
230 "shutdown", 230 "shutdown",
231 "Quit the application", HandleQuit); 231 "Quit the application", HandleQuit);
232 232
233 // Register a command to read other commands from a file
234 MainConsole.Instance.Commands.AddCommand("base", false, "command-script",
235 "command-script <script>",
236 "Run a command script from file", HandleScript);
237
238
233 // Allow derived classes to perform initialization that 239 // Allow derived classes to perform initialization that
234 // needs to be done after the console has opened 240 // needs to be done after the console has opened
235 // 241 //
@@ -259,6 +265,41 @@ namespace OpenSim.Server.Base
259 m_log.Info("[CONSOLE] Quitting"); 265 m_log.Info("[CONSOLE] Quitting");
260 } 266 }
261 267
268 protected virtual void HandleScript(string module, string[] parms)
269 {
270 if (parms.Length != 2)
271 {
272 return;
273 }
274 RunCommandScript(parms[1]);
275 }
276
277 /// <summary>
278 /// Run an optional startup list of commands
279 /// </summary>
280 /// <param name="fileName"></param>
281 private void RunCommandScript(string fileName)
282 {
283 if (File.Exists(fileName))
284 {
285 m_log.Info("[COMMANDFILE]: Running " + fileName);
286
287 using (StreamReader readFile = File.OpenText(fileName))
288 {
289 string currentCommand;
290 while ((currentCommand = readFile.ReadLine()) != null)
291 {
292 if (currentCommand != String.Empty)
293 {
294 m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'");
295 MainConsole.Instance.RunCommand(currentCommand);
296 }
297 }
298 }
299 }
300 }
301
302
262 protected virtual void ReadConfig() 303 protected virtual void ReadConfig()
263 { 304 {
264 } 305 }