/// <summary> /// Creates the grid owner user on a clean startup. /// Sets user to 'Charter Meneber" and elevates to "God" status /// </summary> void CreateGridOwnerUser() { string userName = ""; string password, email, uuid; // Get user name // check for user name seed IConfig loginConfig = m_config.Configs ["LoginService"]; if (loginConfig != null) { string userNameSeed = loginConfig.GetString("UserNameSeed", ""); if (userNameSeed != "") { m_userNameSeed = userNameSeed.Split(','); } } var ufNames = new Utilities.MarkovNameGenerator(); var ulNames = new Utilities.MarkovNameGenerator(); string [] nameSeed = m_userNameSeed == null ? Utilities.UserNames : m_userNameSeed; string firstName = ufNames.FirstName(nameSeed, 3, 4); string lastName = ulNames.FirstName(nameSeed, 5, 6); string enteredName = firstName + " " + lastName; if (userName != "") { enteredName = userName; } do { userName = MainConsole.Instance.Prompt("Grid owner user name (? for suggestion)", enteredName); if (userName == "" || userName == "?") { enteredName = ufNames.NextName + " " + ulNames.NextName; userName = ""; continue; } var fl = userName.Split(' '); if (fl.Length < 2) { MainConsole.Instance.CleanInfo(" User name must be <firstname> <lastname>"); userName = ""; } } while (userName == ""); ufNames.Reset(); ulNames.Reset(); // password var pwmatch = false; do { password = MainConsole.Instance.PasswordPrompt("Password"); if (password == "") { MainConsole.Instance.CleanInfo(" .... password must not be empty, please re-enter"); continue; } var passwordAgain = MainConsole.Instance.PasswordPrompt("Re-enter Password"); pwmatch = (password == passwordAgain); if (!pwmatch) { MainConsole.Instance.CleanInfo(" .... passwords did not match, please re-enter"); } } while (!pwmatch); // email email = MainConsole.Instance.Prompt("Email for password recovery. ('none' if unknown)", "none"); if ((email.ToLower() != "none") && !Utilities.IsValidEmail(email)) { MainConsole.Instance.CleanInfo("This does not look like a valid email address. ('none' if unknown)"); email = MainConsole.Instance.Prompt("Email", email); } // Get available user avatar archives var userAvatarArchive = ""; IAvatarAppearanceArchiver avieArchiver = m_registry.RequestModuleInterface <IAvatarAppearanceArchiver> (); if (avieArchiver != null) { List <string> avatarArchives = avieArchiver.GetAvatarArchiveFilenames(); if (avatarArchives.Count > 0) { avatarArchives.Add("None"); userAvatarArchive = MainConsole.Instance.Prompt("Avatar archive to use", "None", avatarArchives); if (userAvatarArchive == "None") { userAvatarArchive = ""; } } } // Allow the modification of UUID if required - for matching user UUID with other Grids etc like SL uuid = UUID.Random().ToString(); while (true) { uuid = MainConsole.Instance.Prompt("Required avatar UUID (optional))", uuid); UUID test; if (UUID.TryParse(uuid, out test)) { break; } MainConsole.Instance.Error("There was a problem verifying this UUID. Please retry."); } // this really should not normally be altered so hide it //scopeID = UUID.Zero.ToString (); //if (sysFlag) { // scopeID = MainConsole.Instance.Prompt ("Scope (Don't change unless you know what this is)", scopeID); //} // we should be good to go //m_accountService.CreateUser (UUID.Parse (uuid), UUID.Parse (scopeID), userName, Util.Md5Hash (password), email); m_accountService.CreateUser(UUID.Parse(uuid), UUID.Zero, userName, Util.Md5Hash(password), email); // CreateUser will tell us success or problem //MainConsole.Instance.InfoFormat("[User account service]: User '{0}' created", name); // check for success UserAccount account = m_accountService.GetUserAccount(null, userName); if (account != null) { account.UserFlags = Constants.USER_FLAG_CHARTERMEMBER; account.UserLevel = 250; m_accountService.StoreUserAccount(account); // update profile for the user as well var profileConnector = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector> (); if (profileConnector != null) { var profile = profileConnector.GetUserProfile(account.PrincipalID); if (profile == null) { profileConnector.CreateNewProfile(account.PrincipalID); // create a profile for the user profile = profileConnector.GetUserProfile(account.PrincipalID); } if (userAvatarArchive != "") { profile.AArchiveName = userAvatarArchive + ".aa"; } profile.MembershipGroup = "Charter_Member"; profile.IsNewUser = true; profileConnector.UpdateUserProfile(profile); } } else { MainConsole.Instance.WarnFormat("[System User account service]: There was a problem creating the account for '{0}'", userName); } }
/// <summary> /// Creates/updates a region from console. /// </summary> /// <returns>The region from console.</returns> /// <param name="info">Info.</param> /// <param name="prompt">If set to <c>true</c> prompt.</param> /// <param name="currentInfo">Current info.</param> RegionInfo CreateRegionFromConsole(RegionInfo info, Boolean prompt, Dictionary <string, int> currentInfo) { if (info == null || info.NewRegion) { if (info == null) { info = new RegionInfo(); } info.RegionID = UUID.Random(); if (currentInfo != null) { info.RegionLocX = currentInfo ["minX"] > 0 ? currentInfo ["minX"] : 1000 * Constants.RegionSize; info.RegionLocY = currentInfo ["minY"] > 0 ? currentInfo ["minY"] : 1000 * Constants.RegionSize; info.RegionPort = currentInfo ["port"] > 0 ? currentInfo ["port"] + 1 : 9000; } else { info.RegionLocX = 1000 * Constants.RegionSize; info.RegionLocY = 1000 * Constants.RegionSize; info.RegionPort = 9000; } prompt = true; } // prompt for user input if (prompt) { Utilities.MarkovNameGenerator rNames = new Utilities.MarkovNameGenerator(); string regionName = rNames.FirstName(m_regionNameSeed == null ? Utilities.RegionNames: m_regionNameSeed, 3, 7); if (info.RegionName != "") { regionName = info.RegionName; } do { info.RegionName = MainConsole.Instance.Prompt("Region Name (? for suggestion)", regionName); if (info.RegionName == "" || info.RegionName == "?") { regionName = rNames.NextName; info.RegionName = ""; continue; } }while (info.RegionName == ""); rNames.Reset(); info.RegionLocX = int.Parse(MainConsole.Instance.Prompt("Region Location X", ((info.RegionLocX == 0 ? 1000 : info.RegionLocX / Constants.RegionSize)).ToString())) * Constants.RegionSize; info.RegionLocY = int.Parse(MainConsole.Instance.Prompt("Region location Y", ((info.RegionLocY == 0 ? 1000 : info.RegionLocY / Constants.RegionSize)).ToString())) * Constants.RegionSize; //info.RegionLocZ = // int.Parse (MainConsole.Instance.Prompt ("Region location Z", // ((info.RegionLocZ == 0 // ? 0 // : info.RegionLocZ / Constants.RegionSize)).ToString ())) * Constants.RegionSize; info.RegionSizeX = int.Parse(MainConsole.Instance.Prompt("Region size X", info.RegionSizeX.ToString())); info.RegionSizeY = int.Parse(MainConsole.Instance.Prompt("Region size Y", info.RegionSizeY.ToString())); // * Mainland / Full Region (Private) // * Mainland / Homestead // * Mainland / Openspace // // * Estate / Full Region (Private) // info.RegionType = MainConsole.Instance.Prompt("Region Type (Mainland/Estate)", (info.RegionType == "" ? "Estate" : info.RegionType)); // Region presets or advanced setup string setupMode; string terrainOpen = "Grassland"; string terrainFull = "Grassland"; var responses = new List <string>(); if (info.RegionType.ToLower().StartsWith("m")) { // Mainland regions info.RegionType = "Mainland / "; responses.Add("Full Region"); responses.Add("Homestead"); responses.Add("Openspace"); responses.Add("Whitecore"); // TODO: remove? responses.Add("Custom"); setupMode = MainConsole.Instance.Prompt("Mainland region type?", "Full Region", responses).ToLower(); // allow specifying terrain for Openspace if (setupMode.StartsWith("o")) { terrainOpen = MainConsole.Instance.Prompt("Openspace terrain ( Grassland, Swamp, Aquatic)?", terrainOpen).ToLower(); } } else { // Estate regions info.RegionType = "Estate / "; responses.Add("Full Region"); responses.Add("Whitecore"); // TODO: WhiteCore 'standard' setup, rename?? responses.Add("Custom"); setupMode = MainConsole.Instance.Prompt("Estate region type?", "Full Region", responses).ToLower(); } // terrain can be specified for Full or custom regions if (setupMode.StartsWith("f") || setupMode.StartsWith("c")) { var tresp = new List <string>(); tresp.Add("Flatland"); tresp.Add("Grassland"); tresp.Add("Hills"); tresp.Add("Mountainous"); tresp.Add("Island"); tresp.Add("Swamp"); tresp.Add("Aquatic"); string tscape = MainConsole.Instance.Prompt("Terrain Type?", terrainFull, tresp); terrainFull = tscape; // TODO: This would be where we allow selection of preset terrain files } if (setupMode.StartsWith("c")) { info.RegionType = info.RegionType + "Custom"; info.RegionTerrain = terrainFull; // allow port selection info.RegionPort = int.Parse(MainConsole.Instance.Prompt("Region Port", info.RegionPort.ToString())); // Startup mode string scriptStart = MainConsole.Instance.Prompt( "Region Startup - Normal or Delayed startup (normal/delay) : ", "normal").ToLower(); info.Startup = scriptStart.StartsWith("n") ? StartupType.Normal : StartupType.Medium; info.SeeIntoThisSimFromNeighbor = MainConsole.Instance.Prompt( "See into this sim from neighbors (yes/no)", info.SeeIntoThisSimFromNeighbor ? "yes" : "no").ToLower() == "yes"; info.InfiniteRegion = MainConsole.Instance.Prompt( "Make an infinite region (yes/no)", info.InfiniteRegion ? "yes" : "no").ToLower() == "yes"; info.ObjectCapacity = int.Parse(MainConsole.Instance.Prompt("Object capacity", info.ObjectCapacity == 0 ? "50000" : info.ObjectCapacity.ToString())); } if (setupMode.StartsWith("w")) { // 'standard' setup info.RegionType = info.RegionType + "Whitecore"; //info.RegionPort; // use auto assigned port info.RegionTerrain = "Flatland"; info.Startup = StartupType.Normal; info.SeeIntoThisSimFromNeighbor = true; info.InfiniteRegion = false; info.ObjectCapacity = 50000; } if (setupMode.StartsWith("o")) { // 'Openspace' setup info.RegionType = info.RegionType + "Openspace"; //info.RegionPort; // use auto assigned port if (terrainOpen.StartsWith("a")) { info.RegionTerrain = "Aquatic"; } else if (terrainOpen.StartsWith("s")) { info.RegionTerrain = "Swamp"; } else { info.RegionTerrain = "Grassland"; } info.Startup = StartupType.Medium; info.SeeIntoThisSimFromNeighbor = true; info.InfiniteRegion = false; info.ObjectCapacity = 750; info.RegionSettings.AgentLimit = 10; info.RegionSettings.AllowLandJoinDivide = false; info.RegionSettings.AllowLandResell = false; } if (setupMode.StartsWith("h")) { // 'Homestead' setup info.RegionType = info.RegionType + "Homestead"; //info.RegionPort; // use auto assigned port info.RegionTerrain = "Homestead"; info.Startup = StartupType.Medium; info.SeeIntoThisSimFromNeighbor = true; info.InfiniteRegion = false; info.ObjectCapacity = 3750; info.RegionSettings.AgentLimit = 20; info.RegionSettings.AllowLandJoinDivide = false; info.RegionSettings.AllowLandResell = false; } if (setupMode.StartsWith("f")) { // 'Full Region' setup info.RegionType = info.RegionType + "Full Region"; //info.RegionPort; // use auto assigned port info.RegionTerrain = terrainFull; info.Startup = StartupType.Normal; info.SeeIntoThisSimFromNeighbor = true; info.InfiniteRegion = false; info.ObjectCapacity = 15000; info.RegionSettings.AgentLimit = 100; if (info.RegionType.StartsWith("M")) // defaults are 'true' { info.RegionSettings.AllowLandJoinDivide = false; info.RegionSettings.AllowLandResell = false; } } } // are we updating or adding?? if (m_scene != null) { IGridRegisterModule gridRegister = m_scene.RequestModuleInterface <IGridRegisterModule>(); //Re-register so that if the position has changed, we get the new neighbors gridRegister.RegisterRegionWithGrid(m_scene, true, false, null); // Tell clients about changes IEstateModule es = m_scene.RequestModuleInterface <IEstateModule> (); if (es != null) { es.sendRegionHandshakeToAll(); } // in case we have changed the name if (m_scene.SimulationDataService.BackupFile != info.RegionName) { string oldFile = BuildSaveFileName(m_scene.SimulationDataService.BackupFile); if (File.Exists(oldFile)) { File.Delete(oldFile); } m_scene.SimulationDataService.BackupFile = info.RegionName; } m_scene.SimulationDataService.ForceBackup(); MainConsole.Instance.InfoFormat("[FileBasedSimulationData]: Save of {0} completed.", info.RegionName); } return(info); }