diff options
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r-- | OpenSim/Framework/Servers/ServerBase.cs | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 27cfc9b..c182a3a 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs | |||
@@ -201,6 +201,11 @@ namespace OpenSim.Framework.Servers | |||
201 | "General", false, "config save", | 201 | "General", false, "config save", |
202 | "config save <path>", | 202 | "config save <path>", |
203 | "Save current configuration to a file at the given path", HandleConfig); | 203 | "Save current configuration to a file at the given path", HandleConfig); |
204 | |||
205 | m_console.Commands.AddCommand( | ||
206 | "General", false, "command-script", | ||
207 | "command-script <script>", | ||
208 | "Run a command script from file", HandleScript); | ||
204 | } | 209 | } |
205 | 210 | ||
206 | public virtual void HandleShow(string module, string[] cmd) | 211 | public virtual void HandleShow(string module, string[] cmd) |
@@ -363,7 +368,50 @@ namespace OpenSim.Framework.Servers | |||
363 | 368 | ||
364 | private void ShowLogLevel() | 369 | private void ShowLogLevel() |
365 | { | 370 | { |
366 | Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); | 371 | Notice("Console log level is {0}", m_consoleAppender.Threshold); |
372 | } | ||
373 | |||
374 | protected virtual void HandleScript(string module, string[] parms) | ||
375 | { | ||
376 | if (parms.Length != 2) | ||
377 | { | ||
378 | Notice("Usage: command-script <path-to-script"); | ||
379 | return; | ||
380 | } | ||
381 | |||
382 | RunCommandScript(parms[1]); | ||
383 | } | ||
384 | |||
385 | /// <summary> | ||
386 | /// Run an optional startup list of commands | ||
387 | /// </summary> | ||
388 | /// <param name="fileName"></param> | ||
389 | protected void RunCommandScript(string fileName) | ||
390 | { | ||
391 | if (m_console == null) | ||
392 | return; | ||
393 | |||
394 | if (File.Exists(fileName)) | ||
395 | { | ||
396 | m_log.Info("[SERVER BASE]: Running " + fileName); | ||
397 | |||
398 | using (StreamReader readFile = File.OpenText(fileName)) | ||
399 | { | ||
400 | string currentCommand; | ||
401 | while ((currentCommand = readFile.ReadLine()) != null) | ||
402 | { | ||
403 | currentCommand = currentCommand.Trim(); | ||
404 | if (!(currentCommand == "" | ||
405 | || currentCommand.StartsWith(";") | ||
406 | || currentCommand.StartsWith("//") | ||
407 | || currentCommand.StartsWith("#"))) | ||
408 | { | ||
409 | m_log.Info("[SERVER BASE]: Running '" + currentCommand + "'"); | ||
410 | m_console.RunCommand(currentCommand); | ||
411 | } | ||
412 | } | ||
413 | } | ||
414 | } | ||
367 | } | 415 | } |
368 | 416 | ||
369 | /// <summary> | 417 | /// <summary> |
@@ -509,7 +557,7 @@ namespace OpenSim.Framework.Servers | |||
509 | /// </summary> | 557 | /// </summary> |
510 | /// <param name="format"></param> | 558 | /// <param name="format"></param> |
511 | /// <param name="components"></param> | 559 | /// <param name="components"></param> |
512 | protected void Notice(string format, params string[] components) | 560 | protected void Notice(string format, params object[] components) |
513 | { | 561 | { |
514 | if (m_console != null) | 562 | if (m_console != null) |
515 | m_console.OutputFormat(format, components); | 563 | m_console.OutputFormat(format, components); |