aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/OpenSim.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-11-22 05:48:41 +0000
committerJustin Clark-Casey (justincc)2012-11-22 05:48:41 +0000
commit9fcf3f1a3f3457debf0f59ba7659492b44172b99 (patch)
tree472df16756b48e774c83ab9402a3a3c95b3d4601 /OpenSim/Region/Application/OpenSim.cs
parentFactor out common pid file creation and removal code. (diff)
downloadopensim-SC_OLD-9fcf3f1a3f3457debf0f59ba7659492b44172b99.zip
opensim-SC_OLD-9fcf3f1a3f3457debf0f59ba7659492b44172b99.tar.gz
opensim-SC_OLD-9fcf3f1a3f3457debf0f59ba7659492b44172b99.tar.bz2
opensim-SC_OLD-9fcf3f1a3f3457debf0f59ba7659492b44172b99.tar.xz
Make "config show/set/get/save" console commands available on all servers
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Application/OpenSim.cs134
1 files changed, 6 insertions, 128 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index e5aecbc..e654cf7 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -82,8 +82,8 @@ namespace OpenSim
82 { 82 {
83 base.ReadExtraConfigSettings(); 83 base.ReadExtraConfigSettings();
84 84
85 IConfig startupConfig = m_config.Source.Configs["Startup"]; 85 IConfig startupConfig = Config.Configs["Startup"];
86 IConfig networkConfig = m_config.Source.Configs["Network"]; 86 IConfig networkConfig = Config.Configs["Network"];
87 87
88 int stpMaxThreads = 15; 88 int stpMaxThreads = 15;
89 89
@@ -148,7 +148,7 @@ namespace OpenSim
148 break; 148 break;
149 case "rest": 149 case "rest":
150 m_console = new RemoteConsole("Region"); 150 m_console = new RemoteConsole("Region");
151 ((RemoteConsole)m_console).ReadConfig(m_config.Source); 151 ((RemoteConsole)m_console).ReadConfig(Config);
152 break; 152 break;
153 default: 153 default:
154 m_console = new LocalConsole("Region"); 154 m_console = new LocalConsole("Region");
@@ -158,7 +158,7 @@ namespace OpenSim
158 158
159 MainConsole.Instance = m_console; 159 MainConsole.Instance = m_console;
160 160
161 RegisterCommonAppenders(m_config.Source.Configs["Startup"]); 161 RegisterCommonAppenders(Config.Configs["Startup"]);
162 RegisterConsoleCommands(); 162 RegisterConsoleCommands();
163 163
164 base.StartupSpecific(); 164 base.StartupSpecific();
@@ -357,26 +357,6 @@ namespace OpenSim
357 "restart", 357 "restart",
358 "Restart all sims in this instance", RunCommand); 358 "Restart all sims in this instance", RunCommand);
359 359
360 m_console.Commands.AddCommand("General", false, "config set",
361 "config set <section> <key> <value>",
362 "Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig);
363
364 m_console.Commands.AddCommand("General", false, "config get",
365 "config get [<section>] [<key>]",
366 "Synonym for config show",
367 HandleConfig);
368
369 m_console.Commands.AddCommand("General", false, "config show",
370 "config show [<section>] [<key>]",
371 "Show config information",
372 "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine
373 + "If a section is given but not a field, then all fields in that section are printed.",
374 HandleConfig);
375
376 m_console.Commands.AddCommand("General", false, "config save",
377 "config save <path>",
378 "Save current configuration to a file at the given path", HandleConfig);
379
380 m_console.Commands.AddCommand("General", false, "command-script", 360 m_console.Commands.AddCommand("General", false, "command-script",
381 "command-script <script>", 361 "command-script <script>",
382 "Run a command script from file", RunCommand); 362 "Run a command script from file", RunCommand);
@@ -619,111 +599,9 @@ namespace OpenSim
619 bool changed = PopulateRegionEstateInfo(regInfo); 599 bool changed = PopulateRegionEstateInfo(regInfo);
620 IScene scene; 600 IScene scene;
621 CreateRegion(regInfo, true, out scene); 601 CreateRegion(regInfo, true, out scene);
622 if (changed)
623 regInfo.EstateSettings.Save();
624 }
625
626 /// <summary>
627 /// Change and load configuration file data.
628 /// </summary>
629 /// <param name="module"></param>
630 /// <param name="cmd"></param>
631 private void HandleConfig(string module, string[] cmd)
632 {
633 List<string> args = new List<string>(cmd);
634 args.RemoveAt(0);
635 string[] cmdparams = args.ToArray();
636 602
637 if (cmdparams.Length > 0) 603 if (changed)
638 { 604 regInfo.EstateSettings.Save();
639 string firstParam = cmdparams[0].ToLower();
640
641 switch (firstParam)
642 {
643 case "set":
644 if (cmdparams.Length < 4)
645 {
646 Notice("Syntax: config set <section> <key> <value>");
647 Notice("Example: config set ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
648 }
649 else
650 {
651 IConfig c;
652 IConfigSource source = new IniConfigSource();
653 c = source.AddConfig(cmdparams[1]);
654 if (c != null)
655 {
656 string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
657 c.Set(cmdparams[2], _value);
658 m_config.Source.Merge(source);
659
660 Notice("In section [{0}], set {1} = {2}", c.Name, cmdparams[2], _value);
661 }
662 }
663 break;
664
665 case "get":
666 case "show":
667 if (cmdparams.Length == 1)
668 {
669 foreach (IConfig config in m_config.Source.Configs)
670 {
671 Notice("[{0}]", config.Name);
672 string[] keys = config.GetKeys();
673 foreach (string key in keys)
674 Notice(" {0} = {1}", key, config.GetString(key));
675 }
676 }
677 else if (cmdparams.Length == 2 || cmdparams.Length == 3)
678 {
679 IConfig config = m_config.Source.Configs[cmdparams[1]];
680 if (config == null)
681 {
682 Notice("Section \"{0}\" does not exist.",cmdparams[1]);
683 break;
684 }
685 else
686 {
687 if (cmdparams.Length == 2)
688 {
689 Notice("[{0}]", config.Name);
690 foreach (string key in config.GetKeys())
691 Notice(" {0} = {1}", key, config.GetString(key));
692 }
693 else
694 {
695 Notice(
696 "config get {0} {1} : {2}",
697 cmdparams[1], cmdparams[2], config.GetString(cmdparams[2]));
698 }
699 }
700 }
701 else
702 {
703 Notice("Syntax: config {0} [<section>] [<key>]", firstParam);
704 Notice("Example: config {0} ScriptEngine.DotNetEngine NumberOfScriptThreads", firstParam);
705 }
706
707 break;
708
709 case "save":
710 if (cmdparams.Length < 2)
711 {
712 Notice("Syntax: config save <path>");
713 return;
714 }
715
716 if (Application.iniFilePath == cmdparams[1])
717 {
718 Notice("Path can not be " + Application.iniFilePath);
719 return;
720 }
721
722 Notice("Saving configuration file: " + cmdparams[1]);
723 m_config.Save(cmdparams[1]);
724 break;
725 }
726 }
727 } 605 }
728 606
729 /// <summary> 607 /// <summary>