/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Reflection;
using System.Runtime;
using System.Threading;
using OpenMetaverse;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Statistics;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
using Timer = System.Timers.Timer;
namespace OpenSim
{
///
/// Interactive OpenSim region server
///
public class OpenSim : OpenSimBase
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected string m_startupCommandsFile;
protected string m_shutdownCommandsFile;
private string m_timedScript = "disabled";
private Timer m_scriptTimer;
private bool m_gui = false;
public OpenSim(IConfigSource configSource) : base(configSource)
{
}
protected override void ReadExtraConfigSettings()
{
base.ReadExtraConfigSettings();
IConfig startupConfig = m_config.Source.Configs["Startup"];
if (startupConfig != null)
{
m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", String.Empty);
m_shutdownCommandsFile = startupConfig.GetString("shutdown_console_commands_file", String.Empty);
m_gui = startupConfig.GetBoolean("gui", false);
m_timedScript = startupConfig.GetString("timer_Script", "disabled");
}
}
///
/// Performs initialisation of the scene, such as loading configuration from disk.
///
protected override void StartupSpecific()
{
m_log.Info("====================================================================");
m_log.Info("========================= STARTING OPENSIM =========================");
m_log.Info("====================================================================");
m_log.InfoFormat("[OPENSIM MAIN]: Running in {0} mode", (ConfigurationSettings.Standalone ? "sandbox" : "grid"));
//m_log.InfoFormat("[OPENSIM MAIN]: GC Is Server GC: {0}", GCSettings.IsServerGC.ToString());
// http://msdn.microsoft.com/en-us/library/bb384202.aspx
//GCSettings.LatencyMode = GCLatencyMode.Batch;
//m_log.InfoFormat("[OPENSIM MAIN]: GC Latency Mode: {0}", GCSettings.LatencyMode.ToString());
m_console = new ConsoleBase("Region");
m_console.SetGuiMode(m_gui);
MainConsole.Instance = m_console;
m_console.Commands.AddCommand("region", "clear assets",
"clear assets",
"Clear the asset cache", HandleClearAssets);
m_console.Commands.AddCommand("region", "force update",
"force update",
"Force the update of all objects on clients",
HandleForceUpdate);
m_console.Commands.AddCommand("region", "debug packet",
"debug packet ",
"Turn on packet debugging", Debug);
m_console.Commands.AddCommand("region", "debug scene",
"debug scene ",
"Turn on scene debugging", Debug);
m_console.Commands.AddCommand("region", "change region",
"change region ",
"Change current console region", ChangeSelectedRegion);
m_console.Commands.AddCommand("region", "save xml",
"save xml",
"Save a region's data in XML format", SaveXml);
m_console.Commands.AddCommand("region", "save xml2",
"save xml2",
"Save a region's data in XML2 format", SaveXml2);
m_console.Commands.AddCommand("region", "load xml",
"load xml [-newIDs [ ]]",
"Load a region's data from XML format", LoadXml);
m_console.Commands.AddCommand("region", "load xml2",
"load xml2",
"Load a region's data from XML2 format", LoadXml2);
m_console.Commands.AddCommand("region", "save prims xml2",
"save prims xml2 [ ]",
"Save named prim to XML2", SavePrimsXml2);
m_console.Commands.AddCommand("region", "load oar",
"load oar ",
"Load a region's data from OAR archive", LoadOar);
m_console.Commands.AddCommand("region", "save oar",
"save oar ",
"Save a region's data to an OAR archive",
"More information on forthcoming options here soon", SaveOar);
m_console.Commands.AddCommand("region", "save inventory",
"save inventory ",
"Save user inventory data", SaveInv);
m_console.Commands.AddCommand("region", "load inventory",
"load inventory ",
"Load user inventory data", LoadInv);
m_console.Commands.AddCommand("region", "edit scale",
"edit scale ",
"Change the scale of a named prim", HandleEditScale);
m_console.Commands.AddCommand("region", "kick user",
"kick user ",
"Kick a user off the simulator", KickUserCommand);
m_console.Commands.AddCommand("region", "show assets",
"show assets",
"Show asset data", HandleShow);
m_console.Commands.AddCommand("region", "show users",
"show users [full]",
"Show user data", HandleShow);
m_console.Commands.AddCommand("region", "show users full",
"show users full",
String.Empty, HandleShow);
m_console.Commands.AddCommand("region", "show modules",
"show modules",
"Show module data", HandleShow);
m_console.Commands.AddCommand("region", "show regions",
"show regions",
"Show region data", HandleShow);
m_console.Commands.AddCommand("region", "show queues",
"show queues",
"Show queue data", HandleShow);
m_console.Commands.AddCommand("region", "alert",
"alert ",
"Send an alert to a user", RunCommand);
m_console.Commands.AddCommand("region", "alert general",
"alert general ",
"Send an alert everyone", RunCommand);
m_console.Commands.AddCommand("region", "backup",
"backup",
"Persist objects to the database now", RunCommand);
m_console.Commands.AddCommand("region", "create region",
"create region",
"Create a new region", HandleCreateRegion);
m_console.Commands.AddCommand("region", "login enable",
"login enable",
"Enable logins to the simulator", HandleLoginEnable);
m_console.Commands.AddCommand("region", "login disable",
"login disable",
"Disable logins to the simulator", HandleLoginDisable);
m_console.Commands.AddCommand("region", "login status",
"login status",
"Display status of logins", HandleLoginStatus);
m_console.Commands.AddCommand("region", "restart",
"restart",
"Restart all sims in this instance", RunCommand);
m_console.Commands.AddCommand("region", "config set",
"config set ",
"Set a config option", HandleConfig);
m_console.Commands.AddCommand("region", "config get",
"config get ",
"Read a config option", HandleConfig);
m_console.Commands.AddCommand("region", "config save",
"config save",
"Save current configuration", HandleConfig);
m_console.Commands.AddCommand("region", "command-script",
"command-script