aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/OpenSimBase.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs239
1 files changed, 165 insertions, 74 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index f482d8f..5de3f25 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Linq;
31using System.Net; 32using System.Net;
32using System.Reflection; 33using System.Reflection;
33using System.Text; 34using System.Text;
@@ -67,6 +68,9 @@ namespace OpenSim
67 private const string PLUGIN_ASSET_CACHE = "/OpenSim/AssetCache"; 68 private const string PLUGIN_ASSET_CACHE = "/OpenSim/AssetCache";
68 private const string PLUGIN_ASSET_SERVER_CLIENT = "/OpenSim/AssetClient"; 69 private const string PLUGIN_ASSET_SERVER_CLIENT = "/OpenSim/AssetClient";
69 70
71 // OpenSim.ini Section name for ESTATES Settings
72 public const string ESTATE_SECTION_NAME = "Estates";
73
70 protected string proxyUrl; 74 protected string proxyUrl;
71 protected int proxyOffset = 0; 75 protected int proxyOffset = 0;
72 76
@@ -242,15 +246,18 @@ namespace OpenSim
242 246
243 foreach (string topic in topics) 247 foreach (string topic in topics)
244 { 248 {
245 m_console.Commands.AddCommand("plugin", false, "help " + topic, 249 string capitalizedTopic = char.ToUpper(topic[0]) + topic.Substring(1);
246 "help " + topic, 250
251 // This is a hack to allow the user to enter the help command in upper or lowercase. This will go
252 // away at some point.
253 m_console.Commands.AddCommand(capitalizedTopic, false, "help " + topic,
254 "help " + capitalizedTopic,
255 "Get help on plugin command '" + topic + "'",
256 HandleCommanderHelp);
257 m_console.Commands.AddCommand(capitalizedTopic, false, "help " + capitalizedTopic,
258 "help " + capitalizedTopic,
247 "Get help on plugin command '" + topic + "'", 259 "Get help on plugin command '" + topic + "'",
248 HandleCommanderHelp); 260 HandleCommanderHelp);
249
250 m_console.Commands.AddCommand("plugin", false, topic,
251 topic,
252 "Execute subcommand for plugin '" + topic + "'",
253 null);
254 261
255 ICommander commander = null; 262 ICommander commander = null;
256 263
@@ -267,7 +274,7 @@ namespace OpenSim
267 274
268 foreach (string command in commander.Commands.Keys) 275 foreach (string command in commander.Commands.Keys)
269 { 276 {
270 m_console.Commands.AddCommand(topic, false, 277 m_console.Commands.AddCommand(capitalizedTopic, false,
271 topic + " " + command, 278 topic + " " + command,
272 topic + " " + commander.Commands[command].ShortHelp(), 279 topic + " " + commander.Commands[command].ShortHelp(),
273 String.Empty, HandleCommanderCommand); 280 String.Empty, HandleCommanderCommand);
@@ -286,7 +293,7 @@ namespace OpenSim
286 // Only safe for the interactive console, since it won't 293 // Only safe for the interactive console, since it won't
287 // let us come here unless both scene and commander exist 294 // let us come here unless both scene and commander exist
288 // 295 //
289 ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(cmd[1]); 296 ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(cmd[1].ToLower());
290 if (moduleCommander != null) 297 if (moduleCommander != null)
291 m_console.Output(moduleCommander.Help); 298 m_console.Output(moduleCommander.Help);
292 } 299 }
@@ -424,7 +431,7 @@ namespace OpenSim
424 431
425 mscene = scene; 432 mscene = scene;
426 433
427 scene.StartTimer(); 434 scene.Start();
428 435
429 scene.StartScripts(); 436 scene.StartScripts();
430 437
@@ -443,12 +450,42 @@ namespace OpenSim
443 { 450 {
444 RegionInfo regionInfo = scene.RegionInfo; 451 RegionInfo regionInfo = scene.RegionInfo;
445 452
453 string estateOwnerFirstName = null;
454 string estateOwnerLastName = null;
455 string estateOwnerEMail = null;
456 string estateOwnerPassword = null;
457 string rawEstateOwnerUuid = null;
458
459 if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null)
460 {
461 string defaultEstateOwnerName
462 = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim();
463 string[] ownerNames = defaultEstateOwnerName.Split(' ');
464
465 if (ownerNames.Length >= 2)
466 {
467 estateOwnerFirstName = ownerNames[0];
468 estateOwnerLastName = ownerNames[1];
469 }
470
471 // Info to be used only on Standalone Mode
472 rawEstateOwnerUuid = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null);
473 estateOwnerEMail = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null);
474 estateOwnerPassword = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null);
475 }
476
446 MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName); 477 MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName);
447 List<char> excluded = new List<char>(new char[1]{' '}); 478 List<char> excluded = new List<char>(new char[1]{' '});
448 string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded);
449 string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded);
450 479
451 UserAccount account = scene.UserAccountService.GetUserAccount(regionInfo.ScopeID, first, last); 480
481 if (estateOwnerFirstName == null || estateOwnerLastName == null)
482 {
483 estateOwnerFirstName = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded);
484 estateOwnerLastName = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded);
485 }
486
487 UserAccount account
488 = scene.UserAccountService.GetUserAccount(regionInfo.ScopeID, estateOwnerFirstName, estateOwnerLastName);
452 489
453 if (account == null) 490 if (account == null)
454 { 491 {
@@ -467,23 +504,35 @@ namespace OpenSim
467 504
468 if (scene.UserAccountService is UserAccountService) 505 if (scene.UserAccountService is UserAccountService)
469 { 506 {
470 string password = MainConsole.Instance.PasswdPrompt("Password"); 507 if (estateOwnerPassword == null)
471 string email = MainConsole.Instance.CmdPrompt("Email", ""); 508 estateOwnerPassword = MainConsole.Instance.PasswdPrompt("Password");
472 509
473 string rawPrincipalId = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString()); 510 if (estateOwnerEMail == null)
511 estateOwnerEMail = MainConsole.Instance.CmdPrompt("Email");
512
513 if (rawEstateOwnerUuid == null)
514 rawEstateOwnerUuid = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString());
474 515
475 UUID principalId = UUID.Zero; 516 UUID estateOwnerUuid = UUID.Zero;
476 if (!UUID.TryParse(rawPrincipalId, out principalId)) 517 if (!UUID.TryParse(rawEstateOwnerUuid, out estateOwnerUuid))
477 { 518 {
478 m_log.ErrorFormat("[OPENSIM]: ID {0} is not a valid UUID", rawPrincipalId); 519 m_log.ErrorFormat("[OPENSIM]: ID {0} is not a valid UUID", rawEstateOwnerUuid);
479 return; 520 return;
480 } 521 }
481 522
523 // If we've been given a zero uuid then this signals that we should use a random user id
524 if (estateOwnerUuid == UUID.Zero)
525 estateOwnerUuid = UUID.Random();
526
482 account 527 account
483 = ((UserAccountService)scene.UserAccountService).CreateUser( 528 = ((UserAccountService)scene.UserAccountService).CreateUser(
484 regionInfo.ScopeID, principalId, first, last, password, email); 529 regionInfo.ScopeID,
530 estateOwnerUuid,
531 estateOwnerFirstName,
532 estateOwnerLastName,
533 estateOwnerPassword,
534 estateOwnerEMail);
485 } 535 }
486// }
487 } 536 }
488 537
489 if (account == null) 538 if (account == null)
@@ -883,15 +932,21 @@ namespace OpenSim
883 /// This method doesn't allow an estate to be created with the same name as existing estates. 932 /// This method doesn't allow an estate to be created with the same name as existing estates.
884 /// </remarks> 933 /// </remarks>
885 /// <param name="regInfo"></param> 934 /// <param name="regInfo"></param>
886 /// <param name="existingName">A list of estate names that already exist.</param> 935 /// <param name="estatesByName">A list of estate names that already exist.</param>
936 /// <param name="estateName">Estate name to create if already known</param>
887 /// <returns>true if the estate was created, false otherwise</returns> 937 /// <returns>true if the estate was created, false otherwise</returns>
888 public bool CreateEstate(RegionInfo regInfo, List<string> existingNames) 938 public bool CreateEstate(RegionInfo regInfo, Dictionary<string, EstateSettings> estatesByName, string estateName)
889 { 939 {
890 // Create a new estate 940 // Create a new estate
891 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true); 941 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true);
892 string newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
893 942
894 if (existingNames.Contains(newName)) 943 string newName;
944 if (estateName != null && estateName != "")
945 newName = estateName;
946 else
947 newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
948
949 if (estatesByName.ContainsKey(newName))
895 { 950 {
896 MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName); 951 MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName);
897 return false; 952 return false;
@@ -918,66 +973,102 @@ namespace OpenSim
918 if (EstateDataService != null) 973 if (EstateDataService != null)
919 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, false); 974 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, false);
920 975
921 if (regInfo.EstateSettings.EstateID == 0) // No record at all 976 if (regInfo.EstateSettings.EstateID != 0)
977 return;
978
979 m_log.WarnFormat("[ESTATE] Region {0} is not part of an estate.", regInfo.RegionName);
980
981 List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll();
982 Dictionary<string, EstateSettings> estatesByName = new Dictionary<string, EstateSettings>();
983
984 foreach (EstateSettings estate in estates)
985 estatesByName[estate.EstateName] = estate;
986
987 string defaultEstateName = null;
988
989 if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null)
922 { 990 {
923 m_log.WarnFormat("[ESTATE] Region {0} is not part of an estate.", regInfo.RegionName); 991 defaultEstateName = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null);
924 992
925 List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll(); 993 if (defaultEstateName != null)
926 List<string> estateNames = new List<string>();
927 foreach (EstateSettings estate in estates)
928 estateNames.Add(estate.EstateName);
929
930 while (true)
931 { 994 {
932 if (estates.Count == 0) 995 EstateSettings defaultEstate;
933 { 996 bool defaultEstateJoined = false;
934 m_log.Info("[ESTATE] No existing estates found. You must create a new one."); 997
935 998 if (estatesByName.ContainsKey(defaultEstateName))
936 if (CreateEstate(regInfo, estateNames)) 999 {
937 break; 1000 defaultEstate = estatesByName[defaultEstateName];
1001
1002 if (EstateDataService.LinkRegion(regInfo.RegionID, (int)defaultEstate.EstateID))
1003 defaultEstateJoined = true;
1004 }
1005 else
1006 {
1007 if (CreateEstate(regInfo, estatesByName, defaultEstateName))
1008 defaultEstateJoined = true;
1009 }
1010
1011 if (defaultEstateJoined)
1012 return;
1013 else
1014 m_log.ErrorFormat(
1015 "[OPENSIM BASE]: Joining default estate {0} failed", defaultEstateName);
1016 }
1017 }
1018
1019 // If we have no default estate or creation of the default estate failed then ask the user.
1020 while (true)
1021 {
1022 if (estates.Count == 0)
1023 {
1024 m_log.Info("[ESTATE]: No existing estates found. You must create a new one.");
1025
1026 if (CreateEstate(regInfo, estatesByName, null))
1027 break;
1028 else
1029 continue;
1030 }
1031 else
1032 {
1033 string response
1034 = MainConsole.Instance.CmdPrompt(
1035 string.Format(
1036 "Do you wish to join region {0} to an existing estate (yes/no)?", regInfo.RegionName),
1037 "yes",
1038 new List<string>() { "yes", "no" });
1039
1040 if (response == "no")
1041 {
1042 if (CreateEstate(regInfo, estatesByName, null))
1043 break;
938 else 1044 else
939 continue; 1045 continue;
940 } 1046 }
941 else 1047 else
942 { 1048 {
943 string response 1049 string[] estateNames = estatesByName.Keys.ToArray();
1050 response
944 = MainConsole.Instance.CmdPrompt( 1051 = MainConsole.Instance.CmdPrompt(
945 string.Format( 1052 string.Format(
946 "Do you wish to join region {0} to an existing estate (yes/no)?", regInfo.RegionName), 1053 "Name of estate to join. Existing estate names are ({0})",
947 "yes", 1054 string.Join(", ", estateNames)),
948 new List<string>() { "yes", "no" }); 1055 estateNames[0]);
949 1056
950 if (response == "no") 1057 List<int> estateIDs = EstateDataService.GetEstates(response);
1058 if (estateIDs.Count < 1)
951 { 1059 {
952 if (CreateEstate(regInfo, estateNames)) 1060 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again.");
953 break; 1061 continue;
954 else
955 continue;
956 }
957 else
958 {
959 response
960 = MainConsole.Instance.CmdPrompt(
961 string.Format(
962 "Name of estate to join. Existing estate names are ({0})", string.Join(", ", estateNames.ToArray())),
963 estateNames[0]);
964
965 List<int> estateIDs = EstateDataService.GetEstates(response);
966 if (estateIDs.Count < 1)
967 {
968 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again.");
969 continue;
970 }
971
972 int estateID = estateIDs[0];
973
974 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(estateID);
975
976 if (EstateDataService.LinkRegion(regInfo.RegionID, estateID))
977 break;
978
979 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
980 } 1062 }
1063
1064 int estateID = estateIDs[0];
1065
1066 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(estateID);
1067
1068 if (EstateDataService.LinkRegion(regInfo.RegionID, estateID))
1069 break;
1070
1071 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
981 } 1072 }
982 } 1073 }
983 } 1074 }