/// <summary> /// Beware: Web site component-dependent logic /// </summary> /// <param name="setupVariables"></param> /// <returns></returns> public static string ResolveAspNet40RegistrationToolPath_Iis7(SetupVariables setupVariables) { // By default we fallback to the corresponding tool version based on the platform bitness var util = Environment.Is64BitOperatingSystem ? AspNet40RegistrationToolx64 : AspNet40RegistrationToolx86; // Choose appropriate tool version for IIS 7 if (setupVariables.IISVersion.Major == 7 && setupVariables.SetupAction == SetupActions.Update) { // Evaluate app pool settings on x64 platform only when update is running if (Environment.Is64BitOperatingSystem == true) { // Change to x86 tool version if the component's app pool is in WOW64 mode using (var srvman = new Microsoft.Web.Administration.ServerManager()) { // Retrieve the component's app pool var appPoolObj = srvman.ApplicationPools[setupVariables.WebApplicationPoolName]; // We are if (appPoolObj == null) { throw new ArgumentException(String.Format("Could not find '{0}' web application pool", setupVariables.WebApplicationPoolName), "appPoolObj"); } // Check app pool mode else if (appPoolObj.Enable32BitAppOnWin64 == true) { util = AspNet40RegistrationToolx86; } } } } // Build path to the tool return(Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), util)); }
public static DialogResult UninstallBase(object obj) { Hashtable args = Utils.GetSetupParameters(obj); string shellVersion = Utils.GetStringSetupParameter(args, Global.Parameters.ShellVersion); var setupVariables = new SetupVariables { ComponentId = Utils.GetStringSetupParameter(args, Global.Parameters.ComponentId), ComponentCode = Utils.GetStringSetupParameter(args, Global.Parameters.ComponentCode), SetupAction = SetupActions.Uninstall, IISVersion = Global.IISVersion }; // AppConfig.LoadConfiguration(); InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; wizard.SetupVariables = setupVariables; // AppConfig.LoadComponentSettings(wizard.SetupVariables); IntroductionPage page1 = new IntroductionPage(); ConfirmUninstallPage page2 = new ConfirmUninstallPage(); UninstallPage page3 = new UninstallPage(); page2.UninstallPage = page3; FinishPage page4 = new FinishPage(); wizard.Controls.AddRange(new Control[] { page1, page2, page3, page4 }); wizard.LinkPages(); wizard.SelectedPage = page1; //show wizard IWin32Window owner = args[Global.Parameters.ParentForm] as IWin32Window; return form.ShowModal(owner); }
public static object Update(object obj) { Hashtable args = Utils.GetSetupParameters(obj); var setupVariables = new SetupVariables { ComponentId = Utils.GetStringSetupParameter(args, Global.Parameters.ComponentId), SetupAction = SetupActions.Update, BaseDirectory = Utils.GetStringSetupParameter(args, Global.Parameters.BaseDirectory), UpdateVersion = Utils.GetStringSetupParameter(args, "UpdateVersion"), InstallerFolder = Utils.GetStringSetupParameter(args, Global.Parameters.InstallerFolder), Installer = Utils.GetStringSetupParameter(args, Global.Parameters.Installer), InstallerType = Utils.GetStringSetupParameter(args, Global.Parameters.InstallerType), InstallerPath = Utils.GetStringSetupParameter(args, Global.Parameters.InstallerPath) }; AppConfig.LoadConfiguration(); InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; // wizard.SetupVariables = setupVariables; // AppConfig.LoadComponentSettings(wizard.SetupVariables); IntroductionPage introPage = new IntroductionPage(); LicenseAgreementPage licPage = new LicenseAgreementPage(); ExpressInstallPage page2 = new ExpressInstallPage(); //create install currentScenario InstallAction action = new InstallAction(ActionTypes.Backup); action.Description = "Backing up..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.DeleteFiles); action.Description = "Deleting files..."; action.Path = "setup\\delete.txt"; page2.Actions.Add(action); action = new InstallAction(ActionTypes.CopyFiles); action.Description = "Copying files..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.UpdateConfig); action.Description = "Updating system configuration..."; page2.Actions.Add(action); FinishPage page3 = new FinishPage(); wizard.Controls.AddRange(new Control[] { introPage, licPage, page2, page3 }); wizard.LinkPages(); wizard.SelectedPage = introPage; //show wizard IWin32Window owner = args[Global.Parameters.ParentForm] as IWin32Window; return(form.ShowModal(owner)); }
public static DialogResult Update(object obj) { Hashtable args = Utils.GetSetupParameters(obj); var setupVariables = new SetupVariables { ComponentId = Utils.GetStringSetupParameter(args, Global.Parameters.ComponentId), SetupAction = SetupActions.Update, IISVersion = Global.IISVersion }; AppConfig.LoadConfiguration(); InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; wizard.SetupVariables = setupVariables; // AppConfig.LoadComponentSettings(wizard.SetupVariables); IntroductionPage introPage = new IntroductionPage(); LicenseAgreementPage licPage = new LicenseAgreementPage(); ExpressInstallPage page2 = new ExpressInstallPage(); //create install currentScenario InstallAction action = new InstallAction(ActionTypes.Backup); action.Description = "Backing up..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.DeleteFiles); action.Description = "Deleting files..."; action.Path = "setup\\delete.txt"; page2.Actions.Add(action); action = new InstallAction(ActionTypes.CopyFiles); action.Description = "Copying files..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.ExecuteSql); action.Description = "Updating database..."; action.Path = "setup\\update_db.sql"; page2.Actions.Add(action); action = new InstallAction(ActionTypes.UpdateConfig); action.Description = "Updating system configuration..."; page2.Actions.Add(action); FinishPage page3 = new FinishPage(); wizard.Controls.AddRange(new Control[] { introPage, licPage, page2, page3 }); wizard.LinkPages(); wizard.SelectedPage = introPage; //show wizard Form parentForm = args[Global.Parameters.ParentForm] as Form; return(form.ShowDialog(parentForm)); }
public static void LoadSetupVariablesFromConfig(SetupVariables vars, string componentId) { vars.InstallationFolder = AppConfig.GetComponentSettingStringValue(componentId, "InstallFolder"); vars.ComponentName = AppConfig.GetComponentSettingStringValue(componentId, "ComponentName"); vars.ComponentCode = AppConfig.GetComponentSettingStringValue(componentId, "ComponentCode"); vars.ComponentDescription = AppConfig.GetComponentSettingStringValue(componentId, "ComponentDescription"); vars.ComponentId = componentId; vars.ApplicationName = AppConfig.GetComponentSettingStringValue(componentId, "ApplicationName"); vars.Version = AppConfig.GetComponentSettingStringValue(componentId, "Release"); vars.Instance = AppConfig.GetComponentSettingStringValue(componentId, "Instance"); }
public static object Setup(object obj) { var args = Utils.GetSetupParameters(obj); var shellVersion = Utils.GetStringSetupParameter(args, Global.Parameters.ShellVersion); // var setupVariables = new SetupVariables { ComponentId = Utils.GetStringSetupParameter(args, Global.Parameters.ComponentId), SetupAction = SetupActions.Setup, IISVersion = Global.IISVersion, ConfigurationFile = "web.config" }; // AppConfig.LoadConfiguration(); InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; // wizard.SetupVariables = setupVariables; // AppConfig.LoadComponentSettings(wizard.SetupVariables); WebPage page1 = new WebPage(); ServerPasswordPage page2 = new ServerPasswordPage(); ExpressInstallPage page3 = new ExpressInstallPage(); //create install actions InstallAction action = new InstallAction(ActionTypes.UpdateWebSite); action.Description = "Updating web site..."; page3.Actions.Add(action); action = new InstallAction(ActionTypes.UpdateServerPassword); action.Description = "Updating server password..."; page3.Actions.Add(action); action = new InstallAction(ActionTypes.UpdateConfig); action.Description = "Updating system configuration..."; page3.Actions.Add(action); FinishPage page4 = new FinishPage(); wizard.Controls.AddRange(new Control[] { page1, page2, page3, page4 }); wizard.LinkPages(); wizard.SelectedPage = page1; //show wizard IWin32Window owner = args[Global.Parameters.ParentForm] as IWin32Window; return(form.ShowModal(owner)); }
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); }
private bool SiteBindingsExist(SetupVariables setupVariables) { bool iis7 = (setupVariables.IISVersion.Major == 7); string ip = setupVariables.WebSiteIP; string port = setupVariables.WebSitePort; string domain = setupVariables.WebSiteDomain; string siteId = iis7 ? WebUtils.GetIIS7SiteIdByBinding(ip, port, domain) : WebUtils.GetSiteIdByBinding(ip, port, domain); return(siteId != null); }
private void InitSetupVaribles(SetupVariables setupVariables) { try { Wizard.SetupVariables = setupVariables.Clone(); } catch (Exception ex) { if (Utils.IsThreadAbortException(ex)) { return; } } }
public static bool CheckAspNet40Registered(SetupVariables setupVariables) { // var aspNet40Registered = false; // Run ASP.NET Registration Tool command var psOutput = ExecAspNetRegistrationToolCommand(setupVariables, "-lv"); // Split process output per lines var strLines = psOutput.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); // Lookup for an evidence of ASP.NET 4.0 aspNet40Registered = strLines.Any((string s) => { return(s.Contains("4.0.30319.0")); }); // return(aspNet40Registered); }
public static string ExecAspNetRegistrationToolCommand(SetupVariables setupVariables, string arguments) { // var util = (setupVariables.IISVersion.Major == 6) ? Utils.ResolveAspNet40RegistrationToolPath_Iis6(setupVariables) : Utils.ResolveAspNet40RegistrationToolPath_Iis7(setupVariables); // // Create a specific process start info set to redirect its standard output for further processing ProcessStartInfo info = new ProcessStartInfo(util) { WindowStyle = ProcessWindowStyle.Hidden, UseShellExecute = false, RedirectStandardOutput = true, Arguments = arguments }; // Log.WriteInfo(String.Format("Starting aspnet_regiis.exe {0}", info.Arguments)); // var process = default(Process); // var psOutput = String.Empty; // try { // Start the process process = Process.Start(info); // Read the output psOutput = process.StandardOutput.ReadToEnd(); // Wait for the completion process.WaitForExit(); } catch (Exception ex) { Log.WriteError("Could not execute ASP.NET Registration Tool command", ex); } finally { if (process != null) { process.Close(); } } // Trace output data for troubleshooting purposes Log.WriteInfo(psOutput); // Log.WriteInfo(String.Format("Finished aspnet_regiis.exe {0}", info.Arguments)); // return(psOutput); }
public static void InitInstall(Hashtable args, SetupVariables vars) { AppConfig.LoadConfiguration(); LoadSetupVariablesFromParameters(vars, args); vars.SetupAction = SetupActions.Install; vars.InstallationFolder = Path.Combine(Global.DefaultInstallPathRoot, vars.ComponentName); vars.ComponentId = Guid.NewGuid().ToString(); vars.Instance = String.Empty; //create component settings node //vars.ComponentConfig = AppConfig.CreateComponentConfig(vars.ComponentId); //add default component settings //CreateComponentSettingsFromSetupVariables(vars, vars.ComponentId); }
public static WebExtensionStatus GetAspNetWebExtensionStatus_Iis6(SetupVariables setupVariables) { WebExtensionStatus status = WebExtensionStatus.Allowed; if (setupVariables.IISVersion.Major == 6) { status = WebExtensionStatus.NotInstalled; string path; if (Utils.IsWin64() && !Utils.IIS32Enabled()) { //64-bit path = Path.Combine(OS.GetWindowsDirectory(), @"Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll"); } else { //32-bit path = Path.Combine(OS.GetWindowsDirectory(), @"Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll"); } path = path.ToLower(); using (DirectoryEntry iis = new DirectoryEntry("IIS://LocalHost/W3SVC")) { PropertyValueCollection values = iis.Properties["WebSvcExtRestrictionList"]; for (int i = 0; i < values.Count; i++) { string val = values[i] as string; if (!string.IsNullOrEmpty(val)) { string strVal = val.ToString().ToLower(); if (strVal.Contains(path)) { if (strVal[0] == '1') { status = WebExtensionStatus.Allowed; } else { status = WebExtensionStatus.Prohibited; } break; } } } } } return(status); }
internal static CheckStatuses CheckOS(SetupVariables setupVariables, out string details) { details = string.Empty; try { //check OS version OS.WindowsVersion version = OS.GetVersion(); details = OS.GetName(version); if (Utils.IsWin64()) { details += " x64"; } Log.WriteInfo(string.Format("OS check: {0}", details)); if (!(version == OS.WindowsVersion.WindowsServer2003 || version == OS.WindowsVersion.WindowsServer2008 || version == OS.WindowsVersion.WindowsServer2008R2 || version == OS.WindowsVersion.WindowsServer2012 || version == OS.WindowsVersion.WindowsServer2012R2 || version == OS.WindowsVersion.WindowsVista || version == OS.WindowsVersion.Windows7 || version == OS.WindowsVersion.Windows8 || version == OS.WindowsVersion.Win32NTServer || version == OS.WindowsVersion.Win32NTWorkstation )) { details = "OS required: Windows Server 2008/2008 R2/2012 or Windows Vista/7/8."; Log.WriteError(string.Format("OS check: {0}", details), null); #if DEBUG return(CheckStatuses.Warning); #endif #if !DEBUG return(CheckStatuses.Error); #endif } return(CheckStatuses.Success); } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) { Log.WriteError("Check error", ex); } details = "Unexpected error"; return(CheckStatuses.Error); } }
public static string ResolveAspNet40RegistrationToolPath_Iis6(SetupVariables setupVariables) { // By default we fallback to the corresponding tool version based on the platform bitness var util = Environment.Is64BitOperatingSystem ? AspNet40RegistrationToolx64 : AspNet40RegistrationToolx86; // Choose appropriate tool version for IIS 6 if (setupVariables.IISVersion.Major == 6) { // Change to x86 tool version on x64 w/ "Enable32bitAppOnWin64" flag enabled if (Environment.Is64BitOperatingSystem == true && Utils.IIS32Enabled()) { util = AspNet40RegistrationToolx86; } } // Build path to the tool return(Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), util)); }
public static DialogResult Uninstall(object obj) { Hashtable args = Utils.GetSetupParameters(obj); string shellVersion = Utils.GetStringSetupParameter(args, Global.Parameters.ShellVersion); // var setupVariables = new SetupVariables { ComponentId = Utils.GetStringSetupParameter(args, Global.Parameters.ComponentId), IISVersion = Global.IISVersion, SetupAction = SetupActions.Uninstall }; // AppConfig.LoadConfiguration(); InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; wizard.SetupVariables = setupVariables; // AppConfig.LoadComponentSettings(wizard.SetupVariables); // IntroductionPage page1 = new IntroductionPage(); ConfirmUninstallPage page2 = new ConfirmUninstallPage(); UninstallPage page3 = new UninstallPage(); //create uninstall currentScenario InstallAction action = new InstallAction(ActionTypes.DeleteShortcuts); action.Description = "Deleting shortcuts..."; action.Log = "- Delete shortcuts"; action.Name = "Login to WebsitePanel.url"; page3.Actions.Add(action); page2.UninstallPage = page3; FinishPage page4 = new FinishPage(); wizard.Controls.AddRange(new Control[] { page1, page2, page3, page4 }); wizard.LinkPages(); wizard.SelectedPage = page1; //show wizard IWin32Window owner = args[Global.Parameters.ParentForm] as IWin32Window; return(form.ShowModal(owner)); }
private bool CheckDiskSpace(SetupVariables setupVariables, out string details) { details = string.Empty; long spaceRequired = FileUtils.CalculateFolderSize(setupVariables.InstallerFolder); if (string.IsNullOrEmpty(setupVariables.InstallationFolder)) { details = "Installation folder is not specified."; return(false); } string drive = null; try { drive = Path.GetPathRoot(Path.GetFullPath(setupVariables.InstallationFolder)); } catch { details = "Installation folder is invalid."; return(false); } ulong freeBytesAvailable, totalBytes, freeBytes; if (FileUtils.GetDiskFreeSpaceEx(drive, out freeBytesAvailable, out totalBytes, out freeBytes)) { long freeSpace = Convert.ToInt64(freeBytesAvailable); if (spaceRequired > freeSpace) { details = string.Format("There is not enough space on the disk ({0} required, {1} available)", FileUtils.SizeToMB(spaceRequired), FileUtils.SizeToMB(freeSpace)); return(false); } } else { details = "I/O error"; return(false); } return(true); }
internal static CheckStatuses CheckIIS32Mode(SetupVariables setupVariables, out string details) { details = string.Empty; CheckStatuses ret = CheckIISVersion(setupVariables, out details); if (ret == CheckStatuses.Error) { return(ret); } try { //IIS 6 if (setupVariables.IISVersion.Major == 6) { //x64 if (Utils.IsWin64()) { if (!Utils.IIS32Enabled()) { Log.WriteInfo("IIS 32-bit mode disabled"); EnableIIS32Mode(); details = "IIS 32-bit mode has been enabled."; Log.WriteInfo(string.Format("IIS 32-bit mode check: {0}", details)); return(CheckStatuses.Warning); } } } return(CheckStatuses.Success); } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) { Log.WriteError("Check error", ex); } details = "Unexpected error"; return(CheckStatuses.Error); } }
private CheckStatuses CheckWPEnterpriseServer(SetupVariables setupVariables, out string details) { details = ""; try { if (SiteBindingsExist(setupVariables)) { details = string.Format("Site with specified bindings already exists (ip: {0}, port: {1}, domain: {2})", setupVariables.WebSiteIP, setupVariables.WebSitePort, setupVariables.WebSiteDomain); Log.WriteError(string.Format("Site bindings check: {0}", details), null); return(CheckStatuses.Error); } if (AccountExists(setupVariables)) { details = string.Format("Windows account already exists: {0}\\{1}", setupVariables.UserDomain, setupVariables.UserAccount); Log.WriteError(string.Format("Account check: {0}", details), null); return(CheckStatuses.Error); } if (!CheckDiskSpace(setupVariables, out details)) { Log.WriteError(string.Format("Disk space check: {0}", details), null); return(CheckStatuses.Error); } return(CheckStatuses.Success); } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) { Log.WriteError("Check error", ex); } details = "Unexpected error"; return(CheckStatuses.Error); } }
public static object Uninstall(object obj) { Hashtable args = Utils.GetSetupParameters(obj); // string shellVersion = Utils.GetStringSetupParameter(args, Global.Parameters.ShellVersion); // var setupVariables = new SetupVariables { ComponentId = Utils.GetStringSetupParameter(args, Global.Parameters.ComponentId), SetupAction = SetupActions.Uninstall, IISVersion = Global.IISVersion }; // AppConfig.LoadConfiguration(); InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; wizard.SetupVariables = setupVariables; AppConfig.LoadComponentSettings(wizard.SetupVariables); IntroductionPage page1 = new IntroductionPage(); ConfirmUninstallPage page2 = new ConfirmUninstallPage(); UninstallPage page3 = new UninstallPage(); page2.UninstallPage = page3; FinishPage page4 = new FinishPage(); wizard.Controls.AddRange(new Control[] { page1, page2, page3, page4 }); wizard.LinkPages(); wizard.SelectedPage = page1; //show wizard IWin32Window owner = args[Global.Parameters.ParentForm] as IWin32Window; return(form.ShowModal(owner)); }
public static string ExecAspNetRegistrationToolCommand(SetupVariables setupVariables, string arguments) { // var util = (setupVariables.IISVersion.Major == 6) ? Utils.ResolveAspNet40RegistrationToolPath_Iis6(setupVariables) : Utils.ResolveAspNet40RegistrationToolPath_Iis7(setupVariables); // // Create a specific process start info set to redirect its standard output for further processing ProcessStartInfo info = new ProcessStartInfo(util) { WindowStyle = ProcessWindowStyle.Hidden, UseShellExecute = false, RedirectStandardOutput = true, Arguments = arguments }; // Log.WriteInfo(String.Format("Starting aspnet_regiis.exe {0}", info.Arguments)); // var process = default(Process); // var psOutput = String.Empty; // try { // Start the process process = Process.Start(info); // Read the output psOutput = process.StandardOutput.ReadToEnd(); // Wait for the completion process.WaitForExit(); } catch (Exception ex) { Log.WriteError("Could not execute ASP.NET Registration Tool command", ex); } finally { if (process != null) process.Close(); } // Trace output data for troubleshooting purposes Log.WriteInfo(psOutput); // Log.WriteInfo(String.Format("Finished aspnet_regiis.exe {0}", info.Arguments)); // return psOutput; }
/// <summary> /// Beware: Web site component-dependent logic /// </summary> /// <param name="setupVariables"></param> /// <returns></returns> public static string ResolveAspNet40RegistrationToolPath_Iis7(SetupVariables setupVariables) { // By default we fallback to the corresponding tool version based on the platform bitness var util = Environment.Is64BitOperatingSystem ? AspNet40RegistrationToolx64 : AspNet40RegistrationToolx86; // Choose appropriate tool version for IIS 7 if (setupVariables.IISVersion.Major == 7 && setupVariables.SetupAction == SetupActions.Update) { // Evaluate app pool settings on x64 platform only when update is running if (Environment.Is64BitOperatingSystem == true) { // Change to x86 tool version if the component's app pool is in WOW64 mode using (var srvman = new Microsoft.Web.Administration.ServerManager()) { // Retrieve the component's app pool var appPoolObj = srvman.ApplicationPools[setupVariables.WebApplicationPoolName]; // We are if (appPoolObj == null) { throw new ArgumentException(String.Format("Could not find '{0}' web application pool", setupVariables.WebApplicationPoolName), "appPoolObj"); } // Check app pool mode else if (appPoolObj.Enable32BitAppOnWin64 == true) { util = AspNet40RegistrationToolx86; } } } } // Build path to the tool return Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), util); }
public static void LoadComponentSettings(SetupVariables vars) { XmlNode componentNode = GetComponentConfig(vars.ComponentId); // if (componentNode != null) { var typeRef = vars.GetType(); // XmlNodeList settingNodes = componentNode.SelectNodes("settings/add"); // foreach (XmlNode item in settingNodes) { var sName = XmlUtils.GetXmlAttribute(item, "key"); var sValue = XmlUtils.GetXmlAttribute(item, "value"); // if (String.IsNullOrEmpty(sName)) continue; // var objProperty = typeRef.GetProperty(sName); // if (objProperty == null) continue; // Set property value objProperty.SetValue(vars, Convert.ChangeType(sValue, objProperty.PropertyType), null); } } }
public static ActionResult OnSchedulerPrepare(Session Ctx) { PopUpDebugger(); Ctx.AttachToSetupLog(); Log.WriteStart("OnSchedulerPrepare"); try { var ServiceName = Global.Parameters.SchedulerServiceName; var ServiceFile = string.Empty; ManagementClass WmiService = new ManagementClass("Win32_Service"); foreach (var MObj in WmiService.GetInstances()) { if (MObj.GetPropertyValue("Name").ToString().Equals(ServiceName, StringComparison.CurrentCultureIgnoreCase)) { ServiceFile = MObj.GetPropertyValue("PathName").ToString(); break; } } if (!string.IsNullOrWhiteSpace(ServiceName) && !string.IsNullOrWhiteSpace(ServiceFile)) { var CtxVars = new SetupVariables() { ServiceName = ServiceName, ServiceFile = ServiceFile }; var Script = new BackupSchedulerScript(CtxVars); Script.Actions.Add(new InstallAction(ActionTypes.UnregisterWindowsService) { Name = ServiceName, Path = ServiceFile, Description = "Removing Windows service...", Log = string.Format("- Remove {0} Windows service", ServiceName) }); Script.Context.ServiceName = Global.Parameters.SchedulerServiceName; Script.Run(); } } catch (Exception ex) { Log.WriteError(ex.ToString()); } Log.WriteEnd("OnSchedulerPrepare"); return ActionResult.Success; }
internal static object InstallBase(object obj, string minimalInstallerVersion) { Hashtable args = Utils.GetSetupParameters(obj); //check CS version var shellMode = Utils.GetStringSetupParameter(args, Global.Parameters.ShellMode); var version = new Version(Utils.GetStringSetupParameter(args, Global.Parameters.ShellVersion)); var setupVariables = new SetupVariables { SetupAction = SetupActions.Install, ConfigurationFile = "web.config", WebSiteIP = Global.WebPortal.DefaultIP, //empty - to detect IP WebSitePort = Global.WebPortal.DefaultPort, WebSiteDomain = String.Empty, NewWebSite = true, NewVirtualDirectory = false, EnterpriseServerURL = Global.WebPortal.DefaultEntServURL }; // InitInstall(args, setupVariables); // var wam = new WebPortalActionManager(setupVariables); // wam.PrepareDistributiveDefaults(); // if (shellMode.Equals(Global.SilentInstallerShell, StringComparison.OrdinalIgnoreCase)) { if (version < new Version(minimalInstallerVersion)) { Utils.ShowConsoleErrorMessage(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion); // return(false); } try { var success = true; // setupVariables.EnterpriseServerURL = Utils.GetStringSetupParameter(args, Global.Parameters.EnterpriseServerUrl); // wam.ActionError += new EventHandler <ActionErrorEventArgs>((object sender, ActionErrorEventArgs e) => { Utils.ShowConsoleErrorMessage(e.ErrorMessage); // Log.WriteError(e.ErrorMessage); // success = false; }); // wam.Start(); // return(success); } catch (Exception ex) { Log.WriteError("Failed to install the component", ex); // return(false); } } else { if (version < new Version(minimalInstallerVersion)) { // MessageBox.Show(String.Format(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion), "Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return(DialogResult.Cancel); } // InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; wizard.SetupVariables = setupVariables; wizard.ActionManager = wam; //Unattended setup LoadSetupVariablesFromSetupXml(wizard.SetupVariables.SetupXml, wizard.SetupVariables); //create wizard pages var introPage = new IntroductionPage(); var licPage = new LicenseAgreementPage(); var page1 = 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"); page1.Checks.AddRange(new ConfigurationCheck[] { check1, check2, check3 }); var page2 = new InstallFolderPage(); var page3 = new WebPage(); var page4 = new UserAccountPage(); var page5 = new UrlPage(); var page6 = new ExpressInstallPage2(); var page7 = new FinishPage(); wizard.Controls.AddRange(new Control[] { introPage, licPage, page1, page2, page3, page4, page5, page6, page7 }); wizard.LinkPages(); wizard.SelectedPage = introPage; //show wizard IWin32Window owner = args[Global.Parameters.ParentForm] as IWin32Window; return(form.ShowModal(owner)); } }
internal static CheckStatuses CheckOS(SetupVariables setupVariables, out string details) { details = string.Empty; try { //check OS version OS.WindowsVersion version = OS.GetVersion(); details = OS.GetName(version); if (Utils.IsWin64()) details += " x64"; Log.WriteInfo(string.Format("OS check: {0}", details)); if (!(version == OS.WindowsVersion.WindowsServer2003 || version == OS.WindowsVersion.WindowsServer2008 || version == OS.WindowsVersion.WindowsServer2008R2 || version == OS.WindowsVersion.WindowsServer2012 || version == OS.WindowsVersion.WindowsServer2012R2 || version == OS.WindowsVersion.WindowsVista || version == OS.WindowsVersion.Windows7 || version == OS.WindowsVersion.Windows8 || version == OS.WindowsVersion.Win32NTServer || version == OS.WindowsVersion.Win32NTWorkstation )) { details = "OS required: Windows Server 2008/2008 R2/2012 or Windows Vista/7/8."; Log.WriteError(string.Format("OS check: {0}", details), null); #if DEBUG return CheckStatuses.Warning; #endif #if !DEBUG return CheckStatuses.Error; #endif } return CheckStatuses.Success; } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) Log.WriteError("Check error", ex); details = "Unexpected error"; return CheckStatuses.Error; } }
private CheckStatuses CheckWPEnterpriseServer(SetupVariables setupVariables, out string details) { details = ""; try { if (SiteBindingsExist(setupVariables)) { details = string.Format("Site with specified bindings already exists (ip: {0}, port: {1}, domain: {2})", setupVariables.WebSiteIP, setupVariables.WebSitePort, setupVariables.WebSiteDomain); Log.WriteError(string.Format("Site bindings check: {0}", details), null); return CheckStatuses.Error; } if (AccountExists(setupVariables)) { details = string.Format("Windows account already exists: {0}\\{1}", setupVariables.UserDomain, setupVariables.UserAccount); Log.WriteError(string.Format("Account check: {0}", details), null); return CheckStatuses.Error; } if (!CheckDiskSpace(setupVariables, out details)) { Log.WriteError(string.Format("Disk space check: {0}", details), null); return CheckStatuses.Error; } return CheckStatuses.Success; } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) Log.WriteError("Check error", ex); details = "Unexpected error"; return CheckStatuses.Error; } }
private bool CheckDiskSpace(SetupVariables setupVariables, out string details) { details = string.Empty; long spaceRequired = FileUtils.CalculateFolderSize(setupVariables.InstallerFolder); if (string.IsNullOrEmpty(setupVariables.InstallationFolder)) { details = "Installation folder is not specified."; return false; } string drive = null; try { drive = Path.GetPathRoot(Path.GetFullPath(setupVariables.InstallationFolder)); } catch { details = "Installation folder is invalid."; return false; } ulong freeBytesAvailable, totalBytes, freeBytes; if (FileUtils.GetDiskFreeSpaceEx(drive, out freeBytesAvailable, out totalBytes, out freeBytes)) { long freeSpace = Convert.ToInt64(freeBytesAvailable); if (spaceRequired > freeSpace) { details = string.Format("There is not enough space on the disk ({0} required, {1} available)", FileUtils.SizeToMB(spaceRequired), FileUtils.SizeToMB(freeSpace)); return false; } } else { details = "I/O error"; return false; } return true; }
private bool AccountExists(SetupVariables setupVariables) { string domain = setupVariables.UserDomain; string username = setupVariables.UserAccount; return SecurityUtils.UserExists(domain, username); }
private bool SiteBindingsExist(SetupVariables setupVariables) { bool iis7 = (setupVariables.IISVersion.Major == 7); string ip = setupVariables.WebSiteIP; string port = setupVariables.WebSitePort; string domain = setupVariables.WebSiteDomain; string siteId = iis7 ? WebUtils.GetIIS7SiteIdByBinding(ip, port, domain) : WebUtils.GetSiteIdByBinding(ip, port, domain); return (siteId != null); }
internal static CheckStatuses CheckIISVersion(SetupVariables setupVariables, out string details) { details = string.Empty; try { details = string.Format("IIS {0}", setupVariables.IISVersion.ToString(2)); if (setupVariables.IISVersion.Major == 6 && Utils.IsWin64() && Utils.IIS32Enabled()) { details += " (32-bit mode)"; } Log.WriteInfo(string.Format("IIS check: {0}", details)); if (setupVariables.IISVersion.Major < 6) { details = "IIS 6.0 or greater required."; Log.WriteError(string.Format("IIS check: {0}", details), null); return CheckStatuses.Error; } return CheckStatuses.Success; } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) Log.WriteError("Check error", ex); details = "Unexpected error"; return CheckStatuses.Error; } }
internal static CheckStatuses CheckASPNET(SetupVariables setupVariables, out string details) { details = "ASP.NET 4.0 is installed."; CheckStatuses ret = CheckStatuses.Success; try { // IIS 6 if (setupVariables.IISVersion.Major == 6) { // if (Utils.CheckAspNet40Registered(setupVariables) == false) { // Register ASP.NET 4.0 Utils.RegisterAspNet40(setupVariables); // ret = CheckStatuses.Warning; details = AspNet40HasBeenInstalledMessage; } // Enable ASP.NET 4.0 Web Server Extension if it is prohibited if (Utils.GetAspNetWebExtensionStatus_Iis6(setupVariables) == WebExtensionStatus.Prohibited) { Utils.EnableAspNetWebExtension_Iis6(); } } // IIS 7 on Windows 2008 and higher else { if (!IsWebServerRoleInstalled()) { details = "Web Server (IIS) role is not installed on your server. Run Server Manager to add Web Server (IIS) role."; Log.WriteInfo(string.Format("ASP.NET check: {0}", details)); return(CheckStatuses.Error); } if (!IsAspNetRoleServiceInstalled()) { details = "ASP.NET role service is not installed on your server. Run Server Manager to add ASP.NET role service."; Log.WriteInfo(string.Format("ASP.NET check: {0}", details)); return(CheckStatuses.Error); } // Register ASP.NET 4.0 if (Utils.CheckAspNet40Registered(setupVariables) == false) { // Register ASP.NET 4.0 Utils.RegisterAspNet40(setupVariables); // ret = CheckStatuses.Warning; details = AspNet40HasBeenInstalledMessage; } } // Log details Log.WriteInfo(string.Format("ASP.NET check: {0}", details)); // return(ret); } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) { Log.WriteError("Check error", ex); } details = "Unexpected error"; #if DEBUG return(CheckStatuses.Warning); #endif #if !DEBUG return(CheckStatuses.Error); #endif } }
public static DialogResult Setup(object obj) { Hashtable args = Utils.GetSetupParameters(obj); string shellVersion = Utils.GetStringSetupParameter(args, "ShellVersion"); // var setupVariables = new SetupVariables { ComponentId = Utils.GetStringSetupParameter(args, Global.Parameters.ComponentId), ConfigurationFile = "web.config", IISVersion = Global.IISVersion, SetupAction = SetupActions.Setup }; // AppConfig.LoadConfiguration(); InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; wizard.SetupVariables = setupVariables; // AppConfig.LoadComponentSettings(wizard.SetupVariables); //IntroductionPage page1 = new IntroductionPage(); WebPage page1 = new WebPage(); ServerAdminPasswordPage page2 = new ServerAdminPasswordPage(); ExpressInstallPage page3 = new ExpressInstallPage(); //create install currentScenario InstallAction action = new InstallAction(ActionTypes.UpdateWebSite); action.Description = "Updating web site..."; page3.Actions.Add(action); action = new InstallAction(ActionTypes.UpdateServerAdminPassword); action.Description = "Updating serveradmin password..."; page3.Actions.Add(action); action = new InstallAction(ActionTypes.UpdateConfig); action.Description = "Updating system configuration..."; page3.Actions.Add(action); FinishPage page4 = new FinishPage(); wizard.Controls.AddRange(new Control[] { page1, page2, page3, page4 }); wizard.LinkPages(); wizard.SelectedPage = page1; //show wizard IWin32Window owner = args[Global.Parameters.ParentForm] as IWin32Window; return form.ShowModal(owner); }
internal static object InstallBase(object obj, string minimalInstallerVersion) { var args = Utils.GetSetupParameters(obj); //check CS version var shellVersion = Utils.GetStringSetupParameter(args, "ShellVersion"); var shellMode = Utils.GetStringSetupParameter(args, Global.Parameters.ShellMode); var version = new Version(shellVersion); var setupVariables = new SetupVariables { ConnectionString = Global.EntServer.AspNetConnectionStringFormat, DatabaseServer = Global.EntServer.DefaultDbServer, Database = Global.EntServer.DefaultDatabase, CreateDatabase = true, WebSiteIP = Global.EntServer.DefaultIP, WebSitePort = Global.EntServer.DefaultPort, WebSiteDomain = String.Empty, NewWebSite = true, NewVirtualDirectory = false, ConfigurationFile = "web.config", UpdateServerAdminPassword = true, ServerAdminPassword = "", }; // InitInstall(args, setupVariables); // var eam = new EntServerActionManager(setupVariables); // eam.PrepareDistributiveDefaults(); // if (shellMode.Equals(Global.SilentInstallerShell, StringComparison.OrdinalIgnoreCase)) { if (version < new Version(minimalInstallerVersion)) { Utils.ShowConsoleErrorMessage(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion); // return false; } try { var success = true; // setupVariables.ServerAdminPassword = Utils.GetStringSetupParameter(args, Global.Parameters.ServerAdminPassword); setupVariables.Database = Utils.GetStringSetupParameter(args, Global.Parameters.DatabaseName); setupVariables.DatabaseServer = Utils.GetStringSetupParameter(args, Global.Parameters.DatabaseServer); // setupVariables.DbInstallConnectionString = SqlUtils.BuildDbServerMasterConnectionString( setupVariables.DatabaseServer, Utils.GetStringSetupParameter(args, Global.Parameters.DbServerAdmin), Utils.GetStringSetupParameter(args, Global.Parameters.DbServerAdminPassword) ); // eam.ActionError += new EventHandler<ActionErrorEventArgs>((object sender, ActionErrorEventArgs e) => { Utils.ShowConsoleErrorMessage(e.ErrorMessage); // Log.WriteError(e.ErrorMessage); // success = false; }); // eam.Start(); // return success; } catch (Exception ex) { Log.WriteError("Failed to install the component", ex); // return false; } } else { if (version < new Version(minimalInstallerVersion)) { MessageBox.Show(string.Format(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion), "Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Warning); return DialogResult.Cancel; } InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; wizard.SetupVariables = setupVariables; wizard.ActionManager = eam; //Unattended setup LoadSetupVariablesFromSetupXml(wizard.SetupVariables.SetupXml, wizard.SetupVariables); //create wizard pages var introPage = new IntroductionPage(); var licPage = new LicenseAgreementPage(); var page1 = 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"); // page1.Checks.AddRange(new ConfigurationCheck[] { check1, check2, check3 }); // var page2 = new InstallFolderPage(); var page3 = new WebPage(); var page4 = new UserAccountPage(); var page5 = new DatabasePage(); var passwordPage = new ServerAdminPasswordPage(); // var page6 = new ExpressInstallPage2(); // var page7 = new FinishPage(); wizard.Controls.AddRange(new Control[] { introPage, licPage, page1, page2, page3, page4, page5, passwordPage, page6, page7 }); wizard.LinkPages(); wizard.SelectedPage = introPage; //show wizard IWin32Window owner = args[Global.Parameters.ParentForm] as IWin32Window; return form.ShowModal(owner); } }
private CheckStatuses CheckWPPortal(SetupVariables setupVariables, out string details) { details = ""; try { if (AccountExists(setupVariables)) { details = string.Format("Windows account already exists: {0}\\{1}", setupVariables.UserDomain, setupVariables.UserAccount); Log.WriteError(string.Format("Account check: {0}", details), null); return CheckStatuses.Error; } if (!CheckDiskSpace(setupVariables, out details)) { Log.WriteError(string.Format("Disk space check: {0}", details), null); return CheckStatuses.Error; } return CheckStatuses.Success; } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) Log.WriteError("Check error", ex); details = "Unexpected error"; return CheckStatuses.Error; } }
internal static object InstallBase(object obj, string minimalInstallerVersion) { Hashtable args = Utils.GetSetupParameters(obj); //check CS version string shellVersion = Utils.GetStringSetupParameter(args, Global.Parameters.ShellVersion); var shellMode = Utils.GetStringSetupParameter(args, Global.Parameters.ShellMode); Version version = new Version(shellVersion); // var setupVariables = new SetupVariables { SetupAction = SetupActions.Install, IISVersion = Global.IISVersion }; // InitInstall(args, setupVariables); //Unattended setup LoadSetupVariablesFromSetupXml(setupVariables.SetupXml, setupVariables); // var sam = new ServerActionManager(setupVariables); // Prepare installation defaults sam.PrepareDistributiveDefaults(); // Silent Installer Mode if (shellMode.Equals(Global.SilentInstallerShell, StringComparison.OrdinalIgnoreCase)) { if (version < new Version(minimalInstallerVersion)) { Utils.ShowConsoleErrorMessage(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion); // return false; } try { var success = true; // setupVariables.ServerPassword = Utils.GetStringSetupParameter(args, Global.Parameters.ServerPassword); // sam.ActionError += new EventHandler<ActionErrorEventArgs>((object sender, ActionErrorEventArgs e) => { Utils.ShowConsoleErrorMessage(e.ErrorMessage); // Log.WriteError(e.ErrorMessage); // success = false; }); // sam.Start(); // return success; } catch (Exception ex) { Log.WriteError("Failed to install the component", ex); // return false; } } else { if (version < new Version(minimalInstallerVersion)) { MessageBox.Show(String.Format(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion), "Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return DialogResult.Cancel; } var form = new InstallerForm(); var wizard = form.Wizard; wizard.SetupVariables = setupVariables; // wizard.ActionManager = sam; //create wizard pages var introPage = new IntroductionPage(); var licPage = new LicenseAgreementPage(); // var page1 = new ConfigurationCheckPage(); page1.Checks.AddRange(new ConfigurationCheck[] { new ConfigurationCheck(CheckTypes.OperationSystem, "Operating System Requirement"), new ConfigurationCheck(CheckTypes.IISVersion, "IIS Requirement"), new ConfigurationCheck(CheckTypes.ASPNET, "ASP.NET Requirement") }); // var page2 = new InstallFolderPage(); var page3 = new WebPage(); var page4 = new UserAccountPage(); var page5 = new ServerPasswordPage(); var page6 = new ExpressInstallPage2(); var page7 = new FinishPage(); // wizard.Controls.AddRange(new Control[] { introPage, licPage, page1, page2, page3, page4, page5, page6, page7 }); wizard.LinkPages(); wizard.SelectedPage = introPage; //show wizard IWin32Window owner = args["ParentForm"] as IWin32Window; return form.ShowModal(owner); } }
internal static CheckStatuses CheckIIS32Mode(SetupVariables setupVariables, out string details) { details = string.Empty; CheckStatuses ret = CheckIISVersion(setupVariables, out details); if (ret == CheckStatuses.Error) return ret; try { //IIS 6 if (setupVariables.IISVersion.Major == 6) { //x64 if (Utils.IsWin64()) { if (!Utils.IIS32Enabled()) { Log.WriteInfo("IIS 32-bit mode disabled"); EnableIIS32Mode(); details = "IIS 32-bit mode has been enabled."; Log.WriteInfo(string.Format("IIS 32-bit mode check: {0}", details)); return CheckStatuses.Warning; } } } return CheckStatuses.Success; } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) Log.WriteError("Check error", ex); details = "Unexpected error"; return CheckStatuses.Error; } }
protected static void LoadSetupVariablesFromSetupXml(string xml, SetupVariables setupVariables) { if (string.IsNullOrEmpty(xml)) return; XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlNodeList settings = doc.SelectNodes("settings/add"); foreach (XmlElement node in settings) { string key = node.GetAttribute("key").ToLower(); string value = node.GetAttribute("value"); switch (key) { case "installationfolder": setupVariables.InstallationFolder = value; break; case "websitedomain": setupVariables.WebSiteDomain = value; break; case "websiteip": setupVariables.WebSiteIP = value; break; case "websiteport": setupVariables.WebSitePort = value; break; case "serveradminpassword": setupVariables.ServerAdminPassword = value; break; case "serverpassword": setupVariables.ServerPassword = value; break; case "useraccount": setupVariables.UserAccount = value; break; case "userpassword": setupVariables.UserPassword = value; break; case "userdomain": setupVariables.UserDomain = value; break; case "enterpriseserverurl": setupVariables.EnterpriseServerURL = value; break; case "licensekey": setupVariables.LicenseKey = value; break; case "dbinstallconnectionstring": setupVariables.DbInstallConnectionString = value; break; } } }
internal static CheckStatuses CheckASPNET(SetupVariables setupVariables, out string details) { details = "ASP.NET 4.0 is installed."; CheckStatuses ret = CheckStatuses.Success; try { // IIS 6 if (setupVariables.IISVersion.Major == 6) { // if (Utils.CheckAspNet40Registered(setupVariables) == false) { // Register ASP.NET 4.0 Utils.RegisterAspNet40(setupVariables); // ret = CheckStatuses.Warning; details = AspNet40HasBeenInstalledMessage; } // Enable ASP.NET 4.0 Web Server Extension if it is prohibited if (Utils.GetAspNetWebExtensionStatus_Iis6(setupVariables) == WebExtensionStatus.Prohibited) { Utils.EnableAspNetWebExtension_Iis6(); } } // IIS 7 on Windows 2008 and higher else { if (!IsWebServerRoleInstalled()) { details = "Web Server (IIS) role is not installed on your server. Run Server Manager to add Web Server (IIS) role."; Log.WriteInfo(string.Format("ASP.NET check: {0}", details)); return CheckStatuses.Error; } if (!IsAspNetRoleServiceInstalled()) { details = "ASP.NET role service is not installed on your server. Run Server Manager to add ASP.NET role service."; Log.WriteInfo(string.Format("ASP.NET check: {0}", details)); return CheckStatuses.Error; } // Register ASP.NET 4.0 if (Utils.CheckAspNet40Registered(setupVariables) == false) { // Register ASP.NET 4.0 Utils.RegisterAspNet40(setupVariables); // ret = CheckStatuses.Warning; details = AspNet40HasBeenInstalledMessage; } } // Log details Log.WriteInfo(string.Format("ASP.NET check: {0}", details)); // return ret; } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) Log.WriteError("Check error", ex); details = "Unexpected error"; #if DEBUG return CheckStatuses.Warning; #endif #if !DEBUG return CheckStatuses.Error; #endif } }
private static SetupScript GetPrepareScript(Session Ctx) { var CtxVars = new SetupVariables(); WiXSetup.FillFromSession(Ctx.CustomActionData, CtxVars); AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = GetProperty(Ctx, "MainConfig") }); CtxVars.IISVersion = Tool.GetWebServerVersion(); CtxVars.ComponentId = GetProperty(Ctx, "ComponentId"); CtxVars.Version = AppConfig.GetComponentSettingStringValue(CtxVars.ComponentId, Global.Parameters.Release); CtxVars.SpecialBaseDirectory = Directory.GetParent(GetProperty(Ctx, "MainConfig")).FullName; CtxVars.FileNameMap = new Dictionary<string, string>(); CtxVars.FileNameMap.Add(new FileInfo(GetProperty(Ctx, "MainConfig")).Name, BackupRestore.MainConfig); SetupScript Result = new ExpressScript(CtxVars); Result.Actions.Add(new InstallAction(ActionTypes.StopApplicationPool) { SetupVariables = CtxVars }); Result.Actions.Add(new InstallAction(ActionTypes.Backup) { SetupVariables = CtxVars }); Result.Actions.Add(new InstallAction(ActionTypes.DeleteDirectory) { SetupVariables = CtxVars, Path = CtxVars.InstallFolder }); return Result; }
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)); }
public static ActionResult PreFillSettings(Session session) { Func<string, bool> HaveInstalledComponents = (string CfgFullPath) => { var ComponentsPath = "//components"; return File.Exists(CfgFullPath) ? BackupRestore.HaveChild(CfgFullPath, ComponentsPath) : false; }; Func<IEnumerable<string>, string> FindMainConfig = (IEnumerable<string> Dirs) => { // Looking into directories with next priority: // Previous installation directory and her backup, "WebsitePanel" directories on fixed drives and their backups. // The last chance is an update from an installation based on previous installer version that installed to "Program Files". // Regular directories. foreach (var Dir in Dirs) { var Result = Path.Combine(Dir, BackupRestore.MainConfig); if (HaveInstalledComponents(Result)) { return Result; } else { var ComponentNames = new string[] { Global.Server.ComponentName, Global.EntServer.ComponentName, Global.WebPortal.ComponentName }; foreach (var Name in ComponentNames) { var Backup = BackupRestore.Find(Dir, Global.DefaultProductName, Name); if (Backup != null && HaveInstalledComponents(Backup.BackupMainConfigFile)) return Backup.BackupMainConfigFile; } } } // Looking into platform specific Program Files. { var InstallerMainCfg = "WebsitePanel.Installer.exe.config"; var InstallerName = "WebsitePanel Installer"; var PFolderType = Environment.Is64BitOperatingSystem ? Environment.SpecialFolder.ProgramFilesX86 : Environment.SpecialFolder.ProgramFiles; var PFiles = Environment.GetFolderPath(PFolderType); var Result = Path.Combine(PFiles, InstallerName, InstallerMainCfg); if (HaveInstalledComponents(Result)) return Result; } return null; }; Action<Session, SetupVariables> VersionGuard = (Session SesCtx, SetupVariables CtxVars) => { var Current = SesCtx["ProductVersion"]; var Found = string.IsNullOrWhiteSpace(CtxVars.Version) ? "0.0.0" : CtxVars.Version; if ((new Version(Found) > new Version(Current)) && !CtxVars.InstallerType.ToLowerInvariant().Equals("msi")) throw new InvalidOperationException("New version must be greater than previous always."); }; Func<string, string> NormalizeDir = (string Dir) => { string nds = Path.DirectorySeparatorChar.ToString(); string ads = Path.AltDirectorySeparatorChar.ToString(); var Result = Dir.Trim(); if (!Result.EndsWith(nds) && !Result.EndsWith(ads)) { if (Result.Contains(nds)) Result += nds; else Result += ads; } return Result; }; try { var Ctx = session; Ctx.AttachToSetupLog(); PopUpDebugger(); Log.WriteStart("PreFillSettings"); TryApllyNewPassword(Ctx, "PI_SERVER_PASSWORD"); TryApllyNewPassword(Ctx, "PI_ESERVER_PASSWORD"); TryApllyNewPassword(Ctx, "PI_PORTAL_PASSWORD"); var WSP = Ctx["WSP_INSTALL_DIR"]; var DirList = new List<string>(); DirList.Add(WSP); DirList.AddRange(from Drive in DriveInfo.GetDrives() where Drive.DriveType == DriveType.Fixed select Path.Combine(Drive.RootDirectory.FullName, Global.DefaultProductName)); var CfgPath = FindMainConfig(DirList); if (!string.IsNullOrWhiteSpace(CfgPath)) { try { var EServerUrl = string.Empty; AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = CfgPath }); var CtxVars = new SetupVariables(); CtxVars.ComponentId = WiXSetup.GetComponentID(CfgPath, Global.Server.ComponentCode); if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId)) { AppConfig.LoadComponentSettings(CtxVars); VersionGuard(Ctx, CtxVars); SetProperty(Ctx, "COMPFOUND_SERVER_ID", CtxVars.ComponentId); SetProperty(Ctx, "COMPFOUND_SERVER_MAIN_CFG", CfgPath); SetProperty(Ctx, "PI_SERVER_IP", CtxVars.WebSiteIP); SetProperty(Ctx, "PI_SERVER_PORT", CtxVars.WebSitePort); SetProperty(Ctx, "PI_SERVER_HOST", CtxVars.WebSiteDomain); SetProperty(Ctx, "PI_SERVER_LOGIN", CtxVars.UserAccount); SetProperty(Ctx, "PI_SERVER_DOMAIN", CtxVars.UserDomain); SetProperty(Ctx, "PI_SERVER_INSTALL_DIR", CtxVars.InstallFolder); SetProperty(Ctx, "WSP_INSTALL_DIR", NormalizeDir(new DirectoryInfo(CtxVars.InstallFolder).Parent.FullName)); Ctx["SERVER_ACCESS_PASSWORD"] = string.Empty; Ctx["SERVER_ACCESS_PASSWORD_CONFIRM"] = string.Empty; var HaveAccount = SecurityUtils.UserExists(CtxVars.UserDomain, CtxVars.UserAccount); bool HavePool = Tool.AppPoolExists(CtxVars.ApplicationPool); Ctx["COMPFOUND_SERVER"] = (HaveAccount && HavePool) ? YesNo.Yes : YesNo.No; } CtxVars.ComponentId = WiXSetup.GetComponentID(CfgPath, Global.EntServer.ComponentCode); if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId)) { AppConfig.LoadComponentSettings(CtxVars); VersionGuard(Ctx, CtxVars); SetProperty(Ctx, "COMPFOUND_ESERVER_ID", CtxVars.ComponentId); SetProperty(Ctx, "COMPFOUND_ESERVER_MAIN_CFG", CfgPath); SetProperty(Ctx, "PI_ESERVER_IP", CtxVars.WebSiteIP); SetProperty(Ctx, "PI_ESERVER_PORT", CtxVars.WebSitePort); SetProperty(Ctx, "PI_ESERVER_HOST", CtxVars.WebSiteDomain); SetProperty(Ctx, "PI_ESERVER_LOGIN", CtxVars.UserAccount); SetProperty(Ctx, "PI_ESERVER_DOMAIN", CtxVars.UserDomain); EServerUrl = string.Format("http://{0}:{1}", CtxVars.WebSiteIP, CtxVars.WebSitePort); SetProperty(Ctx, "PI_ESERVER_INSTALL_DIR", CtxVars.InstallFolder); SetProperty(Ctx, "WSP_INSTALL_DIR", NormalizeDir(new DirectoryInfo(CtxVars.InstallFolder).Parent.FullName)); var ConnStr = new SqlConnectionStringBuilder(CtxVars.DbInstallConnectionString); SetProperty(Ctx, "DB_CONN", ConnStr.ToString()); SetProperty(Ctx, "DB_SERVER", ConnStr.DataSource); SetProperty(Ctx, "DB_AUTH", ConnStr.IntegratedSecurity ? SQL_AUTH_WINDOWS : SQL_AUTH_SERVER); if (!ConnStr.IntegratedSecurity) { SetProperty(Ctx, "DB_LOGIN", ConnStr.UserID); SetProperty(Ctx, "DB_PASSWORD", ConnStr.Password); } ConnStr = new SqlConnectionStringBuilder(CtxVars.ConnectionString); SetProperty(Ctx, "DB_DATABASE", ConnStr.InitialCatalog); SetProperty(Ctx, "PI_ESERVER_CONN_STR", ConnStr.ToString()); SetProperty(Ctx, "PI_ESERVER_CRYPTO_KEY", CtxVars.CryptoKey); try { var SqlQuery = string.Format("USE [{0}]; SELECT [dbo].[Users].[Password] FROM [dbo].[Users] WHERE [dbo].[Users].[UserID] = 1;", ConnStr.InitialCatalog); using (var Reader = SqlUtils.ExecuteSql(CtxVars.DbInstallConnectionString, SqlQuery).CreateDataReader()) { if (Reader.Read()) { var Hash = Reader[0].ToString(); var Password = IsEnctyptionEnabled(string.Format(@"{0}\Web.config", CtxVars.InstallationFolder)) ? Utils.Decrypt(CtxVars.CryptoKey, Hash) : Hash; Ctx["SERVERADMIN_PASSWORD"] = Password; Ctx["SERVERADMIN_PASSWORD_CONFIRM"] = Password; } } } catch { // Nothing to do. } var HaveAccount = SecurityUtils.UserExists(CtxVars.UserDomain, CtxVars.UserAccount); bool HavePool = Tool.AppPoolExists(CtxVars.ApplicationPool); Ctx["COMPFOUND_ESERVER"] = (HaveAccount && HavePool) ? YesNo.Yes : YesNo.No; } CtxVars.ComponentId = WiXSetup.GetComponentID(CfgPath, Global.WebPortal.ComponentCode); if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId)) { AppConfig.LoadComponentSettings(CtxVars); VersionGuard(Ctx, CtxVars); SetProperty(Ctx, "COMPFOUND_PORTAL_ID", CtxVars.ComponentId); SetProperty(Ctx, "COMPFOUND_PORTAL_MAIN_CFG", CfgPath); SetProperty(Ctx, "PI_PORTAL_IP", CtxVars.WebSiteIP); SetProperty(Ctx, "PI_PORTAL_PORT", CtxVars.WebSitePort); SetProperty(Ctx, "PI_PORTAL_HOST", CtxVars.WebSiteDomain); SetProperty(Ctx, "PI_PORTAL_LOGIN", CtxVars.UserAccount); SetProperty(Ctx, "PI_PORTAL_DOMAIN", CtxVars.UserDomain); if (!SetProperty(Ctx, "PI_ESERVER_URL", CtxVars.EnterpriseServerURL)) if (!SetProperty(Ctx, "PI_ESERVER_URL", EServerUrl)) SetProperty(Ctx, "PI_ESERVER_URL", Global.WebPortal.DefaultEntServURL); SetProperty(Ctx, "PI_PORTAL_INSTALL_DIR", CtxVars.InstallFolder); SetProperty(Ctx, "WSP_INSTALL_DIR", NormalizeDir(new DirectoryInfo(CtxVars.InstallFolder).Parent.FullName)); var HaveAccount = SecurityUtils.UserExists(CtxVars.UserDomain, CtxVars.UserAccount); bool HavePool = Tool.AppPoolExists(CtxVars.ApplicationPool); Ctx["COMPFOUND_PORTAL"] = (HaveAccount && HavePool) ? YesNo.Yes : YesNo.No; } CtxVars.ComponentId = WiXSetup.GetComponentID(CfgPath, Global.Scheduler.ComponentCode); var HaveComponentId = !string.IsNullOrWhiteSpace(CtxVars.ComponentId); var HaveSchedulerService = ServiceController.GetServices().Any(x => x.DisplayName.Equals(Global.Parameters.SchedulerServiceName, StringComparison.CurrentCultureIgnoreCase)); var EServerConnStr = Ctx["PI_ESERVER_CONN_STR"]; var HaveConn = !string.IsNullOrWhiteSpace(EServerConnStr); if (HaveComponentId || HaveSchedulerService || HaveConn) { Ctx["COMPFOUND_SCHEDULER"] = YesNo.No; try { SqlConnectionStringBuilder ConnInfo = null; if (HaveComponentId) { AppConfig.LoadComponentSettings(CtxVars); VersionGuard(Ctx, CtxVars); SetProperty(Ctx, "COMPFOUND_SCHEDULER_ID", CtxVars.ComponentId); SetProperty(Ctx, "COMPFOUND_SCHEDULER_MAIN_CFG", CfgPath); SetProperty(Ctx, "PI_SCHEDULER_CRYPTO_KEY", CtxVars.CryptoKey); ConnInfo = new SqlConnectionStringBuilder(CtxVars.ConnectionString); } else if (HaveConn) { SetProperty(Ctx, "PI_SCHEDULER_CRYPTO_KEY", Ctx["PI_ESERVER_CRYPTO_KEY"]); ConnInfo = new SqlConnectionStringBuilder(EServerConnStr); } if(ConnInfo != null) { SetProperty(Ctx, "PI_SCHEDULER_DB_SERVER", ConnInfo.DataSource); SetProperty(Ctx, "PI_SCHEDULER_DB_DATABASE", ConnInfo.InitialCatalog); SetProperty(Ctx, "PI_SCHEDULER_DB_LOGIN", ConnInfo.UserID); SetProperty(Ctx, "PI_SCHEDULER_DB_PASSWORD", ConnInfo.Password); } Ctx["COMPFOUND_SCHEDULER"] = HaveSchedulerService? YesNo.Yes : YesNo.No; } catch (Exception ex) { Log.WriteError("Detection of existing Scheduler Service failed.", ex); } } } catch (InvalidOperationException ioex) { Log.WriteError(ioex.ToString()); var Text = new Record(1); Text.SetString(0, ioex.Message); Ctx.Message(InstallMessage.Error, Text); return ActionResult.Failure; } } } catch (Exception ex) { Log.WriteError(ex.ToString()); return ActionResult.Failure; } Log.WriteEnd("PreFillSettings"); return ActionResult.Success; }
internal static object InstallBase(object obj, string minimalInstallerVersion) { Hashtable args = Utils.GetSetupParameters(obj); //check CS version string shellVersion = Utils.GetStringSetupParameter(args, Global.Parameters.ShellVersion); var shellMode = Utils.GetStringSetupParameter(args, Global.Parameters.ShellMode); Version version = new Version(shellVersion); //******************** Server **************** var serverSetup = new SetupVariables { ComponentId = Guid.NewGuid().ToString(), Instance = String.Empty, ComponentName = Global.Server.ComponentName, ComponentCode = Global.Server.ComponentCode, ComponentDescription = Global.Server.ComponentDescription, // ServerPassword = Guid.NewGuid().ToString("N").Substring(0, 10), // SetupAction = SetupActions.Install, IISVersion = Global.IISVersion, ApplicationName = Utils.GetStringSetupParameter(args, Global.Parameters.ApplicationName), Version = Utils.GetStringSetupParameter(args, Global.Parameters.Version), Installer = Utils.GetStringSetupParameter(args, Global.Parameters.Installer), InstallerPath = Utils.GetStringSetupParameter(args, Global.Parameters.InstallerPath), SetupXml = Utils.GetStringSetupParameter(args, Global.Parameters.SetupXml), // InstallerFolder = Path.Combine(Utils.GetStringSetupParameter(args, Global.Parameters.InstallerFolder), Global.Server.ComponentName), InstallerType = Utils.GetStringSetupParameter(args, Global.Parameters.InstallerType).Replace(Global.StandaloneServer.SetupController, Global.Server.SetupController), InstallationFolder = Path.Combine(Path.Combine(Utils.GetSystemDrive(), "WebsitePanel"), Global.Server.ComponentName), ConfigurationFile = "web.config", }; // Load config file AppConfig.LoadConfiguration(); // LoadComponentVariablesFromSetupXml(serverSetup.ComponentCode, serverSetup.SetupXml, serverSetup); // //serverSetup.ComponentConfig = AppConfig.CreateComponentConfig(serverSetup.ComponentId); //serverSetup.RemoteServerUrl = GetUrl(serverSetup.WebSiteDomain, serverSetup.WebSiteIP, serverSetup.WebSitePort); // //CreateComponentSettingsFromSetupVariables(serverSetup, serverSetup.ComponentId); //******************** Enterprise Server **************** var esServerSetup = new SetupVariables { ComponentId = Guid.NewGuid().ToString(), SetupAction = SetupActions.Install, IISVersion = Global.IISVersion, // Instance = String.Empty, ComponentName = Global.EntServer.ComponentName, ComponentCode = Global.EntServer.ComponentCode, ApplicationName = Utils.GetStringSetupParameter(args, Global.Parameters.ApplicationName), Version = Utils.GetStringSetupParameter(args, Global.Parameters.Version), ComponentDescription = Global.EntServer.ComponentDescription, Installer = Utils.GetStringSetupParameter(args, Global.Parameters.Installer), InstallerFolder = Path.Combine(Utils.GetStringSetupParameter(args, Global.Parameters.InstallerFolder), Global.EntServer.ComponentName), InstallerType = Utils.GetStringSetupParameter(args, Global.Parameters.InstallerType).Replace(Global.StandaloneServer.SetupController, Global.EntServer.SetupController), InstallationFolder = Path.Combine(Path.Combine(Utils.GetSystemDrive(), "WebsitePanel"), Global.EntServer.ComponentName), InstallerPath = Utils.GetStringSetupParameter(args, Global.Parameters.InstallerPath), SetupXml = Utils.GetStringSetupParameter(args, Global.Parameters.SetupXml), // ConfigurationFile = "web.config", ConnectionString = Global.EntServer.AspNetConnectionStringFormat, DatabaseServer = Global.EntServer.DefaultDbServer, Database = Global.EntServer.DefaultDatabase, CreateDatabase = true, UpdateServerAdminPassword = true, // WebSiteIP = Global.EntServer.DefaultIP, WebSitePort = Global.EntServer.DefaultPort, WebSiteDomain = String.Empty, }; // LoadComponentVariablesFromSetupXml(esServerSetup.ComponentCode, esServerSetup.SetupXml, esServerSetup); // //esServerSetup.ComponentConfig = AppConfig.CreateComponentConfig(esServerSetup.ComponentId); // //CreateComponentSettingsFromSetupVariables(esServerSetup, esServerSetup.ComponentId); //******************** Portal **************** #region Portal Setup Variables var portalSetup = new SetupVariables { ComponentId = Guid.NewGuid().ToString(), SetupAction = SetupActions.Install, IISVersion = Global.IISVersion, // Instance = String.Empty, ComponentName = Global.WebPortal.ComponentName, ComponentCode = Global.WebPortal.ComponentCode, ApplicationName = Utils.GetStringSetupParameter(args, Global.Parameters.ApplicationName), Version = Utils.GetStringSetupParameter(args, Global.Parameters.Version), ComponentDescription = Global.WebPortal.ComponentDescription, Installer = Utils.GetStringSetupParameter(args, Global.Parameters.Installer), InstallerFolder = Path.Combine(Utils.GetStringSetupParameter(args, Global.Parameters.InstallerFolder), Global.WebPortal.ComponentName), InstallerType = Utils.GetStringSetupParameter(args, Global.Parameters.InstallerType).Replace(Global.StandaloneServer.SetupController, Global.WebPortal.SetupController), InstallationFolder = Path.Combine(Path.Combine(Utils.GetSystemDrive(), "WebsitePanel"), Global.WebPortal.ComponentName), InstallerPath = Utils.GetStringSetupParameter(args, Global.Parameters.InstallerPath), SetupXml = Utils.GetStringSetupParameter(args, Global.Parameters.SetupXml), // ConfigurationFile = "web.config", EnterpriseServerURL = Global.WebPortal.DefaultEntServURL, }; // LoadComponentVariablesFromSetupXml(portalSetup.ComponentCode, portalSetup.SetupXml, portalSetup); // //portalSetup.ComponentConfig = AppConfig.CreateComponentConfig(portalSetup.ComponentId); // //CreateComponentSettingsFromSetupVariables(portalSetup, portalSetup.ComponentId); #endregion // var stdssam = new StandaloneServerActionManager(serverSetup, esServerSetup, portalSetup); // stdssam.PrepareDistributiveDefaults(); // if (shellMode.Equals(Global.SilentInstallerShell, StringComparison.OrdinalIgnoreCase)) { // Validate the setup controller's bootstrapper version if (version < new Version(minimalInstallerVersion)) { Utils.ShowConsoleErrorMessage(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion); // return(false); } try { var success = true; // Retrieve WebsitePanel Enterprise Server component's settings from the command-line var adminPassword = Utils.GetStringSetupParameter(args, Global.Parameters.ServerAdminPassword); // This has been designed to make an installation process via Web PI more secure if (String.IsNullOrEmpty(adminPassword)) { // Set serveradmin password esServerSetup.ServerAdminPassword = Guid.NewGuid().ToString(); // Set peer admin password esServerSetup.PeerAdminPassword = Guid.NewGuid().ToString(); // Instruct provisioning scenario to enter the application in SCPA mode (Setup Control Panel Acounts) esServerSetup.EnableScpaMode = true; } else { esServerSetup.ServerAdminPassword = esServerSetup.PeerAdminPassword = adminPassword; } // esServerSetup.Database = Utils.GetStringSetupParameter(args, Global.Parameters.DatabaseName); esServerSetup.DatabaseServer = Utils.GetStringSetupParameter(args, Global.Parameters.DatabaseServer); esServerSetup.DbInstallConnectionString = SqlUtils.BuildDbServerMasterConnectionString( esServerSetup.DatabaseServer, Utils.GetStringSetupParameter(args, Global.Parameters.DbServerAdmin), Utils.GetStringSetupParameter(args, Global.Parameters.DbServerAdminPassword) ); // stdssam.ActionError += new EventHandler <ActionErrorEventArgs>((object sender, ActionErrorEventArgs e) => { Utils.ShowConsoleErrorMessage(e.ErrorMessage); // Log.WriteError(e.ErrorMessage); // success = false; }); // stdssam.Start(); // return(success); } catch (Exception ex) { Log.WriteError("Failed to install the component", ex); // return(false); } } else { // Validate the setup controller's bootstrapper version if (version < new Version(minimalInstallerVersion)) { MessageBox.Show(String.Format(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion), "Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return(DialogResult.Cancel); } // NOTE: there is no assignment to SetupVariables property of the wizard as usually because we have three components // to setup here and thus we have created SwapSetupVariablesAction setup action to swap corresponding variables // back and forth while executing the installation scenario. InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; wizard.SetupVariables = serverSetup; // Assign corresponding action manager to the wizard. wizard.ActionManager = stdssam; // Initialize wizard pages and their properties var introPage = new IntroductionPage(); var licPage = new LicenseAgreementPage(); var page2 = new ConfigurationCheckPage(); // Setup prerequisites validation page2.Checks.AddRange(new ConfigurationCheck[] { new ConfigurationCheck(CheckTypes.OperationSystem, "Operating System Requirement"), new ConfigurationCheck(CheckTypes.IISVersion, "IIS Requirement"), new ConfigurationCheck(CheckTypes.ASPNET, "ASP.NET Requirement"), // Validate Server installation prerequisites new ConfigurationCheck(CheckTypes.WPServer, "WebsitePanel Server Requirement") { SetupVariables = serverSetup }, // Validate EnterpriseServer installation prerequisites new ConfigurationCheck(CheckTypes.WPEnterpriseServer, "WebsitePanel Enterprise Server Requirement") { SetupVariables = esServerSetup }, // Validate WebPortal installation prerequisites new ConfigurationCheck(CheckTypes.WPPortal, "WebsitePanel Portal Requirement") { SetupVariables = portalSetup } }); // Assign WebPortal setup variables set to acquire corresponding settings var page3 = new WebPage { SetupVariables = portalSetup }; // Assign EnterpriseServer setup variables set to acquire corresponding settings var page4 = new DatabasePage { SetupVariables = esServerSetup }; // Assign EnterpriseServer setup variables set to acquire corresponding settings var page5 = new ServerAdminPasswordPage { SetupVariables = esServerSetup, NoteText = "Note: Both serveradmin and admin accounts will use this password. You can always change password for serveradmin or admin accounts through control panel." }; // var page6 = new ExpressInstallPage2(); // Assign WebPortal setup variables set to acquire corresponding settings var page7 = new SetupCompletePage { SetupVariables = portalSetup }; // wizard.Controls.AddRange(new Control[] { introPage, licPage, page2, page3, page4, page5, page6, page7 }); wizard.LinkPages(); wizard.SelectedPage = introPage; // Run wizard IWin32Window owner = args[Global.Parameters.ParentForm] as IWin32Window; return(form.ShowModal(owner)); } }
public static string ResolveAspNet40RegistrationToolPath_Iis6(SetupVariables setupVariables) { // By default we fallback to the corresponding tool version based on the platform bitness var util = Environment.Is64BitOperatingSystem ? AspNet40RegistrationToolx64 : AspNet40RegistrationToolx86; // Choose appropriate tool version for IIS 6 if (setupVariables.IISVersion.Major == 6) { // Change to x86 tool version on x64 w/ "Enable32bitAppOnWin64" flag enabled if (Environment.Is64BitOperatingSystem == true && Utils.IIS32Enabled()) { util = AspNet40RegistrationToolx86; } } // Build path to the tool return Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), util); }
public static bool CheckAspNet40Registered(SetupVariables setupVariables) { var regkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\ASP.NET\\4.0.30319.0"); return(regkey != null); }
public static bool CheckAspNet40Registered(SetupVariables setupVariables) { // var aspNet40Registered = false; // Run ASP.NET Registration Tool command var psOutput = ExecAspNetRegistrationToolCommand(setupVariables, "-lv"); // Split process output per lines var strLines = psOutput.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); // Lookup for an evidence of ASP.NET 4.0 aspNet40Registered = strLines.Any((string s) => { return s.Contains("4.0.30319.0"); }); // return aspNet40Registered; }
public static DialogResult UpdateBase(object obj, string minimalInstallerVersion, string versionsToUpgrade, bool updateSql, InstallAction versionSpecificAction) { Hashtable args = Utils.GetSetupParameters(obj); 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); } // Load application configuration AppConfig.LoadConfiguration(); // var setupVariables = new SetupVariables { SetupAction = SetupActions.Update, ComponentId = Utils.GetStringSetupParameter(args, "ComponentId"), IISVersion = Global.IISVersion, }; // Load setup variables from app.config AppConfig.LoadComponentSettings(setupVariables); // InstallerForm form = new InstallerForm(); form.Wizard.SetupVariables = setupVariables; Wizard wizard = form.Wizard; // Initialize setup variables with the data received from update procedure wizard.SetupVariables.BaseDirectory = Utils.GetStringSetupParameter(args, "BaseDirectory"); wizard.SetupVariables.UpdateVersion = Utils.GetStringSetupParameter(args, "UpdateVersion"); wizard.SetupVariables.InstallerFolder = Utils.GetStringSetupParameter(args, "InstallerFolder"); wizard.SetupVariables.Installer = Utils.GetStringSetupParameter(args, "Installer"); wizard.SetupVariables.InstallerType = Utils.GetStringSetupParameter(args, "InstallerType"); wizard.SetupVariables.InstallerPath = Utils.GetStringSetupParameter(args, "InstallerPath"); #region Support for multiple versions to upgrade from // Find out whether the version(s) are supported in that upgrade var upgradeSupported = versionsToUpgrade.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Any(x => { return(VersionEquals(wizard.SetupVariables.Version, x.Trim())); }); // if (upgradeSupported == false) { Log.WriteInfo( String.Format("Could not find a suitable version to upgrade. Current version: {0}; Versions supported: {1};", wizard.SetupVariables.Version, versionsToUpgrade)); // MessageBox.Show( "Your current software version either is not supported or could not be upgraded at this time. Please send log file from the installer to the software vendor for further research on the issue.", "Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return(DialogResult.Cancel); } #endregion // IntroductionPage introPage = new IntroductionPage(); LicenseAgreementPage licPage = new LicenseAgreementPage(); ExpressInstallPage page2 = new ExpressInstallPage(); //create install currentScenario InstallAction action = new InstallAction(ActionTypes.StopApplicationPool); action.Description = "Stopping IIS Application Pool..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.Backup); action.Description = "Backing up..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.DeleteFiles); action.Description = "Deleting files..."; action.Path = "setup\\delete.txt"; page2.Actions.Add(action); action = new InstallAction(ActionTypes.CopyFiles); action.Description = "Copying files..."; page2.Actions.Add(action); if (versionSpecificAction != null) { page2.Actions.Add(versionSpecificAction); } if (updateSql) { action = new InstallAction(ActionTypes.ExecuteSql); action.Description = "Updating database..."; action.Path = "setup\\update_db.sql"; page2.Actions.Add(action); } action = new InstallAction(ActionTypes.UpdateConfig); action.Description = "Updating system configuration..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.StartApplicationPool); action.Description = "Starting IIS Application Pool..."; page2.Actions.Add(action); FinishPage page3 = new FinishPage(); wizard.Controls.AddRange(new Control[] { introPage, licPage, page2, page3 }); wizard.LinkPages(); wizard.SelectedPage = introPage; //show wizard IWin32Window owner = args["ParentForm"] as IWin32Window; return(form.ShowModal(owner)); }
public static WebExtensionStatus GetAspNetWebExtensionStatus_Iis6(SetupVariables setupVariables) { WebExtensionStatus status = WebExtensionStatus.Allowed; if (setupVariables.IISVersion.Major == 6) { status = WebExtensionStatus.NotInstalled; string path; if (Utils.IsWin64() && !Utils.IIS32Enabled()) { //64-bit path = Path.Combine(OS.GetWindowsDirectory(), @"Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll"); } else { //32-bit path = Path.Combine(OS.GetWindowsDirectory(), @"Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll"); } path = path.ToLower(); using (DirectoryEntry iis = new DirectoryEntry("IIS://LocalHost/W3SVC")) { PropertyValueCollection values = iis.Properties["WebSvcExtRestrictionList"]; for (int i = 0; i < values.Count; i++) { string val = values[i] as string; if (!string.IsNullOrEmpty(val)) { string strVal = val.ToString().ToLower(); if (strVal.Contains(path)) { if (strVal[0] == '1') { status = WebExtensionStatus.Allowed; } else { status = WebExtensionStatus.Prohibited; } break; } } } } } return status; }
public static void LoadSetupVariablesFromParameters(SetupVariables vars, Hashtable args) { vars.ApplicationName = Utils.GetStringSetupParameter(args, "ApplicationName"); vars.ComponentName = Utils.GetStringSetupParameter(args, "ComponentName"); vars.ComponentCode = Utils.GetStringSetupParameter(args, "ComponentCode"); vars.ComponentDescription = Utils.GetStringSetupParameter(args, "ComponentDescription"); vars.Version = Utils.GetStringSetupParameter(args, "Version"); vars.InstallerFolder = Utils.GetStringSetupParameter(args, "InstallerFolder"); vars.Installer = Utils.GetStringSetupParameter(args, "Installer"); vars.InstallerType = Utils.GetStringSetupParameter(args, "InstallerType"); vars.InstallerPath = Utils.GetStringSetupParameter(args, "InstallerPath"); vars.IISVersion = Utils.GetVersionSetupParameter(args, "IISVersion"); vars.SetupXml = Utils.GetStringSetupParameter(args, "SetupXml"); // Add some extra variables if any, coming from SilentInstaller #region SilentInstaller CLI arguments var shellMode = Utils.GetStringSetupParameter(args, Global.Parameters.ShellMode); // if (shellMode.Equals(Global.SilentInstallerShell, StringComparison.OrdinalIgnoreCase)) { vars.WebSiteIP = Utils.GetStringSetupParameter(args, Global.Parameters.WebSiteIP); vars.WebSitePort = Utils.GetStringSetupParameter(args, Global.Parameters.WebSitePort); vars.WebSiteDomain = Utils.GetStringSetupParameter(args, Global.Parameters.WebSiteDomain); vars.UserDomain = Utils.GetStringSetupParameter(args, Global.Parameters.UserDomain); vars.UserAccount = Utils.GetStringSetupParameter(args, Global.Parameters.UserAccount); vars.UserPassword = Utils.GetStringSetupParameter(args, Global.Parameters.UserPassword); } #endregion }
public static DialogResult Update(object obj) { Hashtable args = Utils.GetSetupParameters(obj); var setupVariables = new SetupVariables { ComponentId = Utils.GetStringSetupParameter(args, Global.Parameters.ComponentId), SetupAction = SetupActions.Update, IISVersion = Global.IISVersion }; AppConfig.LoadConfiguration(); InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; wizard.SetupVariables = setupVariables; // AppConfig.LoadComponentSettings(wizard.SetupVariables); IntroductionPage introPage = new IntroductionPage(); LicenseAgreementPage licPage = new LicenseAgreementPage(); ExpressInstallPage page2 = new ExpressInstallPage(); //create install currentScenario InstallAction action = new InstallAction(ActionTypes.Backup); action.Description = "Backing up..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.DeleteFiles); action.Description = "Deleting files..."; action.Path = "setup\\delete.txt"; page2.Actions.Add(action); action = new InstallAction(ActionTypes.CopyFiles); action.Description = "Copying files..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.ExecuteSql); action.Description = "Updating database..."; action.Path = "setup\\update_db.sql"; page2.Actions.Add(action); action = new InstallAction(ActionTypes.UpdateConfig); action.Description = "Updating system configuration..."; page2.Actions.Add(action); FinishPage page3 = new FinishPage(); wizard.Controls.AddRange(new Control[] { introPage, licPage, page2, page3 }); wizard.LinkPages(); wizard.SelectedPage = introPage; //show wizard Form parentForm = args[Global.Parameters.ParentForm] as Form; return form.ShowDialog(parentForm); }
public static object Update(object obj) { Hashtable args = Utils.GetSetupParameters(obj); var setupVariables = new SetupVariables { ComponentId = Utils.GetStringSetupParameter(args, Global.Parameters.ComponentId), SetupAction = SetupActions.Update, BaseDirectory = Utils.GetStringSetupParameter(args, Global.Parameters.BaseDirectory), UpdateVersion = Utils.GetStringSetupParameter(args, "UpdateVersion"), InstallerFolder = Utils.GetStringSetupParameter(args, Global.Parameters.InstallerFolder), Installer = Utils.GetStringSetupParameter(args, Global.Parameters.Installer), InstallerType = Utils.GetStringSetupParameter(args, Global.Parameters.InstallerType), InstallerPath = Utils.GetStringSetupParameter(args, Global.Parameters.InstallerPath) }; AppConfig.LoadConfiguration(); InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; // wizard.SetupVariables = setupVariables; // AppConfig.LoadComponentSettings(wizard.SetupVariables); IntroductionPage introPage = new IntroductionPage(); LicenseAgreementPage licPage = new LicenseAgreementPage(); ExpressInstallPage page2 = new ExpressInstallPage(); //create install currentScenario InstallAction action = new InstallAction(ActionTypes.Backup); action.Description = "Backing up..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.DeleteFiles); action.Description = "Deleting files..."; action.Path = "setup\\delete.txt"; page2.Actions.Add(action); action = new InstallAction(ActionTypes.CopyFiles); action.Description = "Copying files..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.UpdateConfig); action.Description = "Updating system configuration..."; page2.Actions.Add(action); FinishPage page3 = new FinishPage(); wizard.Controls.AddRange(new Control[] { introPage, licPage, page2, page3 }); wizard.LinkPages(); wizard.SelectedPage = introPage; //show wizard IWin32Window owner = args[Global.Parameters.ParentForm] as IWin32Window; return form.ShowModal(owner); }
private void InitSetupVaribles(SetupVariables setupVariables) { try { Wizard.SetupVariables = setupVariables.Clone(); } catch (Exception ex) { if (Utils.IsThreadAbortException(ex)) return; } }
protected static void LoadSetupVariablesFromSetupXml(string xml, SetupVariables setupVariables) { if (string.IsNullOrEmpty(xml)) { return; } XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlNodeList settings = doc.SelectNodes("settings/add"); foreach (XmlElement node in settings) { string key = node.GetAttribute("key").ToLower(); string value = node.GetAttribute("value"); switch (key) { case "installationfolder": setupVariables.InstallationFolder = value; break; case "websitedomain": setupVariables.WebSiteDomain = value; break; case "websiteip": setupVariables.WebSiteIP = value; break; case "websiteport": setupVariables.WebSitePort = value; break; case "serveradminpassword": setupVariables.ServerAdminPassword = value; break; case "serverpassword": setupVariables.ServerPassword = value; break; case "useraccount": setupVariables.UserAccount = value; break; case "userpassword": setupVariables.UserPassword = value; break; case "userdomain": setupVariables.UserDomain = value; break; case "enterpriseserverurl": setupVariables.EnterpriseServerURL = value; break; case "licensekey": setupVariables.LicenseKey = value; break; case "dbinstallconnectionstring": setupVariables.DbInstallConnectionString = value; break; } } }
public static DialogResult UpdateBase(object obj, string minimalInstallerVersion, string versionToUpgrade, bool updateSql, InstallAction versionSpecificAction) { Hashtable args = Utils.GetSetupParameters(obj); 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); } // Load application configuration AppConfig.LoadConfiguration(); // var setupVariables = new SetupVariables { SetupAction = SetupActions.Update, ComponentId = Utils.GetStringSetupParameter(args, "ComponentId"), IISVersion = Global.IISVersion, }; // Load setup variables from app.config AppConfig.LoadComponentSettings(setupVariables); // InstallerForm form = new InstallerForm(); form.Wizard.SetupVariables = setupVariables; Wizard wizard = form.Wizard; // Initialize setup variables with the data received from update procedure wizard.SetupVariables.BaseDirectory = Utils.GetStringSetupParameter(args, "BaseDirectory"); wizard.SetupVariables.UpdateVersion = Utils.GetStringSetupParameter(args, "UpdateVersion"); wizard.SetupVariables.InstallerFolder = Utils.GetStringSetupParameter(args, "InstallerFolder"); wizard.SetupVariables.Installer = Utils.GetStringSetupParameter(args, "Installer"); wizard.SetupVariables.InstallerType = Utils.GetStringSetupParameter(args, "InstallerType"); wizard.SetupVariables.InstallerPath = Utils.GetStringSetupParameter(args, "InstallerPath"); // if (!VersionEquals(wizard.SetupVariables.Version, versionToUpgrade)) { MessageBox.Show( string.Format("Please update to version {0}", versionToUpgrade), "Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(DialogResult.Cancel); } // IntroductionPage introPage = new IntroductionPage(); LicenseAgreementPage licPage = new LicenseAgreementPage(); ExpressInstallPage page2 = new ExpressInstallPage(); //create install currentScenario InstallAction action = new InstallAction(ActionTypes.StopApplicationPool); action.Description = "Stopping IIS Application Pool..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.Backup); action.Description = "Backing up..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.DeleteFiles); action.Description = "Deleting files..."; action.Path = "setup\\delete.txt"; page2.Actions.Add(action); action = new InstallAction(ActionTypes.CopyFiles); action.Description = "Copying files..."; page2.Actions.Add(action); if (versionSpecificAction != null) { page2.Actions.Add(versionSpecificAction); } if (updateSql) { action = new InstallAction(ActionTypes.ExecuteSql); action.Description = "Updating database..."; action.Path = "setup\\update_db.sql"; page2.Actions.Add(action); } action = new InstallAction(ActionTypes.UpdateConfig); action.Description = "Updating system configuration..."; page2.Actions.Add(action); action = new InstallAction(ActionTypes.StartApplicationPool); action.Description = "Starting IIS Application Pool..."; page2.Actions.Add(action); FinishPage page3 = new FinishPage(); wizard.Controls.AddRange(new Control[] { introPage, licPage, page2, page3 }); wizard.LinkPages(); wizard.SelectedPage = introPage; //show wizard IWin32Window owner = args["ParentForm"] as IWin32Window; return(form.ShowModal(owner)); }
public static DialogResult Uninstall(object obj) { Hashtable args = Utils.GetSetupParameters(obj); string shellVersion = Utils.GetStringSetupParameter(args, Global.Parameters.ShellVersion); // var setupVariables = new SetupVariables { ComponentId = Utils.GetStringSetupParameter(args, Global.Parameters.ComponentId), IISVersion = Global.IISVersion, SetupAction = SetupActions.Uninstall }; // AppConfig.LoadConfiguration(); InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; wizard.SetupVariables = setupVariables; // AppConfig.LoadComponentSettings(wizard.SetupVariables); // IntroductionPage page1 = new IntroductionPage(); ConfirmUninstallPage page2 = new ConfirmUninstallPage(); UninstallPage page3 = new UninstallPage(); //create uninstall currentScenario InstallAction action = new InstallAction(ActionTypes.DeleteShortcuts); action.Description = "Deleting shortcuts..."; action.Log = "- Delete shortcuts"; action.Name = "Login to WebsitePanel.url"; page3.Actions.Add(action); page2.UninstallPage = page3; FinishPage page4 = new FinishPage(); wizard.Controls.AddRange(new Control[] { page1, page2, page3, page4 }); wizard.LinkPages(); wizard.SelectedPage = page1; //show wizard IWin32Window owner = args[Global.Parameters.ParentForm] as IWin32Window; return form.ShowModal(owner); }
internal static object InstallBase(object obj, string minimalInstallerVersion) { Hashtable args = Utils.GetSetupParameters(obj); //check CS version string shellVersion = Utils.GetStringSetupParameter(args, Global.Parameters.ShellVersion); var shellMode = Utils.GetStringSetupParameter(args, Global.Parameters.ShellMode); Version version = new Version(shellVersion); // var setupVariables = new SetupVariables { SetupAction = SetupActions.Install, IISVersion = Global.IISVersion }; // InitInstall(args, setupVariables); //Unattended setup LoadSetupVariablesFromSetupXml(setupVariables.SetupXml, setupVariables); // var sam = new ServerActionManager(setupVariables); // Prepare installation defaults sam.PrepareDistributiveDefaults(); // Silent Installer Mode if (shellMode.Equals(Global.SilentInstallerShell, StringComparison.OrdinalIgnoreCase)) { if (version < new Version(minimalInstallerVersion)) { Utils.ShowConsoleErrorMessage(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion); // return(false); } try { var success = true; // setupVariables.ServerPassword = Utils.GetStringSetupParameter(args, Global.Parameters.ServerPassword); // sam.ActionError += new EventHandler <ActionErrorEventArgs>((object sender, ActionErrorEventArgs e) => { Utils.ShowConsoleErrorMessage(e.ErrorMessage); // Log.WriteError(e.ErrorMessage); // success = false; }); // sam.Start(); // return(success); } catch (Exception ex) { Log.WriteError("Failed to install the component", ex); // return(false); } } else { if (version < new Version(minimalInstallerVersion)) { MessageBox.Show(String.Format(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion), "Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return(DialogResult.Cancel); } var form = new InstallerForm(); var wizard = form.Wizard; wizard.SetupVariables = setupVariables; // wizard.ActionManager = sam; //create wizard pages var introPage = new IntroductionPage(); var licPage = new LicenseAgreementPage(); // var page1 = new ConfigurationCheckPage(); page1.Checks.AddRange(new ConfigurationCheck[] { new ConfigurationCheck(CheckTypes.OperationSystem, "Operating System Requirement"), new ConfigurationCheck(CheckTypes.IISVersion, "IIS Requirement"), new ConfigurationCheck(CheckTypes.ASPNET, "ASP.NET Requirement") }); // var page2 = new InstallFolderPage(); var page3 = new WebPage(); var page4 = new UserAccountPage(); var page5 = new ServerPasswordPage(); var page6 = new ExpressInstallPage2(); var page7 = new FinishPage(); // wizard.Controls.AddRange(new Control[] { introPage, licPage, page1, page2, page3, page4, page5, page6, page7 }); wizard.LinkPages(); wizard.SelectedPage = introPage; //show wizard IWin32Window owner = args["ParentForm"] as IWin32Window; return(form.ShowModal(owner)); } }
protected static void LoadComponentVariablesFromSetupXml(string componentCode, string xml, SetupVariables setupVariables) { if (string.IsNullOrEmpty(componentCode)) { return; } if (string.IsNullOrEmpty(xml)) { return; } try { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); string xpath = string.Format("components/component[@code=\"{0}\"]", componentCode); XmlNode componentNode = doc.SelectSingleNode(xpath); if (componentNode != null) { LoadSetupVariablesFromSetupXml(componentNode.InnerXml, setupVariables); } } catch (Exception ex) { Log.WriteError("Unattended setup error", ex); throw; } }