diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs index f45e3503..bfd91d56 100644 --- a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs +++ b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs @@ -565,6 +565,16 @@ + + + + + + + + + + @@ -593,23 +603,23 @@ - + - + - + - + - + - + diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/EntServerActionManager.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/EntServerActionManager.cs index 3680e837..4afab84d 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/EntServerActionManager.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/EntServerActionManager.cs @@ -63,6 +63,9 @@ namespace WebsitePanel.Setup.Actions void IInstallAction.Run(SetupVariables vars) { + if (vars.ComponentExists) + return; + try { OnInstallProgressChanged(LogStartInstallMessage, 0); @@ -232,6 +235,9 @@ namespace WebsitePanel.Setup.Actions { void IInstallAction.Run(SetupVariables vars) { + if (vars.ComponentExists) + return; + try { // @@ -330,6 +336,9 @@ namespace WebsitePanel.Setup.Actions void IInstallAction.Run(SetupVariables vars) { + if (vars.ComponentExists) + return; + try { Log.WriteStart("Updating serveradmin password"); @@ -389,6 +398,9 @@ namespace WebsitePanel.Setup.Actions { void IInstallAction.Run(SetupVariables vars) { + if (vars.ComponentExists) + return; + Log.WriteStart("Updating web.config file (connection string)"); var file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile); vars.ConnectionString = String.Format(vars.ConnectionString, vars.DatabaseServer, vars.Database, vars.Database, vars.DatabaseUserPassword); diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/ServerActionManager.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/ServerActionManager.cs index 05f14d9d..57f60eb7 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/ServerActionManager.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/ServerActionManager.cs @@ -151,6 +151,8 @@ namespace WebsitePanel.Setup.Actions void IInstallAction.Run(SetupVariables vars) { + if (vars.ComponentExists) + return; // Exit with an error if Windows account with the same name already exists if (SecurityUtils.UserExists(vars.UserDomain, vars.UserAccount)) throw new Exception(UserAccountExists); @@ -394,7 +396,7 @@ namespace WebsitePanel.Setup.Actions } // This flag is the opposite of poolExists flag - vars.NewWebApplicationPool = !poolExists; + vars.NewWebApplicationPool = !poolExists || vars.ComponentExists; if (poolExists) { @@ -501,6 +503,9 @@ namespace WebsitePanel.Setup.Actions void IInstallAction.Run(SetupVariables vars) { + if (vars.ComponentExists) + return; + var siteName = vars.ComponentFullName; var ip = vars.WebSiteIP; var port = vars.WebSitePort; @@ -774,6 +779,9 @@ namespace WebsitePanel.Setup.Actions void IInstallAction.Run(SetupVariables vars) { + if (vars.ComponentExists) + return; + try { Begin(LogStartInstallMessage); diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/FileUtils.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/FileUtils.cs index 8ce06987..ecab1061 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/FileUtils.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/FileUtils.cs @@ -335,10 +335,10 @@ namespace WebsitePanel.Setup return files; } - public static void CopyFileToFolder(string sourceFile, string destinationFolder) + public static void CopyFileToFolder(string sourceFile, string destinationFolder, string destinationFileName = "") { string fileName = Path.GetFileName(sourceFile); - string destinationFile = Path.Combine(destinationFolder, fileName); + string destinationFile = Path.Combine(destinationFolder, string.IsNullOrWhiteSpace(destinationFileName) ? fileName : destinationFileName); CopyFile(new FileInfo(sourceFile), destinationFile); } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SetupVariables.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SetupVariables.cs index 91184c43..15cbc217 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SetupVariables.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SetupVariables.cs @@ -249,6 +249,11 @@ namespace WebsitePanel.Setup public string BaseDirectory { get; set; } + public string SpecialBaseDirectory { get; set; } + public IDictionary FileNameMap { get; set; } + + public bool ComponentExists { get; set; } + public string UpdateVersion { get; set; } public string EnterpriseServerURL { get; set; } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/Adapter.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/Adapter.cs index ea06fd77..2deea1a8 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/Adapter.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/Adapter.cs @@ -163,6 +163,8 @@ namespace WebsitePanel.Setup.Internal Utils.GetStringSetupParameter(Hash, Global.Parameters.DbServerAdminPassword)); Dst.BaseDirectory = Utils.GetStringSetupParameter(Hash, Global.Parameters.BaseDirectory); + Dst.ComponentId = Utils.GetStringSetupParameter(Hash, Global.Parameters.ComponentId); + Dst.ComponentExists = string.IsNullOrWhiteSpace(Dst.ComponentId) ? false : true; } public static string GetFullConfigPath(SetupVariables Ctx) { @@ -2739,7 +2741,7 @@ namespace WebsitePanel.Setup.Internal BackupDatabase(action.ConnectionString, action.Name); break; case ActionTypes.BackupConfig: - BackupConfig(action.Path, destinationDirectory); + BackupConfig(action.Path, destinationDirectory, action.SetupVariables != null ? action.SetupVariables.FileNameMap : null); break; } } @@ -2755,7 +2757,7 @@ namespace WebsitePanel.Setup.Internal } } - private void BackupConfig(string path, string backupDirectory) + private void BackupConfig(string path, string backupDirectory, IDictionary NameMap = null) { try { @@ -2772,7 +2774,7 @@ namespace WebsitePanel.Setup.Internal string[] files = Directory.GetFiles(path, "*.config", SearchOption.TopDirectoryOnly); foreach (string file in files) { - FileUtils.CopyFileToFolder(file, destination); + FileUtils.CopyFileToFolder(file, destination, GetMappedFileName(file, NameMap)); } Log.WriteEnd("Backed up system configuration"); InstallLog.AppendLine("- Backed up system configuration"); @@ -2786,6 +2788,17 @@ namespace WebsitePanel.Setup.Internal } } + private string GetMappedFileName(string FullFileName, IDictionary Map) + { + if (Map == null) + return ""; + string Key = new FileInfo(FullFileName).Name; + if (Map.Keys.Contains(Key)) + return Map[Key]; + else + return ""; + } + private void BackupDatabase(string connectionString, string database) { try @@ -2881,10 +2894,14 @@ namespace WebsitePanel.Setup.Internal } //config action = new InstallAction(ActionTypes.BackupConfig); - action.Description = "Backing up configuration settings..."; action.Path = Context.BaseDirectory; + action.Description = "Backing up configuration settings..."; + if (!string.IsNullOrWhiteSpace(Context.SpecialBaseDirectory) ) + { + action.Path = Context.SpecialBaseDirectory; + action.SetupVariables = Context; + } list.Add(action); - return list; } private void UpdateWebSiteBindings() @@ -4225,6 +4242,12 @@ namespace WebsitePanel.Setup.Internal WiXThrow = true; }); sam.Start(); + if (Context.ComponentExists) + { + Context.UpdateVersion = Context.Release; + AppConfig.LoadComponentSettings(Context); + new RestoreScript(Context).Run(); + } } catch (Exception ex) { @@ -4303,6 +4326,12 @@ namespace WebsitePanel.Setup.Internal WiXThrow = true; }); sam.Start(); + if(Context.ComponentExists) + { + Context.UpdateVersion = Context.Release; + AppConfig.LoadComponentSettings(Context); + new RestoreScript(Context).Run(); + } } catch (Exception ex) { @@ -4381,6 +4410,12 @@ namespace WebsitePanel.Setup.Internal WiXThrow = true; }); sam.Start(); + if (Context.ComponentExists) + { + Context.UpdateVersion = Context.Release; + AppConfig.LoadComponentSettings(Context); + new RestoreScript(Context).Run(); + } } catch (Exception ex) { diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs index ffaf53c2..b268cead 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs @@ -159,7 +159,7 @@ namespace WebsitePanel.WIXInstaller }; var Ctx = session; - Ctx.AttachToSetupLog(); + Ctx.AttachToSetupLog(); PopUpDebugger(); @@ -181,6 +181,9 @@ namespace WebsitePanel.WIXInstaller { AppConfig.LoadComponentSettings(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); @@ -200,6 +203,9 @@ namespace WebsitePanel.WIXInstaller { AppConfig.LoadComponentSettings(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); @@ -220,7 +226,7 @@ namespace WebsitePanel.WIXInstaller SetProperty(Ctx, "DB_LOGIN", ConnStr.UserID); SetProperty(Ctx, "DB_PASSWORD", ConnStr.Password); } - + var HaveAccount = SecurityUtils.UserExists(CtxVars.UserDomain, CtxVars.UserAccount); bool HavePool = Tool.AppPoolExists(CtxVars.ApplicationPool); @@ -231,6 +237,9 @@ namespace WebsitePanel.WIXInstaller { AppConfig.LoadComponentSettings(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); @@ -242,7 +251,7 @@ namespace WebsitePanel.WIXInstaller SetProperty(Ctx, "PI_PORTAL_INSTALL_DIR", CtxVars.InstallFolder); SetProperty(Ctx, "WSP_INSTALL_DIR", Directory.GetParent(CtxVars.InstallFolder).FullName); - + var HaveAccount = SecurityUtils.UserExists(CtxVars.UserDomain, CtxVars.UserAccount); bool HavePool = Tool.AppPoolExists(CtxVars.ApplicationPool); @@ -496,7 +505,7 @@ namespace WebsitePanel.WIXInstaller GetConnectionString(session["DB_SERVER"], "master", session["DB_LOGIN"], session["DB_PASSWORD"]); string msg; bool Result = CheckConnection(ConnStr, out msg); - session["DB_CONN_CORRECT"] = Result ? YesNo.Yes: YesNo.No; + session["DB_CONN_CORRECT"] = Result ? YesNo.Yes : YesNo.No; session["DB_CONN"] = Result ? ConnStr : ""; session["DB_CONN_MSG"] = msg; return ActionResult.Success; @@ -799,7 +808,7 @@ namespace WebsitePanel.WIXInstaller private static string GetProperty(Session Ctx, string Property) { if (Ctx.CustomActionData.ContainsKey(Property)) - return Ctx[Property]; + return Ctx.CustomActionData[Property]; else return string.Empty; } @@ -816,11 +825,17 @@ namespace WebsitePanel.WIXInstaller { 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(); + 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 }); + Result.Actions.Add(new InstallAction(ActionTypes.DeleteDirectory) { SetupVariables = CtxVars, Path = CtxVars.InstallFolder }); return Result; } }