protected internal override void OnBeforeMoveNext(CancelEventArgs e) { try { if (!chkChangePassword.Checked) { //if we don't want to change password during setup Wizard.SetupVariables.UpdateServerPassword = false; e.Cancel = false; return; } if (!CheckFields()) { e.Cancel = true; return; } string hash = Utils.ComputeSHA1(txtPassword.Text); Wizard.SetupVariables.ServerPassword = hash; Wizard.SetupVariables.UpdateServerPassword = true; AppConfig.SetComponentSettingStringValue(Wizard.SetupVariables.ComponentId, "Password", hash); } catch { this.AllowMoveNext = false; ShowError("Unable to set server password."); return; } base.OnBeforeMoveNext(e); }
protected internal override void OnBeforeMoveNext(CancelEventArgs e) { try { string installFolder = this.txtFolder.Text; Log.WriteInfo(string.Format("Destination folder \"{0}\" selected", installFolder)); if (!Directory.Exists(installFolder)) { Log.WriteStart(string.Format("Creating a new folder \"{0}\"", installFolder)); Directory.CreateDirectory(installFolder); Log.WriteStart("Created a new folder"); } Wizard.SetupVariables.InstallationFolder = installFolder; string componentId = Wizard.SetupVariables.ComponentId; AppConfig.SetComponentSettingStringValue(componentId, "InstallFolder", installFolder); base.OnBeforeMoveNext(e); } catch (Exception ex) { Log.WriteError("Folder create error", ex); e.Cancel = true; ShowError("Unable to create the folder."); } }
public static void CreateComponentSettingsFromSetupVariables(SetupVariables setupVariables, string componentId) { AppConfig.SetComponentSettingStringValue(componentId, "ApplicationName", setupVariables.ApplicationName); AppConfig.SetComponentSettingStringValue(componentId, "ComponentCode", setupVariables.ComponentCode); AppConfig.SetComponentSettingStringValue(componentId, "ComponentName", setupVariables.ComponentName); AppConfig.SetComponentSettingStringValue(componentId, "ComponentDescription", setupVariables.ComponentDescription); AppConfig.SetComponentSettingStringValue(componentId, "Release", setupVariables.Version); AppConfig.SetComponentSettingStringValue(componentId, "Instance", setupVariables.Instance); AppConfig.SetComponentSettingStringValue(componentId, "InstallFolder", setupVariables.InstallationFolder); AppConfig.SetComponentSettingStringValue(componentId, "Installer", setupVariables.Installer); AppConfig.SetComponentSettingStringValue(componentId, "InstallerType", setupVariables.InstallerType); AppConfig.SetComponentSettingStringValue(componentId, "InstallerPath", setupVariables.InstallerPath); }
protected internal override void OnBeforeMoveNext(CancelEventArgs e) { try { if (!CheckFields()) { e.Cancel = true; return; } string connectionString = CreateConnectionString(); string component = SetupVariables.ComponentFullName; if (CheckConnection(connectionString)) { // check SQL server version string sqlVersion = GetSqlServerVersion(connectionString); if (!sqlVersion.StartsWith("9.") && !sqlVersion.StartsWith("10.")) { // SQL Server 2005 engine required e.Cancel = true; ShowWarning("This program can be installed on SQL Server 2005/2008 only."); return; } int securityMode = GetSqlServerSecurityMode(connectionString); if (securityMode != 0) { // mixed mode required e.Cancel = true; ShowWarning("Please switch SQL Server authentication to mixed SQL Server and Windows Authentication mode."); return; } } else { e.Cancel = true; ShowWarning("SQL Server does not exist or access denied"); return; } string database = this.txtDatabase.Text; if (SqlUtils.DatabaseExists(connectionString, database)) { e.Cancel = true; ShowWarning(string.Format("{0} database already exists.", database)); return; } string server = this.txtSqlServer.Text; Log.WriteInfo(string.Format("Sql server \"{0}\" selected for {1}", server, component)); SetupVariables.Database = database; SetupVariables.DatabaseServer = server; SetupVariables.DbInstallConnectionString = connectionString; AppConfig.SetComponentSettingStringValue(SetupVariables.ComponentId, "Database", database); AppConfig.SetComponentSettingStringValue(SetupVariables.ComponentId, "DatabaseServer", server); AppConfig.SetComponentSettingStringValue(SetupVariables.ComponentId, "InstallConnectionString", connectionString); } catch { e.Cancel = true; ShowError("Unable to configure the database server."); return; } base.OnBeforeMoveNext(e); }
internal static DialogResult InstallBase(object obj, string minimalInstallerVersion) { Hashtable args = Utils.GetSetupParameters(obj); //check CS version string shellVersion = Utils.GetStringSetupParameter(args, "ShellVersion"); Version version = new Version(shellVersion); if (version < new Version(minimalInstallerVersion)) { MessageBox.Show( string.Format("WebsitePanel Installer {0} or higher required.", minimalInstallerVersion), "Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(DialogResult.Cancel); } InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; //load config file AppConfig.LoadConfiguration(); //general settings wizard.SetupVariables.ApplicationName = Utils.GetStringSetupParameter(args, "ApplicationName"); wizard.SetupVariables.Version = Utils.GetStringSetupParameter(args, "Version"); wizard.SetupVariables.Installer = Utils.GetStringSetupParameter(args, "Installer"); wizard.SetupVariables.InstallerPath = Utils.GetStringSetupParameter(args, "InstallerPath"); wizard.SetupVariables.IISVersion = Utils.GetVersionSetupParameter(args, "IISVersion"); wizard.SetupVariables.SetupAction = SetupActions.Install; wizard.SetupVariables.SetupXml = Utils.GetStringSetupParameter(args, "SetupXml"); //******************** Server **************** //general settings string serverId = Guid.NewGuid().ToString(); wizard.SetupVariables.ServerComponentId = serverId; wizard.SetupVariables.ComponentId = serverId; wizard.SetupVariables.Instance = string.Empty; wizard.SetupVariables.ComponentName = "Server"; wizard.SetupVariables.ComponentCode = "server"; wizard.SetupVariables.ComponentDescription = "WebsitePanel Server is a set of services running on the remote server to be controlled. Server application should be reachable from Enterprise Server one."; wizard.SetupVariables.InstallerFolder = Path.Combine(Utils.GetStringSetupParameter(args, "InstallerFolder"), "Server"); wizard.SetupVariables.InstallerType = Utils.GetStringSetupParameter(args, "InstallerType").Replace("StandaloneServerSetup", "Server"); wizard.SetupVariables.InstallationFolder = Path.Combine(Utils.GetSystemDrive(), "WebsitePanel\\Server"); //web settings wizard.SetupVariables.UserAccount = "WPServer"; wizard.SetupVariables.UserPassword = Guid.NewGuid().ToString("P"); wizard.SetupVariables.UserDomain = null; wizard.SetupVariables.WebSiteIP = "127.0.0.1"; wizard.SetupVariables.WebSitePort = "9003"; wizard.SetupVariables.WebSiteDomain = string.Empty; wizard.SetupVariables.NewWebSite = true; wizard.SetupVariables.NewVirtualDirectory = false; wizard.SetupVariables.UserMembership = (wizard.SetupVariables.IISVersion.Major == 7) ? new string[] { "AD:Domain Admins", "SID:" + SystemSID.ADMINISTRATORS, "IIS_IUSRS" } : new string[] { "AD:Domain Admins", "SID:" + SystemSID.ADMINISTRATORS, "IIS_WPG" }; wizard.SetupVariables.ConfigurationFile = "web.config"; wizard.SetupVariables.UpdateServerPassword = true; //Unattended setup LoadComponentVariablesFromSetupXml(wizard.SetupVariables.ComponentCode, wizard.SetupVariables.SetupXml, wizard.SetupVariables); //create component settings node wizard.SetupVariables.ComponentConfig = AppConfig.CreateComponentConfig(serverId); //write component settings to xml CreateComponentSettingsFromSetupVariables(wizard.SetupVariables, serverId); //save settings SetupVariables serverSetupVariables = wizard.SetupVariables.Clone(); //server password string serverPassword = serverSetupVariables.ServerPassword; if (string.IsNullOrEmpty(serverPassword)) { serverPassword = Guid.NewGuid().ToString("N").Substring(0, 10); } serverSetupVariables.ServerPassword = Utils.ComputeSHA1(serverPassword); //add password to config AppConfig.SetComponentSettingStringValue(serverSetupVariables.ComponentId, "Password", serverSetupVariables.ServerPassword); wizard.SetupVariables.RemoteServerPassword = serverPassword; //server url wizard.SetupVariables.RemoteServerUrl = GetUrl(serverSetupVariables.WebSiteDomain, serverSetupVariables.WebSiteIP, serverSetupVariables.WebSitePort); //******************** Portal **************** //general settings string portalId = Guid.NewGuid().ToString(); wizard.SetupVariables.PortalComponentId = portalId; wizard.SetupVariables.ComponentId = portalId; wizard.SetupVariables.Instance = string.Empty; wizard.SetupVariables.ComponentName = "Portal"; wizard.SetupVariables.ComponentCode = "portal"; wizard.SetupVariables.ComponentDescription = "WebsitePanel Portal is a control panel itself with user interface which allows managing user accounts, hosting spaces, web sites, FTP accounts, files, etc."; wizard.SetupVariables.InstallerFolder = Path.Combine(Utils.GetStringSetupParameter(args, "InstallerFolder"), "Portal"); wizard.SetupVariables.InstallerType = Utils.GetStringSetupParameter(args, "InstallerType").Replace("StandaloneServerSetup", "Portal"); wizard.SetupVariables.InstallationFolder = Path.Combine(Utils.GetSystemDrive(), "WebsitePanel\\Portal"); //web settings wizard.SetupVariables.UserAccount = "WPPortal"; wizard.SetupVariables.UserPassword = Guid.NewGuid().ToString("P"); wizard.SetupVariables.UserDomain = null; wizard.SetupVariables.WebSiteIP = string.Empty; //empty - to detect IP wizard.SetupVariables.WebSitePort = "9001"; wizard.SetupVariables.WebSiteDomain = string.Empty; wizard.SetupVariables.NewWebSite = true; wizard.SetupVariables.NewVirtualDirectory = false; wizard.SetupVariables.UserMembership = (wizard.SetupVariables.IISVersion.Major == 7) ? new string[] { "IIS_IUSRS" } : new string[] { "IIS_WPG" }; wizard.SetupVariables.ConfigurationFile = "web.config"; //ES url wizard.SetupVariables.EnterpriseServerURL = "http://127.0.0.1:9002"; //Unattended setup LoadComponentVariablesFromSetupXml(wizard.SetupVariables.ComponentCode, wizard.SetupVariables.SetupXml, wizard.SetupVariables); //create component settings node wizard.SetupVariables.ComponentConfig = AppConfig.CreateComponentConfig(portalId); //add default component settings CreateComponentSettingsFromSetupVariables(wizard.SetupVariables, portalId); //save settings SetupVariables portalSetupVariables = wizard.SetupVariables.Clone(); //******************** Enterprise Server **************** //general settings string enterpriseServerId = Guid.NewGuid().ToString(); wizard.SetupVariables.EnterpriseServerComponentId = enterpriseServerId; wizard.SetupVariables.ComponentId = enterpriseServerId; wizard.SetupVariables.Instance = string.Empty; wizard.SetupVariables.ComponentName = "Enterprise Server"; wizard.SetupVariables.ComponentCode = "enterprise server"; wizard.SetupVariables.ComponentDescription = "Enterprise Server is the heart of WebsitePanel system. It includes all business logic of the application. Enterprise Server should have access to Server and be accessible from Portal applications."; wizard.SetupVariables.InstallerFolder = Path.Combine(Utils.GetStringSetupParameter(args, "InstallerFolder"), "Enterprise Server"); wizard.SetupVariables.InstallerType = Utils.GetStringSetupParameter(args, "InstallerType").Replace("StandaloneServerSetup", "EnterpriseServer"); wizard.SetupVariables.InstallationFolder = Path.Combine(Utils.GetSystemDrive(), "WebsitePanel\\Enterprise Server"); //web settings wizard.SetupVariables.UserAccount = "WPEnterpriseServer"; wizard.SetupVariables.UserPassword = Guid.NewGuid().ToString("P"); wizard.SetupVariables.UserDomain = null; wizard.SetupVariables.WebSiteIP = "127.0.0.1"; wizard.SetupVariables.WebSitePort = "9002"; wizard.SetupVariables.WebSiteDomain = string.Empty; wizard.SetupVariables.NewWebSite = true; wizard.SetupVariables.NewVirtualDirectory = false; wizard.SetupVariables.UserMembership = (wizard.SetupVariables.IISVersion.Major == 7) ? new string[] { "IIS_IUSRS" } : new string[] { "IIS_WPG" }; wizard.SetupVariables.ConfigurationFile = "web.config"; //db settings wizard.SetupVariables.DatabaseServer = "localhost\\sqlexpress"; wizard.SetupVariables.Database = "WebsitePanel"; wizard.SetupVariables.CreateDatabase = true; //serveradmin settings wizard.SetupVariables.UpdateServerAdminPassword = true; wizard.SetupVariables.ServerAdminPassword = string.Empty; //Unattended setup LoadComponentVariablesFromSetupXml(wizard.SetupVariables.ComponentCode, wizard.SetupVariables.SetupXml, wizard.SetupVariables); //create component settings node wizard.SetupVariables.ComponentConfig = AppConfig.CreateComponentConfig(enterpriseServerId); //add default component settings CreateComponentSettingsFromSetupVariables(wizard.SetupVariables, enterpriseServerId); //save settings SetupVariables enterpiseServerSetupVariables = wizard.SetupVariables.Clone(); /////////////////////// //create wizard pages IntroductionPage introPage = new IntroductionPage(); LicenseAgreementPage licPage = new LicenseAgreementPage(); ConfigurationCheckPage page2 = new ConfigurationCheckPage(); ConfigurationCheck check1 = new ConfigurationCheck(CheckTypes.OperationSystem, "Operating System Requirement"); ConfigurationCheck check2 = new ConfigurationCheck(CheckTypes.IISVersion, "IIS Requirement"); ConfigurationCheck check3 = new ConfigurationCheck(CheckTypes.ASPNET, "ASP.NET Requirement"); ConfigurationCheck check4 = new ConfigurationCheck(CheckTypes.WPServer, "WebsitePanel Server Requirement"); check4.SetupVariables = serverSetupVariables; ConfigurationCheck check5 = new ConfigurationCheck(CheckTypes.WPEnterpriseServer, "WebsitePanel Enterprise Server Requirement"); check5.SetupVariables = enterpiseServerSetupVariables; ConfigurationCheck check6 = new ConfigurationCheck(CheckTypes.WPPortal, "WebsitePanel Portal Requirement"); check6.SetupVariables = portalSetupVariables; page2.Checks.AddRange(new ConfigurationCheck[] { check1, check2, check3, check4, check5, check6 }); WebPage page3 = new WebPage(); //use portal settings for this page page3.SetupVariables = portalSetupVariables; DatabasePage page4 = new DatabasePage(); //use ES settings for this page page4.SetupVariables = enterpiseServerSetupVariables; ServerAdminPasswordPage page5 = new ServerAdminPasswordPage(); page5.SetupVariables = enterpiseServerSetupVariables; page5.NoteText = "Note: Both serveradmin and admin accounts will use this password. You can always change password for serveradmin or admin accounts through control panel."; ExpressInstallPage page6 = new ExpressInstallPage(); wizard.SetupVariables.ComponentName = string.Empty; //create install actions //************ Server ************** InstallAction action = new InstallAction(ActionTypes.InitSetupVariables); action.Description = "Installing WebsitePanel Server..."; action.SetupVariables = serverSetupVariables; page6.Actions.Add(action); action = new InstallAction(ActionTypes.CopyFiles); action.Description = "Copying files..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.CreateWebSite); action.Description = "Creating web site..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.FolderPermissions); action.Description = "Configuring folder permissions..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.ServerPassword); action.Description = "Setting server password..."; page6.Actions.Add(action); //************* Enterprise server ********* action = new InstallAction(ActionTypes.InitSetupVariables); action.Description = "Installing WebsitePanel Enterprise Server..."; action.SetupVariables = enterpiseServerSetupVariables; page6.Actions.Add(action); action = new InstallAction(ActionTypes.CopyFiles); action.Description = "Copying files..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.CreateWebSite); action.Description = "Creating web site..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.CryptoKey); action.Description = "Generating crypto key..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.CreateDatabase); action.Description = "Creating SQL Server database..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.CreateDatabaseUser); action.Description = "Creating SQL Server user..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.ExecuteSql); action.Description = "Creating database objects..."; action.Path = "setup\\install_db.sql"; page6.Actions.Add(action); action = new InstallAction(ActionTypes.CreateWPServerLogin); action.Description = "Creating WebsitePanel login..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.UpdateServerAdminPassword); action.Description = "Updating serveradmin password..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.UpdateLicenseInformation); action.Description = "Updating license information..."; page6.Actions.Add(action); //************* Portal ********* action = new InstallAction(ActionTypes.InitSetupVariables); action.Description = "Installing WebsitePanel Portal..."; action.SetupVariables = portalSetupVariables; page6.Actions.Add(action); action = new InstallAction(ActionTypes.CopyFiles); action.Description = "Copying files..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.CopyWebConfig); action.Description = "Copying web.config..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.CreateWebSite); action.Description = "Creating web site..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.UpdateEnterpriseServerUrl); action.Description = "Updating site settings..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.UpdateConfig); action.Description = "Updating system configuration..."; page6.Actions.Add(action); action = new InstallAction(ActionTypes.CreateShortcuts); action.Description = "Creating shortcut..."; page6.Actions.Add(action); //************* Standalone server provisioning ********* action = new InstallAction(ActionTypes.InitSetupVariables); action.SetupVariables = enterpiseServerSetupVariables; page6.Actions.Add(action); action = new InstallAction(ActionTypes.ConfigureStandaloneServerData); action.Description = "Configuring server data..."; action.Url = portalSetupVariables.EnterpriseServerURL; page6.Actions.Add(action); SetupCompletePage page7 = new SetupCompletePage(); page7.SetupVariables = portalSetupVariables; wizard.Controls.AddRange(new Control[] { introPage, licPage, page2, page3, page4, page5, page6, page7 }); wizard.LinkPages(); wizard.SelectedPage = introPage; //show wizard IWin32Window owner = args["ParentForm"] as IWin32Window; return(form.ShowModal(owner)); }