29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Diagnostics;
34 using System.Reflection;
36 using System.Text.RegularExpressions;
42 using OpenSim.Framework;
43 using OpenSim.Framework.Console;
44 using OpenSim.Framework.Servers;
45 using OpenSim.Framework.Monitoring;
46 using OpenSim.Region.Framework.Interfaces;
47 using OpenSim.Region.Framework.Scenes;
48 using OpenSim.Services.Interfaces;
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
61 protected bool m_gui =
false;
62 protected string m_consoleType =
"local";
63 protected uint m_consolePort = 0;
68 private string m_consolePrompt;
73 private Regex m_consolePromptRegex =
new Regex(
@"([^\\])\\(\w)", RegexOptions.Compiled);
75 private string m_timedScript =
"disabled";
76 private int m_timeInterval = 1200;
77 private Timer m_scriptTimer;
79 public OpenSim(IConfigSource configSource) : base(configSource)
85 base.ReadExtraConfigSettings();
87 IConfig startupConfig = Config.Configs[
"Startup"];
88 IConfig networkConfig = Config.Configs[
"Network"];
90 int stpMinThreads = 2;
91 int stpMaxThreads = 15;
93 if (startupConfig != null)
95 m_startupCommandsFile = startupConfig.GetString(
"startup_console_commands_file",
"startup_commands.txt");
96 m_shutdownCommandsFile = startupConfig.GetString(
"shutdown_console_commands_file",
"shutdown_commands.txt");
98 if (startupConfig.GetString(
"console",
String.Empty) == String.Empty)
99 m_gui = startupConfig.GetBoolean(
"gui",
false);
101 m_consoleType= startupConfig.GetString(
"console", String.Empty);
103 if (networkConfig != null)
104 m_consolePort = (uint)networkConfig.GetInt(
"console_port", 0);
106 m_timedScript = startupConfig.GetString(
"timer_Script",
"disabled");
107 if (m_timedScript !=
"disabled")
109 m_timeInterval = startupConfig.GetInt(
"timer_Interval", 1200);
112 string asyncCallMethodStr = startupConfig.GetString(
"async_call_method", String.Empty);
114 if (!
String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<
FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod))
115 Util.FireAndForgetMethod = asyncCallMethod;
117 stpMinThreads = startupConfig.GetInt(
"MinPoolThreads", 2 );
118 stpMaxThreads = startupConfig.GetInt(
"MaxPoolThreads", 25);
119 m_consolePrompt = startupConfig.GetString(
"ConsolePrompt",
@"Region (\R) ");
123 Util.InitThreadPool(stpMinThreads, stpMaxThreads);
133 m_log.Info(
"====================================================================");
134 m_log.Info(
"========================= STARTING OPENSIM =========================");
135 m_log.Info(
"====================================================================");
148 switch (m_consoleType)
158 m_console =
new LocalConsole(
"Region", Config.Configs[
"Startup"]);
163 MainConsole.Instance = m_console;
165 LogEnvironmentInformation();
166 RegisterCommonAppenders(Config.Configs[
"Startup"]);
167 RegisterConsoleCommands();
169 base.StartupSpecific();
173 if (userStatsURI !=
String.Empty)
176 if (managedStatsURI !=
String.Empty)
178 string urlBase = String.Format(
"/{0}/", managedStatsURI);
179 MainServer.Instance.AddHTTPHandler(urlBase, StatsManager.HandleStatsRequest);
180 m_log.InfoFormat(
"[OPENSIM] Enabling remote managed stats fetch. URL = {0}", urlBase);
185 if (m_consolePort == 0)
187 ((RemoteConsole)m_console).SetServer(m_httpServer);
191 ((RemoteConsole)m_console).SetServer(MainServer.GetHttpServer(m_consolePort));
196 Watchdog.OnWatchdogTimeout += WatchdogTimeoutHandler;
198 PrintFileToConsole(
"startuplogo.txt");
202 ChangeSelectedRegion(
"region",
203 new string[] {
"change",
"region", SceneManager.Scenes[0].RegionInfo.RegionName});
205 ChangeSelectedRegion(
"region",
new string[] {
"change",
"region",
"root"});
208 if (
String.IsNullOrEmpty(m_startupCommandsFile))
210 m_log.Info(
"[STARTUP]: No startup command script specified. Moving on...");
214 RunCommandScript(m_startupCommandsFile);
218 if (m_timedScript !=
"disabled")
220 m_scriptTimer =
new Timer();
221 m_scriptTimer.Enabled =
true;
222 m_scriptTimer.Interval = m_timeInterval*1000;
223 m_scriptTimer.Elapsed += RunAutoTimerScript;
230 private void RegisterConsoleCommands()
232 MainServer.RegisterHttpConsoleCommands(m_console);
234 m_console.Commands.AddCommand(
"Objects",
false,
"force update",
236 "Force the update of all objects on clients",
239 m_console.Commands.AddCommand(
"General",
false,
"change region",
240 "change region <region name>",
241 "Change current console region",
242 ChangeSelectedRegion);
244 m_console.Commands.AddCommand(
"Archiving",
false,
"save xml",
246 "Save a region's data in XML format",
249 m_console.Commands.AddCommand(
"Archiving",
false,
"save xml2",
251 "Save a region's data in XML2 format",
254 m_console.Commands.AddCommand(
"Archiving",
false,
"load xml",
255 "load xml [-newIDs [<x> <y> <z>]]",
256 "Load a region's data from XML format",
259 m_console.Commands.AddCommand(
"Archiving",
false,
"load xml2",
261 "Load a region's data from XML2 format",
264 m_console.Commands.AddCommand(
"Archiving",
false,
"save prims xml2",
265 "save prims xml2 [<prim name> <file name>]",
266 "Save named prim to XML2",
269 m_console.Commands.AddCommand(
"Archiving",
false,
"load oar",
270 "load oar [-m|--merge] [-s|--skip-assets]"
271 +
" [--default-user \"User Name\"]"
272 +
" [--force-terrain] [--force-parcels]"
274 +
" [--rotation degrees]"
275 +
" [--bounding-origin \"<x,y,z>\"]"
276 +
" [--bounding-size \"<x,y,z>\"]"
277 +
" [--displacement \"<x,y,z>\"]"
280 "Load a region's data from an OAR archive.",
281 "--merge will merge the OAR with the existing scene (suppresses terrain and parcel info loading).\n"
282 +
"--skip-assets will load the OAR but ignore the assets it contains.\n"
283 +
"--default-user will use this user for any objects with an owner whose UUID is not found in the grid.\n"
284 +
"--force-terrain forces the loading of terrain from the oar (undoes suppression done by --merge).\n"
285 +
"--force-parcels forces the loading of parcels from the oar (undoes suppression done by --merge).\n"
286 +
"--no-objects suppresses the addition of any objects (good for loading only the terrain).\n"
287 +
"--rotation specified rotation to be applied to the oar. Specified in degrees.\n"
288 +
"--bounding-origin will only place objects that after displacement and rotation fall within the bounding cube who's position starts at <x,y,z>. Defaults to <0,0,0>.\n"
289 +
"--bounding-size specifies the size of the bounding cube. The default is the size of the destination region and cannot be larger than this.\n"
290 +
"--displacement will add this value to the position of every object loaded.\n"
291 +
"--debug forces the archiver to display messages about where each object is being placed.\n\n"
292 +
"The path can be either a filesystem location or a URI.\n"
293 +
" If this is not given then the command looks for an OAR named region.oar in the current directory."
294 +
" [--rotation-center \"<x,y,z>\"] used to be an option, now it does nothing and will be removed soon."
295 +
"When an OAR is being loaded, operations are applied in this order:\n"
296 +
"1: Rotation (around the incoming OARs region center)\n"
297 +
"2: Cropping (a bounding cube with origin and size)\n"
298 +
"3: Displacement (setting offset coordinates within the destination region)",
301 m_console.Commands.AddCommand(
"Archiving",
false,
"save oar",
303 "save oar [-h|--home=<url>] [--noassets] [--publish] [--perm=<permissions>] [--all] [<OAR path>]",
304 "Save a region's data to an OAR archive.",
306 "-h|--home=<url> adds the url of the profile service to the saved user information.\n"
307 +
"--noassets stops assets being saved to the OAR.\n"
308 +
"--publish saves an OAR stripped of owner and last owner information.\n"
309 +
" on reload, the estate owner will be the owner of all objects\n"
310 +
" this is useful if you're making oars generally available that might be reloaded to the same grid from which you published\n"
311 +
"--perm=<permissions> stops objects with insufficient permissions from being saved to the OAR.\n"
312 +
" <permissions> can contain one or more of these characters: \"C\" = Copy, \"T\" = Transfer\n"
313 +
"--all saves all the regions in the simulator, instead of just the current region.\n"
314 +
"The OAR path must be a filesystem path."
315 +
" If this is not given then the oar is saved to region.oar in the current directory.",
318 m_console.Commands.AddCommand(
"Objects",
false,
"edit scale",
319 "edit scale <name> <x> <y> <z>",
320 "Change the scale of a named prim",
323 m_console.Commands.AddCommand(
"Objects",
false,
"rotate scene",
324 "rotate scene <degrees> [centerX, centerY]",
325 "Rotates all scene objects around centerX, centerY (default 128, 128) (please back up your region before using)",
328 m_console.Commands.AddCommand(
"Objects",
false,
"scale scene",
329 "scale scene <factor>",
330 "Scales the scene objects (please back up your region before using)",
333 m_console.Commands.AddCommand(
"Objects",
false,
"translate scene",
334 "translate scene xOffset yOffset zOffset",
335 "translates the scene objects (please back up your region before using)",
336 HandleTranslateScene);
338 m_console.Commands.AddCommand(
"Users",
false,
"kick user",
339 "kick user <first> <last> [--force] [message]",
340 "Kick a user off the simulator",
341 "The --force option will kick the user without any checks to see whether it's already in the process of closing\n"
342 +
"Only use this option if you are sure the avatar is inactive and a normal kick user operation does not removed them",
345 m_console.Commands.AddCommand(
"Users",
false,
"show users",
347 "Show user data for users currently on the region",
348 "Without the 'full' option, only users actually on the region are shown."
349 +
" With the 'full' option child agents of users in neighbouring regions are also shown.",
352 m_console.Commands.AddCommand(
"Comms",
false,
"show connections",
354 "Show connection data",
357 m_console.Commands.AddCommand(
"Comms",
false,
"show circuits",
359 "Show agent circuit data",
362 m_console.Commands.AddCommand(
"Comms",
false,
"show pending-objects",
363 "show pending-objects",
364 "Show # of objects on the pending queues of all scene viewers",
367 m_console.Commands.AddCommand(
"General",
false,
"show modules",
372 m_console.Commands.AddCommand(
"Regions",
false,
"show regions",
377 m_console.Commands.AddCommand(
"Regions",
false,
"show ratings",
382 m_console.Commands.AddCommand(
"Objects",
false,
"backup",
384 "Persist currently unsaved object changes immediately instead of waiting for the normal persistence call.",
387 m_console.Commands.AddCommand(
"Regions",
false,
"create region",
388 "create region [\"region name\"] <region_file.ini>",
389 "Create a new region.",
390 "The settings for \"region name\" are read from <region_file.ini>. Paths specified with <region_file.ini> are relative to your Regions directory, unless an absolute path is given."
391 +
" If \"region name\" does not exist in <region_file.ini>, it will be added." + Environment.NewLine
392 +
"Without \"region name\", the first region found in <region_file.ini> will be created." + Environment.NewLine
393 +
"If <region_file.ini> does not exist, it will be created.",
396 m_console.Commands.AddCommand(
"Regions",
false,
"restart",
398 "Restart the currently selected region(s) in this instance",
401 m_console.Commands.AddCommand(
"General",
false,
"command-script",
402 "command-script <script>",
403 "Run a command script from file",
406 m_console.Commands.AddCommand(
"Regions",
false,
"remove-region",
407 "remove-region <name>",
408 "Remove a region from this simulator",
411 m_console.Commands.AddCommand(
"Regions",
false,
"delete-region",
412 "delete-region <name>",
413 "Delete a region from disk",
416 m_console.Commands.AddCommand(
"Estates",
false,
"estate create",
417 "estate create <owner UUID> <estate name>",
418 "Creates a new estate with the specified name, owned by the specified user."
419 +
" Estate name must be unique.",
420 CreateEstateCommand);
422 m_console.Commands.AddCommand(
"Estates",
false,
"estate set owner",
423 "estate set owner <estate-id>[ <UUID> | <Firstname> <Lastname> ]",
424 "Sets the owner of the specified estate to the specified UUID or user. ",
425 SetEstateOwnerCommand);
427 m_console.Commands.AddCommand(
"Estates",
false,
"estate set name",
428 "estate set name <estate-id> <new name>",
429 "Sets the name of the specified estate to the specified value. New name must be unique.",
430 SetEstateNameCommand);
432 m_console.Commands.AddCommand(
"Estates",
false,
"estate link region",
433 "estate link region <estate ID> <region ID>",
434 "Attaches the specified region to the specified estate.",
435 EstateLinkRegionCommand);
440 if (m_shutdownCommandsFile !=
String.Empty)
442 RunCommandScript(m_shutdownCommandsFile);
445 base.ShutdownSpecific();
453 private void RunAutoTimerScript(
object sender, EventArgs e)
455 if (m_timedScript !=
"disabled")
457 RunCommandScript(m_timedScript);
461 private void WatchdogTimeoutHandler(Watchdog.ThreadWatchdogInfo twi)
463 int now = Environment.TickCount & Int32.MaxValue;
466 "[WATCHDOG]: Timeout detected for thread \"{0}\". ThreadState={1}. Last tick was {2}ms ago. {3}",
468 twi.Thread.ThreadState,
470 twi.AlarmMethod != null ? string.Format(
"Data: {0}", twi.AlarmMethod()) :
"");
473 #region Console Commands
480 private void KickUserCommand(
string module,
string[] cmdparams)
484 OptionSet
options =
new OptionSet().Add(
"f|force", delegate (
string v) { force = v != null; });
486 List<string> mainParams = options.Parse(cmdparams);
488 if (mainParams.Count < 4)
492 if (mainParams.Count > 4)
493 alert = String.Format(
"\n{0}\n", String.Join(
" ", cmdparams, 4, cmdparams.Length - 4));
495 IList agents = SceneManager.GetCurrentSceneAvatars();
501 if (presence.
Firstname.ToLower().Equals(mainParams[2].ToLower()) &&
502 presence.Lastname.ToLower().Equals(mainParams[3].ToLower()))
504 MainConsole.Instance.Output(
506 "Kicking user: {0,-16} {1,-16} {2,-37} in region: {3,-16}",
507 presence.Firstname, presence.Lastname, presence.UUID, regionInfo.RegionName));
511 presence.ControllingClient.Kick(alert);
513 presence.ControllingClient.Kick(
"\nYou have been logged out by an administrator.\n");
515 presence.Scene.CloseAgent(presence.UUID, force);
520 MainConsole.Instance.Output(
"");
527 private static void PrintFileToConsole(
string fileName)
529 if (
File.Exists(fileName))
531 StreamReader readFile = File.OpenText(fileName);
533 while ((currentLine = readFile.ReadLine()) != null)
535 m_log.Info(
"[!]" + currentLine);
545 private void HandleForceUpdate(
string module,
string[] args)
547 MainConsole.Instance.Output(
"Updating all clients");
548 SceneManager.ForceCurrentSceneClientUpdate();
556 private void HandleEditScale(
string module,
string[] args)
558 if (args.Length == 6)
560 SceneManager.HandleEditCommandOnCurrentScene(args);
564 MainConsole.Instance.Output(
"Argument error: edit scale <prim name> <x> <y> <z>");
568 private void HandleRotateScene(
string module,
string[] args)
570 string usage =
"Usage: rotate scene <angle in degrees> [centerX centerY] (centerX and centerY are optional and default to Constants.RegionSize / 2";
572 float centerX = Constants.RegionSize * 0.5f;
573 float centerY = Constants.RegionSize * 0.5f;
575 if (args.Length < 3 || args.Length == 4)
577 MainConsole.Instance.Output(usage);
581 float angle = (float)(Convert.ToSingle(args[2]) / 180.0 * Math.PI);
582 OpenMetaverse.Quaternion rot = OpenMetaverse.Quaternion.CreateFromAxisAngle(0, 0, 1, angle);
586 centerX = Convert.ToSingle(args[3]);
587 centerY = Convert.ToSingle(args[4]);
590 Vector3 center =
new Vector3(centerX, centerY, 0.0f);
592 SceneManager.ForEachSelectedScene(delegate(
Scene scene)
598 sog.RootPart.UpdateRotation(rot * sog.GroupRotation);
599 Vector3 offset = sog.AbsolutePosition - center;
601 sog.UpdateGroupPosition(center + offset);
607 private void HandleScaleScene(
string module,
string[] args)
609 string usage =
"Usage: scale scene <factor>";
613 MainConsole.Instance.Output(usage);
617 float factor = (float)(Convert.ToSingle(args[2]));
619 float minZ = float.MaxValue;
621 SceneManager.ForEachSelectedScene(delegate(
Scene scene)
628 minZ = sog.RootPart.AbsolutePosition.Z;
633 SceneManager.ForEachSelectedScene(delegate(
Scene scene)
639 Vector3 tmpRootPos = sog.RootPart.AbsolutePosition;
640 tmpRootPos.Z -= minZ;
641 tmpRootPos *= factor;
642 tmpRootPos.Z += minZ;
647 sop.OffsetPosition *= factor;
651 sog.UpdateGroupPosition(tmpRootPos);
657 private void HandleTranslateScene(
string module,
string[] args)
659 string usage =
"Usage: translate scene <xOffset, yOffset, zOffset>";
663 MainConsole.Instance.Output(usage);
667 float xOFfset = (float)Convert.ToSingle(args[2]);
668 float yOffset = (float)Convert.ToSingle(args[3]);
669 float zOffset = (float)Convert.ToSingle(args[4]);
671 Vector3 offset =
new Vector3(xOFfset, yOffset, zOffset);
673 SceneManager.ForEachSelectedScene(delegate(
Scene scene)
678 sog.UpdateGroupPosition(sog.AbsolutePosition + offset);
688 private void HandleCreateRegion(
string module,
string[] cmd)
690 string regionName = string.Empty;
691 string regionFile = string.Empty;
697 else if (cmd.Length > 3)
703 string extension = Path.GetExtension(regionFile).ToLower();
704 bool isXml = extension.Equals(
".xml");
705 bool isIni = extension.Equals(
".ini");
707 if (!isXml && !isIni)
709 MainConsole.Instance.Output(
"Usage: create region [\"region name\"] <region_file.ini>");
713 if (!Path.IsPathRooted(regionFile))
715 string regionsDir = ConfigSource.Source.Configs[
"Startup"].GetString(
"regionload_regionsdir",
"Regions").Trim();
716 regionFile = Path.Combine(regionsDir, regionFile);
722 regInfo =
new RegionInfo(regionName, regionFile,
false, ConfigSource.Source);
726 regInfo =
new RegionInfo(regionName, regionFile,
false, ConfigSource.Source, regionName);
732 MainConsole.Instance.OutputFormat(
733 "ERROR: Cannot create region {0} with ID {1}, this ID is already assigned to region {2}",
734 regInfo.RegionName, regInfo.RegionID, existingScene.RegionInfo.RegionName);
739 bool changed = PopulateRegionEstateInfo(regInfo);
741 CreateRegion(regInfo,
true, out scene);
744 m_estateDataService.StoreEstateSettings(regInfo.EstateSettings);
756 List<string> args =
new List<string>(cmdparams);
760 string command = args[0];
763 cmdparams = args.ToArray();
768 MainConsole.Instance.Output(
"Triggering save of pending object updates to persistent store");
769 SceneManager.BackupCurrentScene();
772 case "remove-region":
773 string regRemoveName = CombineParams(cmdparams, 0);
777 RemoveRegion(removeScene,
false);
779 MainConsole.Instance.Output(
"No region with that name");
782 case "delete-region":
783 string regDeleteName = CombineParams(cmdparams, 0);
787 RemoveRegion(killScene,
true);
789 MainConsole.Instance.Output(
"no region with that name");
793 SceneManager.RestartCurrentScene();
804 if (cmdparams.Length > 2)
806 string newRegionName = CombineParams(cmdparams, 2);
815 MainConsole.Instance.Output(
"Usage: change region <region name>");
822 private void RefreshPrompt()
824 string regionName = (SceneManager.CurrentScene == null ?
"root" : SceneManager.CurrentScene.RegionInfo.RegionName);
825 MainConsole.Instance.Output(String.Format(
"Currently selected region is {0}", regionName));
828 string prompt = m_consolePrompt;
832 prompt = m_consolePromptRegex.Replace(prompt, m =>
835 if (m.Groups[2].Value ==
"R")
836 return m.Groups[1].Value + regionName;
838 return m.Groups[0].Value;
841 m_console.DefaultPrompt = prompt;
842 m_console.ConsoleScene = SceneManager.CurrentScene;
847 base.HandleRestartRegion(whichRegion);
851 if (m_console.ConsoleScene != null && whichRegion.
RegionName == ((
Scene)m_console.ConsoleScene).Name)
865 base.HandleShow(mod, cmd);
867 List<string> args =
new List<string>(cmd);
869 string[] showParams = args.ToArray();
871 switch (showParams[0])
875 if (showParams.Length > 1 && showParams[1] ==
"full")
877 agents = SceneManager.GetCurrentScenePresences();
880 agents = SceneManager.GetCurrentSceneAvatars();
883 MainConsole.Instance.Output(String.Format(
"\nAgents connected: {0}\n", agents.Count));
885 MainConsole.Instance.Output(
886 String.Format(
"{0,-16} {1,-16} {2,-37} {3,-11} {4,-16} {5,-30}",
"Firstname",
"Lastname",
887 "Agent ID",
"Root/Child",
"Region",
"Position")
895 if (regionInfo == null)
897 regionName =
"Unresolvable";
900 regionName = regionInfo.RegionName;
903 MainConsole.Instance.Output(
905 "{0,-16} {1,-16} {2,-37} {3,-11} {4,-16} {5,-30}",
909 presence.IsChildAgent ?
"Child" :
"Root",
911 presence.AbsolutePosition.ToString())
915 MainConsole.Instance.Output(String.Empty);
919 HandleShowConnections();
923 HandleShowCircuits();
927 SceneManager.ForEachSelectedScene(
930 MainConsole.Instance.OutputFormat(
"Loaded region modules in {0} are:", scene.Name);
932 List<IRegionModuleBase> sharedModules =
new List<IRegionModuleBase>();
933 List<IRegionModuleBase> nonSharedModules =
new List<IRegionModuleBase>();
937 if (module.GetType().GetInterface(
"ISharedRegionModule") == null)
938 nonSharedModules.Add(module);
940 sharedModules.Add(module);
951 MainConsole.Instance.Output(
"");
956 cdt.AddColumn(
"Name", ConsoleDisplayUtil.RegionNameSize);
957 cdt.AddColumn(
"ID", ConsoleDisplayUtil.UuidSize);
958 cdt.AddColumn(
"Position", ConsoleDisplayUtil.CoordTupleSize);
959 cdt.AddColumn(
"Size", 11);
960 cdt.AddColumn(
"Port", ConsoleDisplayUtil.PortSize);
961 cdt.AddColumn(
"Ready?", 6);
962 cdt.AddColumn(
"Estate", ConsoleDisplayUtil.EstateNameSize);
963 SceneManager.ForEachScene(
970 string.Format(
"{0},{1}", ri.RegionLocX, ri.RegionLocY),
972 ri.InternalEndPoint.Port,
973 scene.Ready ?
"Yes" :
"No",
974 ri.EstateSettings.EstateName);
978 MainConsole.Instance.Output(cdt.ToString());
982 SceneManager.ForEachScene(
983 delegate(
Scene scene)
998 MainConsole.Instance.Output(String.Format(
999 "Region Name: {0}, Region Rating {1}",
1000 scene.RegionInfo.RegionName,
1007 private void HandleShowCircuits()
1010 cdt.AddColumn(
"Region", 20);
1011 cdt.AddColumn(
"Avatar name", 24);
1012 cdt.AddColumn(
"Type", 5);
1013 cdt.AddColumn(
"Code", 10);
1014 cdt.AddColumn(
"IP", 16);
1015 cdt.AddColumn(
"Viewer Name", 24);
1017 SceneManager.ForEachScene(
1020 foreach (
AgentCircuitData aCircuit
in s.AuthenticateHandler.GetAgentCircuits().Values)
1024 aCircuit.
child ?
"child" :
"root",
1026 aCircuit.IPAddress != null ? aCircuit.IPAddress.ToString() :
"not set",
1027 Util.GetViewerName(aCircuit));
1030 MainConsole.Instance.Output(cdt.ToString());
1033 private void HandleShowConnections()
1036 cdt.AddColumn(
"Region", 20);
1037 cdt.AddColumn(
"Avatar name", 24);
1038 cdt.AddColumn(
"Circuit code", 12);
1039 cdt.AddColumn(
"Endpoint", 23);
1040 cdt.AddColumn(
"Active?", 7);
1041 cdt.AddColumn(
"ChildAgent?", 7);
1042 cdt.AddColumn(
"ping(ms)", 8);
1044 SceneManager.ForEachScene(
1045 s => s.ForEachClient(
1049 if(c.SceneAgent != null && c.SceneAgent.IsChildAgent)
1054 c.CircuitCode.ToString(),
1055 c.RemoteEndPoint.ToString(),
1056 c.IsActive.ToString(),
1061 MainConsole.Instance.Output(cdt.ToString());
1071 if (cmdparams.Length > 5)
1073 SceneManager.SaveNamedPrimsToXml2(cmdparams[3], cmdparams[4]);
1077 SceneManager.SaveNamedPrimsToXml2(
"Primitive", DEFAULT_PRIM_BACKUP_FILENAME);
1086 protected void SaveXml(
string module,
string[] cmdparams)
1088 MainConsole.Instance.Output(
"PLEASE NOTE, save-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use save-xml2, please file a mantis detailing the reason.");
1090 if (cmdparams.Length > 0)
1092 SceneManager.SaveCurrentSceneToXml(cmdparams[2]);
1096 SceneManager.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME);
1105 protected void LoadXml(
string module,
string[] cmdparams)
1107 MainConsole.Instance.Output(
"PLEASE NOTE, load-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use load-xml2, please file a mantis detailing the reason.");
1109 Vector3 loadOffset =
new Vector3(0, 0, 0);
1110 if (cmdparams.Length > 2)
1112 bool generateNewIDS =
false;
1113 if (cmdparams.Length > 3)
1115 if (cmdparams[3] ==
"-newUID")
1117 generateNewIDS =
true;
1119 if (cmdparams.Length > 4)
1122 if (cmdparams.Length > 5)
1126 if (cmdparams.Length > 6)
1130 MainConsole.Instance.Output(String.Format(
"loadOffsets <X,Y,Z> = <{0},{1},{2}>",loadOffset.X,loadOffset.Y,loadOffset.Z));
1133 SceneManager.LoadCurrentSceneFromXml(cmdparams[2], generateNewIDS, loadOffset);
1139 SceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME,
false, loadOffset);
1141 catch (FileNotFoundException)
1143 MainConsole.Instance.Output(
"Default xml not found. Usage: load-xml <filename>");
1152 protected void SaveXml2(
string module,
string[] cmdparams)
1154 if (cmdparams.Length > 2)
1156 SceneManager.SaveCurrentSceneToXml2(cmdparams[2]);
1160 SceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME);
1169 protected void LoadXml2(
string module,
string[] cmdparams)
1171 if (cmdparams.Length > 2)
1175 SceneManager.LoadCurrentSceneFromXml2(cmdparams[2]);
1177 catch (FileNotFoundException)
1179 MainConsole.Instance.Output(
"Specified xml not found. Usage: load xml2 <filename>");
1186 SceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME);
1188 catch (FileNotFoundException)
1190 MainConsole.Instance.Output(
"Default xml not found. Usage: load xml2 <filename>");
1199 protected void LoadOar(
string module,
string[] cmdparams)
1203 SceneManager.LoadArchiveToCurrentScene(cmdparams);
1207 MainConsole.Instance.Output(e.Message);
1215 protected void SaveOar(
string module,
string[] cmdparams)
1217 SceneManager.SaveCurrentSceneToArchive(cmdparams);
1222 string response = null;
1225 if (args.Length == 2)
1227 response =
"No user specified.";
1229 else if (!
UUID.TryParse(args[2], out userID))
1231 response = String.Format(
"{0} is not a valid UUID", args[2]);
1233 else if (args.Length == 3)
1235 response =
"No estate name specified.";
1239 Scene scene = SceneManager.CurrentOrFirstScene;
1242 UUID scopeID = UUID.Zero;
1243 UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, userID);
1244 if (account == null)
1246 response = String.Format(
"Could not find user {0}", userID);
1251 StringBuilder sb =
new StringBuilder(args[3]);
1252 for (
int i = 4; i < args.Length; i++)
1253 sb.Append (
" " + args[i]);
1254 string estateName = sb.ToString().Trim();
1258 response = estateModule.CreateEstate(estateName, userID);
1259 if (response ==
String.Empty)
1261 List<int> estates = scene.EstateDataService.GetEstates(estateName);
1262 response = String.Format(
"Estate {0} created as \"{1}\"", estates.ElementAt(0), estateName);
1268 if (response != null)
1269 MainConsole.Instance.Output(response);
1274 string response = null;
1276 Scene scene = SceneManager.CurrentOrFirstScene;
1279 if (args.Length == 3)
1281 response =
"No estate specified.";
1286 if (!
int.TryParse(args[3], out estateId))
1288 response = String.Format(
"\"{0}\" is not a valid ID for an Estate", args[3]);
1292 if (args.Length == 4)
1294 response =
"No user specified.";
1301 UUID scopeID = UUID.Zero;
1303 string s1 = args[4];
1304 if (args.Length == 5)
1308 if (
UUID.TryParse(s1, out u))
1310 account = scene.UserAccountService.GetUserAccount(scopeID, u);
1311 if (account == null)
1312 response = String.Format(
"Could not find user {0}", s1);
1316 response = String.Format(
"Invalid UUID {0}", s1);
1322 string s2 = args[5];
1323 account = scene.UserAccountService.GetUserAccount(scopeID, s1, s2);
1324 if (account == null)
1325 response = String.Format(
"Could not find user {0} {1}", s1, s2);
1329 if (account != null)
1330 response = estateModule.SetEstateOwner(estateId, account);
1332 if (response ==
String.Empty)
1334 response = String.Format(
"Estate owner changed to {0} ({1} {2})", account.PrincipalID, account.FirstName, account.LastName);
1341 if (response != null)
1342 MainConsole.Instance.Output(response);
1347 string response = null;
1349 Scene scene = SceneManager.CurrentOrFirstScene;
1352 if (args.Length == 3)
1354 response =
"No estate specified.";
1359 if (!
int.TryParse(args[3], out estateId))
1361 response = String.Format(
"\"{0}\" is not a valid ID for an Estate", args[3]);
1365 if (args.Length == 4)
1367 response =
"No name specified.";
1372 StringBuilder sb =
new StringBuilder(args[4]);
1373 for (
int i = 5; i < args.Length; i++)
1374 sb.Append (
" " + args[i]);
1376 string estateName = sb.ToString();
1379 response = estateModule.SetEstateName(estateId, estateName);
1381 if (response ==
String.Empty)
1383 response = String.Format(
"Estate {0} renamed to \"{1}\"", estateId, estateName);
1390 if (response != null)
1391 MainConsole.Instance.Output(response);
1394 private void EstateLinkRegionCommand(
string module,
string[] args)
1397 UUID regionId = UUID.Zero;
1399 string response = null;
1401 if (args.Length == 3)
1403 response =
"No estate specified.";
1405 else if (!
int.TryParse(args [3], out estateId))
1407 response = String.Format(
"\"{0}\" is not a valid ID for an Estate", args [3]);
1409 else if (args.Length == 4)
1411 response =
"No region specified.";
1413 else if (!
UUID.TryParse(args[4], out regionId))
1415 response = String.Format(
"\"{0}\" is not a valid UUID for a Region", args [4]);
1420 response = String.Format(
"No access to Region \"{0}\"", args [4]);
1423 if (response != null)
1425 MainConsole.Instance.Output(response);
1432 if (response ==
String.Empty)
1434 estateModule.TriggerRegionInfoChange();
1435 estateModule.sendRegionHandshakeToAll();
1436 response = String.Format (
"Region {0} is now attached to estate {1}", regionId, estateId);
1440 if (response != null)
1441 MainConsole.Instance.Output (response);
1446 private static string CombineParams(
string[] commandParams,
int pos)
1448 string result = String.Empty;
1449 for (
int i = pos; i < commandParams.Length; i++)
1451 result += commandParams[i] +
" ";
1453 result = result.TrimEnd(
' ');
string Name
Agent's full name.
void OutputFormat(string format, params object[] components)
static NumberFormatInfo NumberFormatInfo
uint circuitcode
Number given to the client when they log-in that they provide as credentials to the UDP server ...
Handler to supply the current status of this sim
bool TrySetCurrentScene(string regionName)
void SavePrimsXml2(string module, string[] cmdparams)
Use XML2 format to serialize data to a file
Used to generated a formatted table for the console.
FireAndForgetMethod
The method used by Util.FireAndForget for asynchronously firing events
OpenSim.Framework.RegionInfo RegionInfo
void CreateEstateCommand(string module, string[] args)
void SaveXml2(string module, string[] cmdparams)
Serialize region data to XML2Format
uint RegionSizeX
X dimension of the region.
uint RegionSizeY
X dimension of the region.
void ChangeSelectedRegion(string module, string[] cmdparams)
Change the currently selected region. The selected region is that operated upon by single region comm...
string m_startupCommandsFile
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
bool child
Root agent, or Child agent
void SetEstateNameCommand(string module, string[] args)
RegionSettings RegionSettings
override void HandleRestartRegion(RegionInfo whichRegion)
Handler to supply the current extended status of this sim Sends the statistical data in a json serial...
System.Timers.Timer Timer
void SaveXml(string module, string[] cmdparams)
Use XML format to serialize data to a file
void AddRow(params object[] cells)
Handler to supply the current extended status of this sim to a user configured URI Sends the statisti...
override void ReadExtraConfigSettings()
override void ShutdownSpecific()
Should be overriden and referenced by descendents if they need to perform extra shutdown processing ...
Circuit data for an agent. Connection information shared between regions that accept UDP connections ...
override void HandleShow(string mod, string[] cmd)
Many commands list objects for debugging. Some of the types are listed here
void LoadOar(string module, string[] cmdparams)
Load a whole region from an opensimulator archive.
static ICommandConsole Instance
void LoadXml2(string module, string[] cmdparams)
Load region data from Xml2Format
Manager for adding, closing and restarting scenes.
void SaveOar(string module, string[] cmdparams)
Save a region to a file, including all the assets needed to restore it.
void Output(string text, string level)
void RunCommand(string module, string[] cmdparams)
Runs commands issued by the server console from the operator
Interactive OpenSim region server
override void StartupSpecific()
Performs initialisation of the scene, such as loading configuration from disk.
string m_shutdownCommandsFile
void SetEstateOwnerCommand(string module, string[] args)
Common OpenSimulator simulator code
uint ParentID
The parent ID of this part.
void LoadXml(string module, string[] cmdparams)
Loads data and region objects from XML format.
virtual RegionInfo RegionInfo
A console that uses cursor control and color
A console that processes commands internally
OpenSim(IConfigSource configSource)
bool IsAttachment
Is this scene object acting as an attachment?
bool TryGetScene(string regionName, out Scene scene)