2008-04-28 14:41:46 +00:00
/ *
* 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 .
2009-06-01 06:37:14 +00:00
* * Neither the name of the OpenSimulator Project nor the
2008-04-28 14:41:46 +00:00
* 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 ;
2008-05-01 14:45:56 +00:00
using System.Collections ;
2008-04-28 14:41:46 +00:00
using System.Collections.Generic ;
using System.IO ;
2008-05-01 14:45:56 +00:00
using System.Reflection ;
2009-02-12 09:53:12 +00:00
using System.Timers ;
2008-05-01 14:45:56 +00:00
using log4net ;
2008-04-28 14:41:46 +00:00
using Nini.Config ;
2009-02-12 09:53:12 +00:00
using OpenMetaverse ;
2008-04-28 14:41:46 +00:00
using OpenSim.Framework ;
using OpenSim.Framework.Console ;
using OpenSim.Framework.Statistics ;
2009-02-06 16:55:34 +00:00
using OpenSim.Region.Framework.Interfaces ;
using OpenSim.Region.Framework.Scenes ;
2008-04-28 14:41:46 +00:00
namespace OpenSim
{
2009-01-12 15:34:05 +00:00
/// <summary>
2008-06-01 01:01:16 +00:00
/// Interactive OpenSim region server
/// </summary>
2009-02-07 12:25:39 +00:00
public class OpenSim : OpenSimBase
2008-05-16 01:22:11 +00:00
{
2008-05-01 14:45:56 +00:00
private static readonly ILog m_log = LogManager . GetLogger ( MethodBase . GetCurrentMethod ( ) . DeclaringType ) ;
2008-04-28 14:41:46 +00:00
protected string m_startupCommandsFile ;
protected string m_shutdownCommandsFile ;
2009-04-16 12:10:50 +00:00
protected bool m_gui = false ;
2009-08-17 08:21:39 +00:00
protected string m_consoleType = "local" ;
2008-04-28 14:41:46 +00:00
private string m_timedScript = "disabled" ;
private Timer m_scriptTimer ;
2008-08-19 02:59:27 +00:00
2008-06-01 01:01:16 +00:00
public OpenSim ( IConfigSource configSource ) : base ( configSource )
2008-04-28 14:41:46 +00:00
{
}
2008-11-05 20:14:52 +00:00
protected override void ReadExtraConfigSettings ( )
2008-04-28 14:41:46 +00:00
{
2008-11-06 20:17:20 +00:00
base . ReadExtraConfigSettings ( ) ;
2008-06-26 17:23:05 +00:00
IConfig startupConfig = m_config . Source . Configs [ "Startup" ] ;
2008-04-28 14:41:46 +00:00
2009-10-22 08:30:12 +00:00
int stpMaxThreads = 15 ;
2009-10-22 01:28:53 +00:00
2008-04-28 14:41:46 +00:00
if ( startupConfig ! = null )
{
2009-03-11 09:31:02 +00:00
m_startupCommandsFile = startupConfig . GetString ( "startup_console_commands_file" , "startup_commands.txt" ) ;
m_shutdownCommandsFile = startupConfig . GetString ( "shutdown_console_commands_file" , "shutdown_commands.txt" ) ;
2008-04-28 14:41:46 +00:00
2009-08-17 08:21:39 +00:00
if ( startupConfig . GetString ( "console" , String . Empty ) = = String . Empty )
m_gui = startupConfig . GetBoolean ( "gui" , false ) ;
else
m_consoleType = startupConfig . GetString ( "console" , String . Empty ) ;
2009-02-10 12:25:29 +00:00
2008-04-28 14:41:46 +00:00
m_timedScript = startupConfig . GetString ( "timer_Script" , "disabled" ) ;
2009-05-04 20:15:39 +00:00
if ( m_logFileAppender ! = null )
{
if ( m_logFileAppender is log4net . Appender . FileAppender )
{
log4net . Appender . FileAppender appender =
( log4net . Appender . FileAppender ) m_logFileAppender ;
2009-05-09 02:49:55 +00:00
string fileName = startupConfig . GetString ( "LogFile" , String . Empty ) ;
if ( fileName ! = String . Empty )
2009-08-07 13:15:59 +00:00
{
2009-05-09 02:49:55 +00:00
appender . File = fileName ;
2009-08-07 13:15:59 +00:00
appender . ActivateOptions ( ) ;
}
2009-10-22 06:03:18 +00:00
m_log . InfoFormat ( "[LOGGING]: Logging started to file {0}" , appender . File ) ;
2009-05-04 20:15:39 +00:00
}
}
2009-10-22 06:03:18 +00:00
string asyncCallMethodStr = startupConfig . GetString ( "async_call_method" , String . Empty ) ;
FireAndForgetMethod asyncCallMethod ;
if ( ! String . IsNullOrEmpty ( asyncCallMethodStr ) & & Utils . EnumTryParse < FireAndForgetMethod > ( asyncCallMethodStr , out asyncCallMethod ) )
Util . FireAndForgetMethod = asyncCallMethod ;
2009-10-22 08:30:12 +00:00
stpMaxThreads = startupConfig . GetInt ( "MaxPoolThreads" , 15 ) ;
2008-04-28 14:41:46 +00:00
}
2009-10-22 06:03:18 +00:00
2009-10-22 08:30:12 +00:00
if ( Util . FireAndForgetMethod = = FireAndForgetMethod . SmartThreadPool )
Util . InitThreadPool ( stpMaxThreads ) ;
2009-10-22 06:03:18 +00:00
m_log . Info ( "[OPENSIM MAIN]: Using async_call_method " + Util . FireAndForgetMethod ) ;
2008-04-28 14:41:46 +00:00
}
/// <summary>
/// Performs initialisation of the scene, such as loading configuration from disk.
/// </summary>
2008-10-03 15:41:27 +00:00
protected override void StartupSpecific ( )
2008-04-28 14:41:46 +00:00
{
m_log . Info ( "====================================================================" ) ;
m_log . Info ( "========================= STARTING OPENSIM =========================" ) ;
m_log . Info ( "====================================================================" ) ;
2009-03-10 20:27:41 +00:00
m_log . InfoFormat ( "[OPENSIM MAIN]: Running in {0} mode" ,
( ConfigurationSettings . Standalone ? "sandbox" : "grid" ) ) ;
2008-12-05 16:20:12 +00:00
//m_log.InfoFormat("[OPENSIM MAIN]: GC Is Server GC: {0}", GCSettings.IsServerGC.ToString());
2008-12-05 12:59:50 +00:00
// http://msdn.microsoft.com/en-us/library/bb384202.aspx
//GCSettings.LatencyMode = GCLatencyMode.Batch;
2008-12-05 13:12:16 +00:00
//m_log.InfoFormat("[OPENSIM MAIN]: GC Latency Mode: {0}", GCSettings.LatencyMode.ToString());
2008-05-16 01:22:11 +00:00
2009-05-04 12:15:55 +00:00
if ( m_gui ) // Driven by external GUI
m_console = new CommandConsole ( "Region" ) ;
else
2009-08-17 08:21:39 +00:00
{
switch ( m_consoleType )
{
case "basic" :
m_console = new CommandConsole ( "Region" ) ;
break ;
case "rest" :
m_console = new RemoteConsole ( "Region" ) ;
( ( RemoteConsole ) m_console ) . ReadConfig ( m_config . Source ) ;
break ;
default :
m_console = new LocalConsole ( "Region" ) ;
break ;
}
}
2008-08-18 00:39:10 +00:00
MainConsole . Instance = m_console ;
2009-02-26 20:01:20 +00:00
RegisterConsoleCommands ( ) ;
base . StartupSpecific ( ) ;
2009-08-17 08:21:39 +00:00
if ( m_console is RemoteConsole )
( ( RemoteConsole ) m_console ) . SetServer ( m_httpServer ) ;
2009-02-26 20:01:20 +00:00
//Run Startup Commands
2009-03-10 20:27:41 +00:00
if ( String . IsNullOrEmpty ( m_startupCommandsFile ) )
2009-02-26 20:01:20 +00:00
{
m_log . Info ( "[STARTUP]: No startup command script specified. Moving on..." ) ;
}
else
{
RunCommandScript ( m_startupCommandsFile ) ;
}
// Start timer script (run a script every xx seconds)
if ( m_timedScript ! = "disabled" )
{
m_scriptTimer = new Timer ( ) ;
m_scriptTimer . Enabled = true ;
2009-03-10 20:27:41 +00:00
m_scriptTimer . Interval = 1200 * 1000 ;
2009-02-26 20:01:20 +00:00
m_scriptTimer . Elapsed + = RunAutoTimerScript ;
}
2009-10-22 19:33:23 +00:00
// Hook up to the watchdog timer
Watchdog . OnWatchdogTimeout + = WatchdogTimeoutHandler ;
2009-02-26 20:01:20 +00:00
PrintFileToConsole ( "startuplogo.txt" ) ;
// For now, start at the 'root' level by default
if ( m_sceneManager . Scenes . Count = = 1 ) // If there is only one region, select it
2009-03-10 20:27:41 +00:00
ChangeSelectedRegion ( "region" ,
new string [ ] { "change" , "region" , m_sceneManager . Scenes [ 0 ] . RegionInfo . RegionName } ) ;
2009-02-26 20:01:20 +00:00
else
ChangeSelectedRegion ( "region" , new string [ ] { "change" , "region" , "root" } ) ;
}
2009-08-13 02:54:57 +00:00
/// <summary>
/// Register standard set of region console commands
/// </summary>
2009-02-26 20:01:20 +00:00
private void RegisterConsoleCommands ( )
{
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "clear assets" ,
2009-03-10 20:27:41 +00:00
"clear assets" ,
"Clear the asset cache" , HandleClearAssets ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "force update" ,
2009-03-10 20:27:41 +00:00
"force update" ,
"Force the update of all objects on clients" ,
HandleForceUpdate ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "debug packet" ,
2009-03-10 20:27:41 +00:00
"debug packet <level>" ,
"Turn on packet debugging" , Debug ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "debug scene" ,
2009-03-10 20:27:41 +00:00
"debug scene <cripting> <collisions> <physics>" ,
"Turn on scene debugging" , Debug ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "change region" ,
2009-03-10 20:27:41 +00:00
"change region <region name>" ,
"Change current console region" , ChangeSelectedRegion ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "save xml" ,
2009-03-10 20:27:41 +00:00
"save xml" ,
"Save a region's data in XML format" , SaveXml ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "save xml2" ,
2009-03-10 20:27:41 +00:00
"save xml2" ,
"Save a region's data in XML2 format" , SaveXml2 ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "load xml" ,
2009-03-10 20:27:41 +00:00
"load xml [-newIDs [<x> <y> <z>]]" ,
"Load a region's data from XML format" , LoadXml ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "load xml2" ,
2009-03-10 20:27:41 +00:00
"load xml2" ,
"Load a region's data from XML2 format" , LoadXml2 ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "save prims xml2" ,
2009-03-10 20:27:41 +00:00
"save prims xml2 [<prim name> <file name>]" ,
"Save named prim to XML2" , SavePrimsXml2 ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "load oar" ,
2009-03-10 20:27:41 +00:00
"load oar <oar name>" ,
"Load a region's data from OAR archive" , LoadOar ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "save oar" ,
2009-03-10 20:27:41 +00:00
"save oar <oar name>" ,
"Save a region's data to an OAR archive" ,
"More information on forthcoming options here soon" , SaveOar ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "edit scale" ,
2009-03-10 20:27:41 +00:00
"edit scale <name> <x> <y> <z>" ,
"Change the scale of a named prim" , HandleEditScale ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "kick user" ,
2009-03-25 18:04:33 +00:00
"kick user <first> <last> [message]" ,
2009-03-10 20:27:41 +00:00
"Kick a user off the simulator" , KickUserCommand ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "show assets" ,
2009-03-10 20:27:41 +00:00
"show assets" ,
"Show asset data" , HandleShow ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "show users" ,
2009-03-10 20:27:41 +00:00
"show users [full]" ,
"Show user data" , HandleShow ) ;
2009-02-07 12:25:39 +00:00
2009-10-14 20:00:42 +00:00
m_console . Commands . AddCommand ( "region" , false , "show connections" ,
"show connections" ,
"Show connection data" , HandleShow ) ;
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "show users full" ,
2009-03-10 20:27:41 +00:00
"show users full" ,
String . Empty , HandleShow ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "show modules" ,
2009-03-10 20:27:41 +00:00
"show modules" ,
"Show module data" , HandleShow ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "show regions" ,
2009-03-10 20:27:41 +00:00
"show regions" ,
"Show region data" , HandleShow ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "show queues" ,
2009-03-10 20:27:41 +00:00
"show queues" ,
"Show queue data" , HandleShow ) ;
2009-05-12 03:35:07 +00:00
m_console . Commands . AddCommand ( "region" , false , "show ratings" ,
"show ratings" ,
"Show rating data" , HandleShow ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "backup" ,
2009-03-10 20:27:41 +00:00
"backup" ,
"Persist objects to the database now" , RunCommand ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "create region" ,
2009-03-10 20:27:41 +00:00
"create region" ,
"Create a new region" , HandleCreateRegion ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "login enable" ,
2009-03-10 20:27:41 +00:00
"login enable" ,
"Enable logins to the simulator" , HandleLoginEnable ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "login disable" ,
2009-03-10 20:27:41 +00:00
"login disable" ,
"Disable logins to the simulator" , HandleLoginDisable ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "login status" ,
2009-03-10 20:27:41 +00:00
"login status" ,
"Display status of logins" , HandleLoginStatus ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "restart" ,
2009-03-10 20:27:41 +00:00
"restart" ,
"Restart all sims in this instance" , RunCommand ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "config set" ,
2009-03-10 20:27:41 +00:00
"config set <section> <field> <value>" ,
"Set a config option" , HandleConfig ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "config get" ,
2009-03-10 20:27:41 +00:00
"config get <section> <field>" ,
"Read a config option" , HandleConfig ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "config save" ,
2009-03-10 20:27:41 +00:00
"config save" ,
"Save current configuration" , HandleConfig ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "command-script" ,
2009-03-10 20:27:41 +00:00
"command-script <script>" ,
"Run a command script from file" , RunCommand ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "remove-region" ,
2009-03-10 20:27:41 +00:00
"remove-region <name>" ,
"Remove a region from this simulator" , RunCommand ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "delete-region" ,
2009-03-10 20:27:41 +00:00
"delete-region <name>" ,
"Delete a region from disk" , RunCommand ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "modules list" ,
2009-03-10 20:27:41 +00:00
"modules list" ,
"List modules" , HandleModules ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "modules load" ,
2009-03-10 20:27:41 +00:00
"modules load <name>" ,
"Load a module" , HandleModules ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "modules unload" ,
2009-03-10 20:27:41 +00:00
"modules unload <name>" ,
"Unload a module" , HandleModules ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "Add-InventoryHost" ,
2009-03-10 20:27:41 +00:00
"Add-InventoryHost <host>" ,
String . Empty , RunCommand ) ;
2009-02-07 12:25:39 +00:00
2009-10-23 14:11:25 +00:00
m_console . Commands . AddCommand ( "region" , false , "killuuid" ,
"killuuid <UUID>" ,
"kill an object by UUID" , KillUUID ) ;
2009-02-07 12:25:39 +00:00
if ( ConfigurationSettings . Standalone )
{
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "create user" ,
2009-03-10 20:27:41 +00:00
"create user [<first> [<last> [<pass> [<x> <y> [<email>]]]]]" ,
"Create a new user" , HandleCreateUser ) ;
2009-02-07 12:25:39 +00:00
2009-02-10 23:15:48 +00:00
m_console . Commands . AddCommand ( "region" , false , "reset user password" ,
2009-03-10 20:27:41 +00:00
"reset user password [<first> [<last> [<password>]]]" ,
"Reset a user password" , HandleResetUserPassword ) ;
2009-02-07 12:25:39 +00:00
}
2009-04-27 00:16:59 +00:00
m_console . Commands . AddCommand ( "hypergrid" , false , "link-mapping" , "link-mapping [<x> <y>] <cr>" ,
"Set local coordinate to map HG regions to" , RunCommand ) ;
m_console . Commands . AddCommand ( "hypergrid" , false , "link-region" ,
"link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>" ,
"Link a hypergrid region" , RunCommand ) ;
m_console . Commands . AddCommand ( "hypergrid" , false , "unlink-region" ,
"unlink-region <local name> or <HostName>:<HttpPort> <cr>" ,
"Unlink a hypergrid region" , RunCommand ) ;
2008-04-28 14:41:46 +00:00
}
2008-12-11 14:31:58 +00:00
public override void ShutdownSpecific ( )
{
if ( m_shutdownCommandsFile ! = String . Empty )
{
RunCommandScript ( m_shutdownCommandsFile ) ;
}
base . ShutdownSpecific ( ) ;
}
2009-01-12 15:34:05 +00:00
2009-08-13 02:54:57 +00:00
/// <summary>
/// Timer to run a specific text file as console commands. Configured in in the main ini file
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
2008-04-28 14:41:46 +00:00
private void RunAutoTimerScript ( object sender , EventArgs e )
{
if ( m_timedScript ! = "disabled" )
{
RunCommandScript ( m_timedScript ) ;
}
}
2009-10-22 19:33:23 +00:00
private void WatchdogTimeoutHandler ( System . Threading . Thread thread , int lastTick )
{
int now = Environment . TickCount & Int32 . MaxValue ;
m_log . ErrorFormat ( "[WATCHDOG]: Timeout detected for thread \"{0}\". ThreadState={1}. Last tick was {2}ms ago" ,
thread . Name , thread . ThreadState , now - lastTick ) ;
}
2008-04-28 14:41:46 +00:00
#region Console Commands
2009-08-13 02:54:57 +00:00
/// <summary>
/// Kicks users off the region
/// </summary>
/// <param name="module"></param>
/// <param name="cmdparams">name of avatar to kick</param>
2009-02-09 16:34:21 +00:00
private void KickUserCommand ( string module , string [ ] cmdparams )
{
if ( cmdparams . Length < 4 )
return ;
2009-03-25 18:04:33 +00:00
string alert = null ;
if ( cmdparams . Length > 4 )
2009-03-25 18:48:30 +00:00
alert = String . Format ( "\n{0}\n" , String . Join ( " " , cmdparams , 4 , cmdparams . Length - 4 ) ) ;
2009-03-25 18:04:33 +00:00
2009-02-09 16:34:21 +00:00
IList agents = m_sceneManager . GetCurrentSceneAvatars ( ) ;
foreach ( ScenePresence presence in agents )
{
RegionInfo regionInfo = m_sceneManager . GetRegionInfo ( presence . RegionHandle ) ;
2009-03-10 20:27:41 +00:00
if ( presence . Firstname . ToLower ( ) . Contains ( cmdparams [ 2 ] . ToLower ( ) ) & &
presence . Lastname . ToLower ( ) . Contains ( cmdparams [ 3 ] . ToLower ( ) ) )
2009-02-09 16:34:21 +00:00
{
2009-05-20 13:50:33 +00:00
m_log . Info (
2009-02-09 16:34:21 +00:00
String . Format (
2009-03-10 20:27:41 +00:00
"Kicking user: {0,-16}{1,-16}{2,-37} in region: {3,-16}" ,
2009-03-25 18:48:30 +00:00
presence . Firstname , presence . Lastname , presence . UUID , regionInfo . RegionName ) ) ;
2009-02-09 16:34:21 +00:00
2009-03-25 18:48:30 +00:00
// kick client...
if ( alert ! = null )
presence . ControllingClient . Kick ( alert ) ;
else
presence . ControllingClient . Kick ( "\nThe OpenSim manager kicked you out.\n" ) ;
// ...and close on our side
2009-02-09 16:34:21 +00:00
presence . Scene . IncomingCloseAgent ( presence . UUID ) ;
}
}
2009-05-20 13:50:33 +00:00
m_log . Info ( "" ) ;
2009-02-09 16:34:21 +00:00
}
2008-06-22 05:08:58 +00:00
2008-04-28 14:41:46 +00:00
/// <summary>
2008-11-28 21:09:20 +00:00
/// Run an optional startup list of commands
2008-04-28 14:41:46 +00:00
/// </summary>
/// <param name="fileName"></param>
private void RunCommandScript ( string fileName )
2009-01-12 15:34:05 +00:00
{
2008-04-28 14:41:46 +00:00
if ( File . Exists ( fileName ) )
{
2008-11-28 21:09:20 +00:00
m_log . Info ( "[COMMANDFILE]: Running " + fileName ) ;
2009-01-12 15:34:05 +00:00
2009-09-11 20:52:49 +00:00
using ( StreamReader readFile = File . OpenText ( fileName ) )
2008-04-28 14:41:46 +00:00
{
2009-09-11 20:52:49 +00:00
string currentCommand ;
while ( ( currentCommand = readFile . ReadLine ( ) ) ! = null )
2008-04-28 14:41:46 +00:00
{
2009-09-11 20:52:49 +00:00
if ( currentCommand ! = String . Empty )
{
m_log . Info ( "[COMMANDFILE]: Running '" + currentCommand + "'" ) ;
m_console . RunCommand ( currentCommand ) ;
}
2008-04-28 14:41:46 +00:00
}
}
}
}
2009-08-13 02:54:57 +00:00
/// <summary>
/// Opens a file and uses it as input to the console command parser.
/// </summary>
/// <param name="fileName">name of file to use as input to the console</param>
2008-05-01 16:03:53 +00:00
private static void PrintFileToConsole ( string fileName )
2008-04-28 14:41:46 +00:00
{
if ( File . Exists ( fileName ) )
{
StreamReader readFile = File . OpenText ( fileName ) ;
2008-05-02 16:41:08 +00:00
string currentLine ;
2008-04-28 14:41:46 +00:00
while ( ( currentLine = readFile . ReadLine ( ) ) ! = null )
{
m_log . Info ( "[!]" + currentLine ) ;
}
}
}
2009-02-07 12:25:39 +00:00
private void HandleClearAssets ( string module , string [ ] args )
2008-04-28 14:41:46 +00:00
{
2009-08-10 15:14:57 +00:00
m_log . Info ( "Not implemented." ) ;
2009-02-07 12:25:39 +00:00
}
2008-04-28 14:41:46 +00:00
2009-08-13 02:54:57 +00:00
/// <summary>
/// Force resending of all updates to all clients in active region(s)
/// </summary>
/// <param name="module"></param>
/// <param name="args"></param>
2009-02-07 12:25:39 +00:00
private void HandleForceUpdate ( string module , string [ ] args )
{
2009-05-20 13:50:33 +00:00
m_log . Info ( "Updating all clients" ) ;
2009-02-07 12:25:39 +00:00
m_sceneManager . ForceCurrentSceneClientUpdate ( ) ;
}
2008-05-25 23:27:38 +00:00
2009-08-13 02:54:57 +00:00
/// <summary>
/// Edits the scale of a primative with the name specified
/// </summary>
/// <param name="module"></param>
/// <param name="args">0,1, name, x, y, z</param>
2009-02-07 12:25:39 +00:00
private void HandleEditScale ( string module , string [ ] args )
{
2009-03-24 19:04:28 +00:00
if ( args . Length = = 6 )
2009-02-07 12:25:39 +00:00
{
m_sceneManager . HandleEditCommandOnCurrentScene ( args ) ;
}
else
{
2009-05-20 13:50:33 +00:00
m_log . Info ( "Argument error: edit scale <prim name> <x> <y> <z>" ) ;
2009-02-07 12:25:39 +00:00
}
}
2008-07-01 19:23:45 +00:00
2009-08-13 02:54:57 +00:00
/// <summary>
/// Creates a new region based on the parameters specified. This will ask the user questions on the console
/// </summary>
/// <param name="module"></param>
/// <param name="cmd">0,1,region name, region XML file</param>
2009-02-07 12:25:39 +00:00
private void HandleCreateRegion ( string module , string [ ] cmd )
{
2009-06-25 23:31:55 +00:00
if ( cmd . Length < 4 )
{
2009-09-30 08:12:43 +00:00
m_log . Error ( "Usage: create region <region name> <region_file.ini>" ) ;
2009-06-25 23:31:55 +00:00
return ;
}
if ( cmd [ 3 ] . EndsWith ( ".xml" ) )
{
string regionsDir = ConfigSource . Source . Configs [ "Startup" ] . GetString ( "regionload_regionsdir" , "Regions" ) . Trim ( ) ;
string regionFile = String . Format ( "{0}/{1}" , regionsDir , cmd [ 3 ] ) ;
// Allow absolute and relative specifiers
if ( cmd [ 3 ] . StartsWith ( "/" ) | | cmd [ 3 ] . StartsWith ( "\\" ) | | cmd [ 3 ] . StartsWith ( ".." ) )
regionFile = cmd [ 3 ] ;
IScene scene ;
CreateRegion ( new RegionInfo ( cmd [ 2 ] , regionFile , false , ConfigSource . Source ) , true , out scene ) ;
}
else if ( cmd [ 3 ] . EndsWith ( ".ini" ) )
{
string regionsDir = ConfigSource . Source . Configs [ "Startup" ] . GetString ( "regionload_regionsdir" , "Regions" ) . Trim ( ) ;
string regionFile = String . Format ( "{0}/{1}" , regionsDir , cmd [ 3 ] ) ;
// Allow absolute and relative specifiers
if ( cmd [ 3 ] . StartsWith ( "/" ) | | cmd [ 3 ] . StartsWith ( "\\" ) | | cmd [ 3 ] . StartsWith ( ".." ) )
regionFile = cmd [ 3 ] ;
IScene scene ;
CreateRegion ( new RegionInfo ( cmd [ 2 ] , regionFile , false , ConfigSource . Source , cmd [ 2 ] ) , true , out scene ) ;
}
else
2009-02-07 12:25:39 +00:00
{
2009-09-30 08:12:43 +00:00
m_log . Error ( "Usage: create region <region name> <region_file.ini>" ) ;
2009-02-07 12:25:39 +00:00
return ;
}
}
2008-04-28 14:41:46 +00:00
2009-08-13 02:54:57 +00:00
/// <summary>
/// Enable logins
/// </summary>
/// <param name="module"></param>
/// <param name="cmd"></param>
2009-02-07 12:25:39 +00:00
private void HandleLoginEnable ( string module , string [ ] cmd )
{
ProcessLogin ( true ) ;
}
2008-09-29 14:41:16 +00:00
2009-08-13 02:54:57 +00:00
/// <summary>
/// Disable logins
/// </summary>
/// <param name="module"></param>
/// <param name="cmd"></param>
2009-02-07 12:25:39 +00:00
private void HandleLoginDisable ( string module , string [ ] cmd )
{
ProcessLogin ( false ) ;
}
2008-04-28 14:41:46 +00:00
2009-08-13 02:54:57 +00:00
/// <summary>
/// Log login status to the console
/// </summary>
/// <param name="module"></param>
/// <param name="cmd"></param>
2009-02-07 12:25:39 +00:00
private void HandleLoginStatus ( string module , string [ ] cmd )
{
2009-09-25 15:39:09 +00:00
if ( m_sceneManager . CurrentOrFirstScene . SceneGridService . RegionLoginsEnabled = = false )
2008-04-28 14:41:46 +00:00
2009-02-07 12:25:39 +00:00
m_log . Info ( "[ Login ] Login are disabled " ) ;
else
m_log . Info ( "[ Login ] Login are enabled" ) ;
}
2008-04-28 14:41:46 +00:00
2009-08-13 02:54:57 +00:00
/// <summary>
/// Change and load configuration file data.
/// </summary>
/// <param name="module"></param>
/// <param name="cmd"></param>
2009-02-07 12:25:39 +00:00
private void HandleConfig ( string module , string [ ] cmd )
{
List < string > args = new List < string > ( cmd ) ;
args . RemoveAt ( 0 ) ;
string [ ] cmdparams = args . ToArray ( ) ;
string n = "CONFIG" ;
2008-04-28 14:41:46 +00:00
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length > 0 )
{
switch ( cmdparams [ 0 ] . ToLower ( ) )
{
case "set" :
if ( cmdparams . Length < 4 )
{
2009-05-20 13:50:33 +00:00
m_log . Error ( "SYNTAX: " + n + " SET SECTION KEY VALUE" ) ;
m_log . Error ( "EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5" ) ;
2009-02-07 12:25:39 +00:00
}
else
{
IConfig c ;
IConfigSource source = new IniConfigSource ( ) ;
c = source . AddConfig ( cmdparams [ 1 ] ) ;
if ( c ! = null )
{
string _value = String . Join ( " " , cmdparams , 3 , cmdparams . Length - 3 ) ;
c . Set ( cmdparams [ 2 ] , _value ) ;
m_config . Source . Merge ( source ) ;
2008-04-28 14:41:46 +00:00
2009-05-20 13:50:33 +00:00
m_log . Error ( n + " " + n + " " + cmdparams [ 1 ] + " " + cmdparams [ 2 ] + " " +
2009-03-10 20:27:41 +00:00
_value ) ;
2009-02-07 12:25:39 +00:00
}
}
break ;
2009-03-10 20:27:41 +00:00
2009-02-07 12:25:39 +00:00
case "get" :
if ( cmdparams . Length < 3 )
{
2009-05-20 13:50:33 +00:00
m_log . Error ( "SYNTAX: " + n + " GET SECTION KEY" ) ;
m_log . Error ( "EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads" ) ;
2009-02-07 12:25:39 +00:00
}
else
{
2009-05-21 23:06:10 +00:00
IConfig c = m_config . Source . Configs [ cmdparams [ 1 ] ] ;
2009-02-07 12:25:39 +00:00
if ( c = = null )
{
2009-05-20 13:50:33 +00:00
m_log . Info ( "Section \"" + cmdparams [ 1 ] + "\" does not exist." ) ;
2009-02-07 12:25:39 +00:00
break ;
}
else
{
2009-05-20 13:50:33 +00:00
m_log . Info ( n + " GET " + cmdparams [ 1 ] + " " + cmdparams [ 2 ] + ": " +
2009-02-07 12:25:39 +00:00
c . GetString ( cmdparams [ 2 ] ) ) ;
}
}
2008-11-24 09:53:49 +00:00
2009-01-12 15:34:05 +00:00
break ;
2009-03-10 20:27:41 +00:00
2009-02-07 12:25:39 +00:00
case "save" :
2009-10-20 13:02:11 +00:00
if ( cmdparams . Length < 2 )
{
m_log . Error ( "SYNTAX: " + n + " SAVE FILE" ) ;
return ;
}
if ( Application . iniFilePath = = cmdparams [ 1 ] )
{
m_log . Error ( "FILE can not be " + Application . iniFilePath ) ;
return ;
}
m_log . Info ( "Saving configuration file: " + cmdparams [ 1 ] ) ;
m_config . Save ( cmdparams [ 1 ] ) ;
2009-02-07 12:25:39 +00:00
break ;
}
}
}
2009-01-12 15:34:05 +00:00
2009-08-13 02:54:57 +00:00
/// <summary>
/// Load, Unload, and list Region modules in use
/// </summary>
/// <param name="module"></param>
/// <param name="cmd"></param>
2009-02-07 12:25:39 +00:00
private void HandleModules ( string module , string [ ] cmd )
{
List < string > args = new List < string > ( cmd ) ;
args . RemoveAt ( 0 ) ;
string [ ] cmdparams = args . ToArray ( ) ;
2008-09-30 10:50:41 +00:00
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length > 0 )
{
switch ( cmdparams [ 0 ] . ToLower ( ) )
{
case "list" :
foreach ( IRegionModule irm in m_moduleLoader . GetLoadedSharedModules )
{
2009-05-20 13:50:33 +00:00
m_log . Info ( "Shared region module: " + irm . Name ) ;
2009-02-07 12:25:39 +00:00
}
break ;
case "unload" :
if ( cmdparams . Length > 1 )
{
foreach ( IRegionModule rm in new ArrayList ( m_moduleLoader . GetLoadedSharedModules ) )
{
if ( rm . Name . ToLower ( ) = = cmdparams [ 1 ] . ToLower ( ) )
{
2009-05-20 13:50:33 +00:00
m_log . Info ( "Unloading module: " + rm . Name ) ;
2009-02-07 12:25:39 +00:00
m_moduleLoader . UnloadModule ( rm ) ;
}
}
}
break ;
case "load" :
if ( cmdparams . Length > 1 )
{
foreach ( Scene s in new ArrayList ( m_sceneManager . Scenes ) )
{
2009-05-20 13:50:33 +00:00
m_log . Info ( "Loading module: " + cmdparams [ 1 ] ) ;
2009-02-07 12:25:39 +00:00
m_moduleLoader . LoadRegionModules ( cmdparams [ 1 ] , s ) ;
}
}
break ;
}
}
}
2008-04-28 14:41:46 +00:00
2009-02-07 12:25:39 +00:00
/// <summary>
/// Runs commands issued by the server console from the operator
/// </summary>
/// <param name="command">The first argument of the parameter (the command)</param>
/// <param name="cmdparams">Additional arguments passed to the command</param>
public void RunCommand ( string module , string [ ] cmdparams )
{
List < string > args = new List < string > ( cmdparams ) ;
if ( args . Count < 1 )
return ;
2008-09-18 15:44:05 +00:00
2009-02-07 12:25:39 +00:00
string command = args [ 0 ] ;
args . RemoveAt ( 0 ) ;
2008-04-28 14:41:46 +00:00
2009-02-07 12:25:39 +00:00
cmdparams = args . ToArray ( ) ;
2008-04-28 14:41:46 +00:00
2009-02-07 12:25:39 +00:00
switch ( command )
{
2009-03-10 20:27:41 +00:00
case "command-script" :
if ( cmdparams . Length > 0 )
{
RunCommandScript ( cmdparams [ 0 ] ) ;
}
break ;
2008-04-28 14:41:46 +00:00
2009-03-10 20:27:41 +00:00
case "backup" :
m_sceneManager . BackupCurrentScene ( ) ;
break ;
case "remove-region" :
string regRemoveName = CombineParams ( cmdparams , 0 ) ;
Scene removeScene ;
if ( m_sceneManager . TryGetScene ( regRemoveName , out removeScene ) )
RemoveRegion ( removeScene , false ) ;
else
2009-05-20 13:50:33 +00:00
m_log . Error ( "no region with that name" ) ;
2009-03-10 20:27:41 +00:00
break ;
case "delete-region" :
string regDeleteName = CombineParams ( cmdparams , 0 ) ;
Scene killScene ;
if ( m_sceneManager . TryGetScene ( regDeleteName , out killScene ) )
RemoveRegion ( killScene , true ) ;
else
2009-05-20 13:50:33 +00:00
m_log . Error ( "no region with that name" ) ;
2009-03-10 20:27:41 +00:00
break ;
case "restart" :
m_sceneManager . RestartCurrentScene ( ) ;
break ;
case "Add-InventoryHost" :
if ( cmdparams . Length > 0 )
{
2009-08-10 17:48:21 +00:00
m_log . Info ( "Not implemented." ) ;
2009-03-10 20:27:41 +00:00
}
break ;
2008-04-28 14:41:46 +00:00
}
}
2008-08-18 00:39:10 +00:00
2008-08-05 17:00:35 +00:00
/// <summary>
2008-08-05 17:03:06 +00:00
/// Change the currently selected region. The selected region is that operated upon by single region commands.
2008-08-05 17:00:35 +00:00
/// </summary>
/// <param name="cmdParams"></param>
2009-02-07 12:25:39 +00:00
protected void ChangeSelectedRegion ( string module , string [ ] cmdparams )
2008-08-05 17:00:35 +00:00
{
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length > 2 )
2008-08-05 17:00:35 +00:00
{
2009-02-07 12:25:39 +00:00
string newRegionName = CombineParams ( cmdparams , 2 ) ;
2008-08-05 17:00:35 +00:00
2008-08-05 17:52:06 +00:00
if ( ! m_sceneManager . TrySetCurrentScene ( newRegionName ) )
2009-05-20 13:50:33 +00:00
m_log . Error ( "Couldn't select region " + newRegionName ) ;
2008-08-05 17:00:35 +00:00
}
2008-08-05 17:52:06 +00:00
else
{
2009-05-20 13:50:33 +00:00
m_log . Error ( "Usage: change region <region name>" ) ;
2008-08-18 00:39:10 +00:00
}
2008-08-05 17:52:06 +00:00
2008-08-18 00:39:10 +00:00
string regionName = ( m_sceneManager . CurrentScene = = null ? "root" : m_sceneManager . CurrentScene . RegionInfo . RegionName ) ;
2009-05-20 13:50:33 +00:00
m_log . Info ( String . Format ( "Currently selected region is {0}" , regionName ) ) ;
2008-08-18 00:39:10 +00:00
m_console . DefaultPrompt = String . Format ( "Region ({0}) " , regionName ) ;
2009-02-07 12:25:39 +00:00
m_console . ConsoleScene = m_sceneManager . CurrentScene ;
2008-08-05 17:00:35 +00:00
}
2008-08-18 00:39:10 +00:00
2008-07-29 17:39:15 +00:00
/// <summary>
/// Execute switch for some of the create commands
/// </summary>
/// <param name="args"></param>
2009-02-07 12:25:39 +00:00
private void HandleCreateUser ( string module , string [ ] cmd )
2008-07-29 17:39:15 +00:00
{
2009-02-07 12:25:39 +00:00
if ( ConfigurationSettings . Standalone )
2008-07-29 17:39:15 +00:00
{
2009-02-07 12:25:39 +00:00
CreateUser ( cmd ) ;
}
else
{
2009-05-20 13:50:33 +00:00
m_log . Info ( "Create user is not available in grid mode, use the user server." ) ;
2008-07-29 17:39:15 +00:00
}
}
2009-01-12 15:34:05 +00:00
2008-09-15 17:29:11 +00:00
/// <summary>
/// Execute switch for some of the reset commands
/// </summary>
/// <param name="args"></param>
2009-02-07 12:25:39 +00:00
protected void HandleResetUserPassword ( string module , string [ ] cmd )
2008-09-15 17:29:11 +00:00
{
2009-02-07 12:25:39 +00:00
if ( ConfigurationSettings . Standalone )
2008-09-15 17:29:11 +00:00
{
2009-02-07 12:25:39 +00:00
ResetUserPassword ( cmd ) ;
}
else
{
2009-05-20 13:50:33 +00:00
m_log . Info ( "Reset user password is not available in grid mode, use the user-server." ) ;
2008-09-15 17:29:11 +00:00
}
2009-01-12 15:34:05 +00:00
}
2008-04-28 14:41:46 +00:00
2008-07-12 19:47:45 +00:00
/// <summary>
/// Turn on some debugging values for OpenSim.
/// </summary>
/// <param name="args"></param>
2009-02-07 12:25:39 +00:00
protected void Debug ( string module , string [ ] args )
2008-04-28 14:41:46 +00:00
{
2009-02-07 12:25:39 +00:00
if ( args . Length = = 1 )
2008-07-12 19:47:45 +00:00
return ;
2008-08-18 00:39:10 +00:00
2009-02-07 12:25:39 +00:00
switch ( args [ 1 ] )
2008-04-28 14:41:46 +00:00
{
case "packet" :
2009-02-07 12:25:39 +00:00
if ( args . Length > 2 )
2008-04-28 14:41:46 +00:00
{
int newDebug ;
2009-02-07 12:25:39 +00:00
if ( int . TryParse ( args [ 2 ] , out newDebug ) )
2008-04-28 14:41:46 +00:00
{
2008-10-14 18:53:56 +00:00
m_sceneManager . SetDebugPacketLevelOnCurrentScene ( newDebug ) ;
2008-04-28 14:41:46 +00:00
}
else
{
2009-05-20 13:50:33 +00:00
m_log . Error ( "packet debug should be 0..255" ) ;
2008-04-28 14:41:46 +00:00
}
2009-05-20 13:50:33 +00:00
m_log . Info ( "New packet debug: " + newDebug . ToString ( ) ) ;
2008-04-28 14:41:46 +00:00
}
break ;
2008-08-18 00:39:10 +00:00
2008-07-12 20:04:31 +00:00
case "scene" :
2009-02-07 12:25:39 +00:00
if ( args . Length = = 5 )
2008-07-12 20:04:31 +00:00
{
if ( m_sceneManager . CurrentScene = = null )
{
2009-05-20 13:50:33 +00:00
m_log . Info ( "Please use 'change region <regioname>' first" ) ;
2008-07-12 20:04:31 +00:00
}
else
{
2009-02-07 12:25:39 +00:00
bool scriptingOn = ! Convert . ToBoolean ( args [ 2 ] ) ;
bool collisionsOn = ! Convert . ToBoolean ( args [ 3 ] ) ;
bool physicsOn = ! Convert . ToBoolean ( args [ 4 ] ) ;
2008-07-12 20:04:31 +00:00
m_sceneManager . CurrentScene . SetSceneCoreDebug ( scriptingOn , collisionsOn , physicsOn ) ;
2008-08-18 00:39:10 +00:00
2009-05-20 13:50:33 +00:00
m_log . Info (
2008-07-12 20:04:31 +00:00
String . Format (
2008-08-18 00:39:10 +00:00
"Set debug scene scripting = {0}, collisions = {1}, physics = {2}" ,
2008-07-12 20:04:31 +00:00
! scriptingOn , ! collisionsOn , ! physicsOn ) ) ;
}
}
else
{
2009-05-20 13:50:33 +00:00
m_log . Error ( "debug scene <scripting> <collisions> <physics> (where inside <> is true/false)" ) ;
2008-07-12 20:04:31 +00:00
}
2008-08-18 00:39:10 +00:00
break ;
2008-04-28 14:41:46 +00:00
default :
2009-05-20 13:50:33 +00:00
m_log . Error ( "Unknown debug" ) ;
2008-04-28 14:41:46 +00:00
break ;
}
}
2008-08-19 02:59:27 +00:00
2008-04-28 14:41:46 +00:00
// see BaseOpenSimServer
2009-08-13 02:54:57 +00:00
/// <summary>
/// Many commands list objects for debugging. Some of the types are listed here
/// </summary>
/// <param name="mod"></param>
/// <param name="cmd"></param>
2009-03-10 20:27:41 +00:00
public override void HandleShow ( string mod , string [ ] cmd )
2008-04-28 14:41:46 +00:00
{
2009-02-09 18:11:09 +00:00
base . HandleShow ( mod , cmd ) ;
2009-03-10 20:27:41 +00:00
2009-02-07 12:25:39 +00:00
List < string > args = new List < string > ( cmd ) ;
args . RemoveAt ( 0 ) ;
string [ ] showParams = args . ToArray ( ) ;
2008-05-16 01:22:11 +00:00
2008-09-12 22:39:17 +00:00
switch ( showParams [ 0 ] )
2008-04-28 14:41:46 +00:00
{
case "assets" :
2009-08-10 15:14:57 +00:00
m_log . Info ( "Not implemented." ) ;
2008-04-28 14:41:46 +00:00
break ;
2009-01-12 15:34:05 +00:00
2008-05-22 04:55:23 +00:00
case "users" :
2008-09-12 22:39:17 +00:00
IList agents ;
if ( showParams . Length > 1 & & showParams [ 1 ] = = "full" )
{
agents = m_sceneManager . GetCurrentScenePresences ( ) ;
}
else
{
agents = m_sceneManager . GetCurrentSceneAvatars ( ) ;
}
2008-05-25 23:27:38 +00:00
2009-05-20 13:50:33 +00:00
m_log . Info ( String . Format ( "\nAgents connected: {0}\n" , agents . Count ) ) ;
2008-05-25 23:27:38 +00:00
2009-05-20 13:50:33 +00:00
m_log . Info (
2008-09-03 03:32:29 +00:00
String . Format ( "{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}" , "Firstname" , "Lastname" ,
"Agent ID" , "Root/Child" , "Region" ) ) ;
2008-05-22 04:55:23 +00:00
foreach ( ScenePresence presence in agents )
{
RegionInfo regionInfo = m_sceneManager . GetRegionInfo ( presence . RegionHandle ) ;
string regionName ;
if ( regionInfo = = null )
{
regionName = "Unresolvable" ;
}
else
{
regionName = regionInfo . RegionName ;
}
2009-05-20 13:50:33 +00:00
m_log . Info (
2008-05-22 04:55:23 +00:00
String . Format (
2008-09-03 03:32:29 +00:00
"{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}" ,
presence . Firstname ,
presence . Lastname ,
presence . UUID ,
presence . IsChildAgent ? "Child" : "Root" ,
regionName ) ) ;
2008-05-22 04:55:23 +00:00
}
2008-05-25 23:27:38 +00:00
2009-10-14 20:00:42 +00:00
m_log . Info ( String . Empty ) ;
break ;
case "connections" :
System . Text . StringBuilder connections = new System . Text . StringBuilder ( "Connections:\n" ) ;
m_sceneManager . ForEachScene (
delegate ( Scene scene )
{
2009-10-26 23:48:43 +00:00
scene . ForEachClient (
2009-10-14 20:00:42 +00:00
delegate ( IClientAPI client )
{
connections . AppendFormat ( "{0}: {1} ({2}) from {3} on circuit {4}\n" ,
scene . RegionInfo . RegionName , client . Name , client . AgentId , client . RemoteEndPoint , client . CircuitCode ) ;
2009-10-26 23:48:43 +00:00
} , false
2009-10-14 20:00:42 +00:00
) ;
}
) ;
m_log . Info ( connections . ToString ( ) ) ;
2008-05-22 04:55:23 +00:00
break ;
2008-04-28 14:41:46 +00:00
case "modules" :
2009-05-20 13:50:33 +00:00
m_log . Info ( "The currently loaded shared modules are:" ) ;
2008-04-28 14:41:46 +00:00
foreach ( IRegionModule module in m_moduleLoader . GetLoadedSharedModules )
{
2009-05-20 13:50:33 +00:00
m_log . Info ( "Shared Module: " + module . Name ) ;
2008-04-28 14:41:46 +00:00
}
break ;
case "regions" :
m_sceneManager . ForEachScene (
delegate ( Scene scene )
2009-03-10 20:27:41 +00:00
{
2009-05-20 13:50:33 +00:00
m_log . Info ( "Region Name: " + scene . RegionInfo . RegionName + " , Region XLoc: " +
2009-03-10 20:27:41 +00:00
scene . RegionInfo . RegionLocX + " , Region YLoc: " +
scene . RegionInfo . RegionLocY + " , Region Port: " +
scene . RegionInfo . InternalEndPoint . Port . ToString ( ) ) ;
} ) ;
2008-04-28 14:41:46 +00:00
break ;
2008-12-18 13:16:41 +00:00
case "queues" :
Notice ( GetQueuesReport ( ) ) ;
break ;
2009-05-12 03:35:07 +00:00
case "ratings" :
m_sceneManager . ForEachScene (
delegate ( Scene scene )
{
string rating = "" ;
if ( scene . RegionInfo . RegionSettings . Maturity = = 1 )
{
rating = "MATURE" ;
}
else if ( scene . RegionInfo . RegionSettings . Maturity = = 2 )
{
rating = "ADULT" ;
}
else
{
rating = "PG" ;
}
2009-05-20 13:50:33 +00:00
m_log . Info ( "Region Name: " + scene . RegionInfo . RegionName + " , Region Rating: " +
2009-05-12 03:35:07 +00:00
rating ) ;
} ) ;
break ;
2008-04-28 14:41:46 +00:00
}
}
2008-08-18 00:39:10 +00:00
2009-08-13 02:54:57 +00:00
/// <summary>
/// print UDP Queue data for each client
/// </summary>
/// <returns></returns>
2008-12-18 13:16:41 +00:00
private string GetQueuesReport ( )
{
string report = String . Empty ;
m_sceneManager . ForEachScene ( delegate ( Scene scene )
{
scene . ForEachClient ( delegate ( IClientAPI client )
{
if ( client is IStatsCollector )
{
report = report + client . FirstName +
" " + client . LastName + "\n" ;
IStatsCollector stats =
( IStatsCollector ) client ;
report = report + string . Format ( "{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}\n" ,
2009-03-10 20:27:41 +00:00
"Send" ,
"In" ,
"Out" ,
"Resend" ,
"Land" ,
"Wind" ,
"Cloud" ,
"Task" ,
"Texture" ,
"Asset" ) ;
2008-12-18 13:16:41 +00:00
report = report + stats . Report ( ) +
"\n\n" ;
}
} ) ;
} ) ;
return report ;
}
2008-07-29 17:39:15 +00:00
/// <summary>
/// Create a new user
/// </summary>
2008-11-23 03:38:40 +00:00
/// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
2008-07-29 17:39:15 +00:00
protected void CreateUser ( string [ ] cmdparams )
{
string firstName ;
string lastName ;
string password ;
2008-11-23 03:38:40 +00:00
string email ;
2008-07-29 17:39:15 +00:00
uint regX = 1000 ;
uint regY = 1000 ;
2009-09-09 18:02:31 +00:00
IConfig standalone ;
if ( ( standalone = m_config . Source . Configs [ "StandAlone" ] ) ! = null )
{
regX = ( uint ) standalone . GetInt ( "default_location_x" , ( int ) regX ) ;
regY = ( uint ) standalone . GetInt ( "default_location_y" , ( int ) regY ) ;
}
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length < 3 )
2008-07-29 17:39:15 +00:00
firstName = MainConsole . Instance . CmdPrompt ( "First name" , "Default" ) ;
2009-02-07 12:25:39 +00:00
else firstName = cmdparams [ 2 ] ;
2008-07-29 17:39:15 +00:00
2009-03-10 20:27:41 +00:00
if ( cmdparams . Length < 4 )
2008-07-29 17:39:15 +00:00
lastName = MainConsole . Instance . CmdPrompt ( "Last name" , "User" ) ;
2009-02-07 12:25:39 +00:00
else lastName = cmdparams [ 3 ] ;
2008-07-29 17:39:15 +00:00
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length < 5 )
2008-07-29 17:39:15 +00:00
password = MainConsole . Instance . PasswdPrompt ( "Password" ) ;
2009-02-07 12:25:39 +00:00
else password = cmdparams [ 4 ] ;
2008-07-29 17:39:15 +00:00
2009-03-10 20:27:41 +00:00
if ( cmdparams . Length < 6 )
2008-07-29 17:39:15 +00:00
regX = Convert . ToUInt32 ( MainConsole . Instance . CmdPrompt ( "Start Region X" , regX . ToString ( ) ) ) ;
2009-02-07 12:25:39 +00:00
else regX = Convert . ToUInt32 ( cmdparams [ 5 ] ) ;
2008-07-29 17:39:15 +00:00
2009-03-10 20:27:41 +00:00
if ( cmdparams . Length < 7 )
2008-07-29 17:39:15 +00:00
regY = Convert . ToUInt32 ( MainConsole . Instance . CmdPrompt ( "Start Region Y" , regY . ToString ( ) ) ) ;
2009-02-07 12:25:39 +00:00
else regY = Convert . ToUInt32 ( cmdparams [ 6 ] ) ;
2008-07-29 17:39:15 +00:00
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length < 8 )
2008-11-23 03:38:40 +00:00
email = MainConsole . Instance . CmdPrompt ( "Email" , "" ) ;
2009-02-07 12:25:39 +00:00
else email = cmdparams [ 7 ] ;
2008-11-23 03:38:40 +00:00
2009-04-17 16:06:35 +00:00
if ( null = = m_commsManager . UserProfileCacheService . GetUserDetails ( firstName , lastName ) )
2008-07-29 17:39:15 +00:00
{
2008-11-28 16:04:01 +00:00
m_commsManager . UserAdminService . AddUser ( firstName , lastName , password , email , regX , regY ) ;
2008-07-29 17:39:15 +00:00
}
else
{
m_log . ErrorFormat ( "[CONSOLE]: A user with the name {0} {1} already exists!" , firstName , lastName ) ;
2008-08-18 00:39:10 +00:00
}
2008-07-29 17:39:15 +00:00
}
2009-01-12 15:34:05 +00:00
2008-09-15 17:29:11 +00:00
/// <summary>
/// Reset a user password.
/// </summary>
/// <param name="cmdparams"></param>
private void ResetUserPassword ( string [ ] cmdparams )
{
string firstName ;
string lastName ;
string newPassword ;
2009-01-12 15:34:05 +00:00
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length < 4 )
2008-09-15 17:29:11 +00:00
firstName = MainConsole . Instance . CmdPrompt ( "First name" ) ;
2009-02-07 12:25:39 +00:00
else firstName = cmdparams [ 3 ] ;
2008-09-15 17:29:11 +00:00
2009-03-10 20:27:41 +00:00
if ( cmdparams . Length < 5 )
2008-09-15 17:29:11 +00:00
lastName = MainConsole . Instance . CmdPrompt ( "Last name" ) ;
2009-02-07 12:25:39 +00:00
else lastName = cmdparams [ 4 ] ;
2008-09-15 17:29:11 +00:00
2009-03-10 20:27:41 +00:00
if ( cmdparams . Length < 6 )
2008-09-15 17:29:11 +00:00
newPassword = MainConsole . Instance . PasswdPrompt ( "New password" ) ;
2009-02-07 12:25:39 +00:00
else newPassword = cmdparams [ 5 ] ;
2009-01-12 15:34:05 +00:00
2008-11-28 16:04:01 +00:00
m_commsManager . UserAdminService . ResetUserPassword ( firstName , lastName , newPassword ) ;
2009-01-12 15:34:05 +00:00
}
2008-08-18 00:39:10 +00:00
2009-08-13 02:54:57 +00:00
/// <summary>
/// Use XML2 format to serialize data to a file
/// </summary>
/// <param name="module"></param>
/// <param name="cmdparams"></param>
2009-02-07 12:25:39 +00:00
protected void SavePrimsXml2 ( string module , string [ ] cmdparams )
{
if ( cmdparams . Length > 5 )
{
m_sceneManager . SaveNamedPrimsToXml2 ( cmdparams [ 3 ] , cmdparams [ 4 ] ) ;
}
else
{
m_sceneManager . SaveNamedPrimsToXml2 ( "Primitive" , DEFAULT_PRIM_BACKUP_FILENAME ) ;
}
}
2009-08-13 02:54:57 +00:00
/// <summary>
/// Use XML format to serialize data to a file
/// </summary>
/// <param name="module"></param>
/// <param name="cmdparams"></param>
2009-02-07 12:25:39 +00:00
protected void SaveXml ( string module , string [ ] cmdparams )
2008-07-12 20:14:17 +00:00
{
m_log . Error ( "[CONSOLE]: 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." ) ;
if ( cmdparams . Length > 0 )
{
2009-02-07 12:25:39 +00:00
m_sceneManager . SaveCurrentSceneToXml ( cmdparams [ 2 ] ) ;
2008-07-12 20:14:17 +00:00
}
else
{
m_sceneManager . SaveCurrentSceneToXml ( DEFAULT_PRIM_BACKUP_FILENAME ) ;
}
2008-08-18 00:39:10 +00:00
}
2009-08-13 02:54:57 +00:00
/// <summary>
/// Loads data and region objects from XML format.
/// </summary>
/// <param name="module"></param>
/// <param name="cmdparams"></param>
2009-02-07 12:25:39 +00:00
protected void LoadXml ( string module , string [ ] cmdparams )
2008-07-12 20:14:17 +00:00
{
m_log . Error ( "[CONSOLE]: 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." ) ;
2008-09-06 07:52:41 +00:00
Vector3 loadOffset = new Vector3 ( 0 , 0 , 0 ) ;
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length > 2 )
2008-07-12 20:14:17 +00:00
{
bool generateNewIDS = false ;
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length > 3 )
2008-07-12 20:14:17 +00:00
{
2009-02-07 12:25:39 +00:00
if ( cmdparams [ 3 ] = = "-newUID" )
2008-07-12 20:14:17 +00:00
{
generateNewIDS = true ;
}
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length > 4 )
2008-07-12 20:14:17 +00:00
{
2009-02-07 12:25:39 +00:00
loadOffset . X = ( float ) Convert . ToDecimal ( cmdparams [ 4 ] ) ;
if ( cmdparams . Length > 5 )
2008-07-12 20:14:17 +00:00
{
2009-02-07 12:25:39 +00:00
loadOffset . Y = ( float ) Convert . ToDecimal ( cmdparams [ 5 ] ) ;
2008-07-12 20:14:17 +00:00
}
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length > 6 )
2008-07-12 20:14:17 +00:00
{
2009-02-07 12:25:39 +00:00
loadOffset . Z = ( float ) Convert . ToDecimal ( cmdparams [ 6 ] ) ;
2008-07-12 20:14:17 +00:00
}
2009-05-20 13:50:33 +00:00
m_log . Error ( "loadOffsets <X,Y,Z> = <" + loadOffset . X + "," + loadOffset . Y + "," +
2008-07-12 20:14:17 +00:00
loadOffset . Z + ">" ) ;
}
}
m_sceneManager . LoadCurrentSceneFromXml ( cmdparams [ 0 ] , generateNewIDS , loadOffset ) ;
}
else
{
2009-01-12 15:34:05 +00:00
try
{
m_sceneManager . LoadCurrentSceneFromXml ( DEFAULT_PRIM_BACKUP_FILENAME , false , loadOffset ) ;
}
2009-03-25 19:21:28 +00:00
catch ( FileNotFoundException )
2009-01-12 15:34:05 +00:00
{
2009-05-20 13:50:33 +00:00
m_log . Error ( "Default xml not found. Usage: load-xml <filename>" ) ;
2009-01-12 15:34:05 +00:00
}
2008-07-12 20:14:17 +00:00
}
2008-08-18 00:39:10 +00:00
}
2009-08-13 02:54:57 +00:00
/// <summary>
/// Serialize region data to XML2Format
/// </summary>
/// <param name="module"></param>
/// <param name="cmdparams"></param>
2009-02-07 12:25:39 +00:00
protected void SaveXml2 ( string module , string [ ] cmdparams )
2008-07-12 20:14:17 +00:00
{
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length > 2 )
2008-07-12 20:14:17 +00:00
{
2009-03-25 19:21:28 +00:00
m_sceneManager . SaveCurrentSceneToXml2 ( cmdparams [ 2 ] ) ;
2008-07-12 20:14:17 +00:00
}
else
{
m_sceneManager . SaveCurrentSceneToXml2 ( DEFAULT_PRIM_BACKUP_FILENAME ) ;
}
}
2008-08-18 00:39:10 +00:00
2009-08-13 02:54:57 +00:00
/// <summary>
/// Load region data from Xml2Format
/// </summary>
/// <param name="module"></param>
/// <param name="cmdparams"></param>
2009-02-07 12:25:39 +00:00
protected void LoadXml2 ( string module , string [ ] cmdparams )
2008-07-12 20:14:17 +00:00
{
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length > 2 )
2008-07-12 20:14:17 +00:00
{
2009-02-26 21:00:33 +00:00
try
{
m_sceneManager . LoadCurrentSceneFromXml2 ( cmdparams [ 2 ] ) ;
}
2009-03-25 19:21:28 +00:00
catch ( FileNotFoundException )
2009-02-26 21:00:33 +00:00
{
2009-05-20 13:50:33 +00:00
m_log . Error ( "Specified xml not found. Usage: load xml2 <filename>" ) ;
2009-02-26 21:00:33 +00:00
}
2008-07-12 20:14:17 +00:00
}
else
{
2009-01-12 15:34:05 +00:00
try
{
m_sceneManager . LoadCurrentSceneFromXml2 ( DEFAULT_PRIM_BACKUP_FILENAME ) ;
}
2009-03-25 19:21:28 +00:00
catch ( FileNotFoundException )
2009-01-12 15:34:05 +00:00
{
2009-05-20 13:50:33 +00:00
m_log . Error ( "Default xml not found. Usage: load xml2 <filename>" ) ;
2009-01-12 15:34:05 +00:00
}
2008-07-12 20:14:17 +00:00
}
2008-08-18 00:39:10 +00:00
}
2008-07-29 14:28:08 +00:00
/// <summary>
2009-07-10 11:03:38 +00:00
/// Load a whole region from an opensimulator archive.
2008-07-29 14:28:08 +00:00
/// </summary>
/// <param name="cmdparams"></param>
2009-02-07 12:25:39 +00:00
protected void LoadOar ( string module , string [ ] cmdparams )
2008-07-12 20:14:17 +00:00
{
2009-05-18 18:44:55 +00:00
try
2009-09-30 16:00:09 +00:00
{
2009-05-18 18:44:55 +00:00
if ( cmdparams . Length > 2 )
2009-02-26 21:00:33 +00:00
{
2009-09-30 16:00:09 +00:00
m_sceneManager . LoadArchiveToCurrentScene ( cmdparams [ 2 ] ) ;
2009-02-26 21:00:33 +00:00
}
2009-05-18 18:44:55 +00:00
else
2009-02-26 21:00:33 +00:00
{
2009-09-30 16:00:09 +00:00
m_sceneManager . LoadArchiveToCurrentScene ( DEFAULT_OAR_BACKUP_FILENAME ) ;
2009-02-26 21:00:33 +00:00
}
2008-07-12 20:14:17 +00:00
}
2009-05-18 18:44:55 +00:00
catch ( Exception e )
2008-07-12 20:14:17 +00:00
{
2009-05-20 13:50:33 +00:00
m_log . Error ( e . Message ) ;
2009-09-30 16:00:09 +00:00
}
2008-07-12 20:14:17 +00:00
}
2008-08-18 00:39:10 +00:00
2008-07-29 14:28:08 +00:00
/// <summary>
/// Save a region to a file, including all the assets needed to restore it.
/// </summary>
/// <param name="cmdparams"></param>
2009-02-07 12:25:39 +00:00
protected void SaveOar ( string module , string [ ] cmdparams )
2008-07-12 20:14:17 +00:00
{
2009-02-07 12:25:39 +00:00
if ( cmdparams . Length > 2 )
2008-07-12 20:14:17 +00:00
{
2009-03-25 19:21:28 +00:00
m_sceneManager . SaveCurrentSceneToArchive ( cmdparams [ 2 ] ) ;
2008-07-12 20:14:17 +00:00
}
else
{
m_sceneManager . SaveCurrentSceneToArchive ( DEFAULT_OAR_BACKUP_FILENAME ) ;
2008-08-18 00:39:10 +00:00
}
}
2009-01-12 15:34:05 +00:00
2008-05-01 16:03:53 +00:00
private static string CombineParams ( string [ ] commandParams , int pos )
2008-04-28 14:41:46 +00:00
{
string result = String . Empty ;
for ( int i = pos ; i < commandParams . Length ; i + + )
{
result + = commandParams [ i ] + " " ;
}
result = result . TrimEnd ( ' ' ) ;
return result ;
}
2009-10-23 14:11:25 +00:00
/// <summary>
/// Kill an object given its UUID.
/// </summary>
/// <param name="cmdparams"></param>
protected void KillUUID ( string module , string [ ] cmdparams )
{
if ( cmdparams . Length > 1 )
{
UUID id = UUID . Zero ;
SceneObjectGroup grp = null ;
Scene sc = null ;
try
{
Guid x = new Guid ( ( string ) cmdparams [ 1 ] ) ;
id = ( UUID ) ( string ) cmdparams [ 1 ] ;
}
catch ( Exception )
{
m_log . Error ( "[KillUUID]: Error bad UUID formating !" ) ;
return ;
}
m_sceneManager . ForEachScene (
delegate ( Scene scene )
{
if ( scene . Entities [ id ] ! = null )
{
grp = ( SceneObjectGroup ) scene . Entities [ id ] ;
sc = scene ;
}
} ) ;
if ( grp = = null )
m_log . ErrorFormat ( "[KillUUID]: Given UUID {0} not found !" , id ) ;
else
{
m_log . InfoFormat ( "[KillUUID]: Found UUID {0} in scene {1}" , id , sc . RegionInfo . RegionName ) ;
try
{
sc . DeleteSceneObject ( grp , false ) ;
}
catch ( Exception e )
{
m_log . ErrorFormat ( "[KillUUID]: Error while removing objects from scene: " + e ) ;
}
}
}
else
{
m_log . Error ( "[KillUUID]: Usage: killuuid <UUID>" ) ;
}
}
2008-04-28 14:41:46 +00:00
# endregion
2008-06-09 08:46:33 +00:00
}
2009-04-05 10:31:18 +00:00
}