This commit is contained in:
Virtuworks 2015-05-13 03:12:54 -04:00
commit b29de7fd74
6 changed files with 127 additions and 18 deletions

View file

@ -563,8 +563,8 @@
<Property Id="COMPFOUND_SERVER" Secure="yes" Value="0" />
<Property Id="COMPFOUND_ESERVER" Secure="yes" Value="0" />
<Property Id="COMPFOUND_PORTAL" Secure="yes" Value="0" />
<Property Id="COMPFOUND_WDPORTAL" Secure="yes" Value="0" />
<Property Id="COMPFOUND_SCHEDULER" Secure="yes" Value="0" />
<Property Id="COMPFOUND_WDPORTAL" Secure="yes" Value="1" />
<Property Id="COMPFOUND_SCHEDULER" Secure="yes" Value="1" />
<!--CustomActions.-->
<!-- <CustomAction Id='AlreadyUpdated' Error='Product has already been updated to $(var.VERSION) or newer.' />
<CustomAction Id='NoDowngrade' Error='A later version of [ProductName] is already installed.' /> -->
@ -599,7 +599,7 @@
<CustomAction Id="CA_PropertyOnServerInstall" Property="CA_OnServerInstall" Value="ApplicationName=$(var.NAME);ComponentName=$(var.ServerTitle);ComponentCode=server;ComponentDescription=$(var.ServerDescription);Version=$(var.VERSION);InstallationFolder=[INSTALLSERVERFOLDER];InstallerFolder=[WEBSITEPANELDIR];Installer=[];InstallerType=[];InstallerPath=[];IISVersion=[];SetupXml=[];WebSiteIP=[PI_SERVER_IP];WebSitePort=[PI_SERVER_PORT];WebSiteDomain=[PI_SERVER_HOST];UserDomain=[PI_SERVER_DOMAIN];UserAccount=[PI_SERVER_LOGIN];UserPassword=[PI_SERVER_PASSWORD];ServerPassword=[SERVER_ACCESS_PASSWORD];EnterpriseServerUrl=[PI_ESERVER_URL];ServerAdminPassword=[SERVERADMIN_PASSWORD];DatabaseServer=[DB_SERVER];DatabaseName=[DB_DATABASE];DbServerAdmin=[DB_LOGIN];DbServerAdminPassword=[DB_PASSWORD];BaseDirectory=[WEBSITEPANELDIR];MODE_UP=[WIX_UPGRADE_DETECTED];MODE_RUP=[UPGRADINGPRODUCTCODE]" />
<CustomAction Id="CA_OnServerInstall" BinaryKey ="Assembly_CA" DllEntry="OnServerInstall" Impersonate="no" Execute="deferred" HideTarget="no"/>
<!--EServer.-->
<CustomAction Id="CA_PropertyOnEServerInstall" Property="CA_OnEServerInstall" Value="ApplicationName=$(var.NAME);ComponentName=$(var.EServerTitle);ComponentCode=enterpriseserver;ComponentDescription=$(var.EServerDescription);Version=$(var.VERSION);InstallationFolder=[INSTALLENTERPRISESERVERFOLDER];InstallerFolder=[WEBSITEPANELDIR];Installer=[];InstallerType=[];InstallerPath=[];IISVersion=[];SetupXml=[];WebSiteIP=[PI_ESERVER_IP];WebSitePort=[PI_ESERVER_PORT];WebSiteDomain=[PI_ESERVER_HOST];UserDomain=[PI_ESERVER_DOMAIN];UserAccount=[PI_ESERVER_LOGIN];UserPassword=[PI_ESERVER_PASSWORD];ServerPassword=[SERVER_ACCESS_PASSWORD];EnterpriseServerUrl=[PI_ESERVER_URL];ServerAdminPassword=[SERVERADMIN_PASSWORD];DatabaseServer=[DB_SERVER];DatabaseName=[DB_DATABASE];DbServerAdmin=[DB_LOGIN];DbServerAdminPassword=[DB_PASSWORD];BaseDirectory=[WEBSITEPANELDIR];MODE_UP=[WIX_UPGRADE_DETECTED];MODE_RUP=[UPGRADINGPRODUCTCODE]" />
<CustomAction Id="CA_PropertyOnEServerInstall" Property="CA_OnEServerInstall" Value="ApplicationName=$(var.NAME);ComponentName=$(var.EServerTitle);ComponentCode=enterprise server;ComponentDescription=$(var.EServerDescription);Version=$(var.VERSION);InstallationFolder=[INSTALLENTERPRISESERVERFOLDER];InstallerFolder=[WEBSITEPANELDIR];Installer=[];InstallerType=[];InstallerPath=[];IISVersion=[];SetupXml=[];WebSiteIP=[PI_ESERVER_IP];WebSitePort=[PI_ESERVER_PORT];WebSiteDomain=[PI_ESERVER_HOST];UserDomain=[PI_ESERVER_DOMAIN];UserAccount=[PI_ESERVER_LOGIN];UserPassword=[PI_ESERVER_PASSWORD];ServerPassword=[SERVER_ACCESS_PASSWORD];EnterpriseServerUrl=[PI_ESERVER_URL];ServerAdminPassword=[SERVERADMIN_PASSWORD];DatabaseServer=[DB_SERVER];DatabaseName=[DB_DATABASE];DbServerAdmin=[DB_LOGIN];DbServerAdminPassword=[DB_PASSWORD];BaseDirectory=[WEBSITEPANELDIR];MODE_UP=[WIX_UPGRADE_DETECTED];MODE_RUP=[UPGRADINGPRODUCTCODE]" />
<CustomAction Id="CA_OnEServerInstall" BinaryKey ="Assembly_CA" DllEntry="OnEServerInstall" Impersonate="no" Execute="deferred" HideTarget="no"/>
<!--Portal.-->
<CustomAction Id="CA_PropertyOnPortalInstall" Property="CA_OnPortalInstall" Value="ApplicationName=$(var.NAME);ComponentName=$(var.PortalTitle);ComponentCode=portal;ComponentDescription=$(var.PortalDescription);Version=$(var.VERSION);InstallationFolder=[INSTALLPORTALFOLDER];InstallerFolder=[WEBSITEPANELDIR];Installer=[];InstallerType=[];InstallerPath=[];IISVersion=[];SetupXml=[];WebSiteIP=[PI_PORTAL_IP];WebSitePort=[PI_PORTAL_PORT];WebSiteDomain=[PI_PORTAL_HOST];UserDomain=[PI_PORTAL_DOMAIN];UserAccount=[PI_PORTAL_LOGIN];UserPassword=[PI_PORTAL_PASSWORD];ServerPassword=[SERVER_ACCESS_PASSWORD];EnterpriseServerUrl=[PI_ESERVER_URL];ServerAdminPassword=[SERVERADMIN_PASSWORD];DatabaseServer=[DB_SERVER];DatabaseName=[DB_DATABASE];DbServerAdmin=[DB_LOGIN];DbServerAdminPassword=[DB_PASSWORD];BaseDirectory=[WEBSITEPANELDIR];MODE_UP=[WIX_UPGRADE_DETECTED];MODE_RUP=[UPGRADINGPRODUCTCODE]" />
@ -607,14 +607,14 @@
<!--Run corresponding uninstall scripts.-->
<CustomAction Id="CA_PropertyOnServerRemove" Property="CA_OnServerRemove" Value="InstallerFolder=[WEBSITEPANELDIR];ComponentCode=server;BaseDirectory=[WEBSITEPANELDIR];MODE_UP=[WIX_UPGRADE_DETECTED];MODE_RUP=[UPGRADINGPRODUCTCODE]" />
<CustomAction Id="CA_OnServerRemove" BinaryKey="Assembly_CA" DllEntry="OnServerRemove" Impersonate="no" Execute="deferred" HideTarget="no" />
<CustomAction Id="CA_PropertyOnEServerRemove" Property="CA_OnEServerRemove" Value="InstallerFolder=[WEBSITEPANELDIR];ComponentCode=enterpriseserver;BaseDirectory=[WEBSITEPANELDIR];MODE_UP=[WIX_UPGRADE_DETECTED];MODE_RUP=[UPGRADINGPRODUCTCODE]" />
<CustomAction Id="CA_PropertyOnEServerRemove" Property="CA_OnEServerRemove" Value="InstallerFolder=[WEBSITEPANELDIR];ComponentCode=enterprise server;BaseDirectory=[WEBSITEPANELDIR];MODE_UP=[WIX_UPGRADE_DETECTED];MODE_RUP=[UPGRADINGPRODUCTCODE]" />
<CustomAction Id="CA_OnEServerRemove" BinaryKey="Assembly_CA" DllEntry="OnEServerRemove" Impersonate="no" Execute="deferred" HideTarget="no" />
<CustomAction Id="CA_PropertyOnPortalRemove" Property="CA_OnPortalRemove" Value="InstallerFolder=[WEBSITEPANELDIR];ComponentCode=portal;BaseDirectory=[WEBSITEPANELDIR];MODE_UP=[WIX_UPGRADE_DETECTED];MODE_RUP=[UPGRADINGPRODUCTCODE]" />
<CustomAction Id="CA_OnPortalRemove" BinaryKey="Assembly_CA" DllEntry="OnPortalRemove" Impersonate="no" Execute="deferred" HideTarget="no" />
<!--Maintenance mode.-->
<CustomAction Id="CA_PropertyMaintenanceServer" Property="CA_MaintenanceServer" Value="InstallerFolder=[WEBSITEPANELDIR];ComponentCode=server;BaseDirectory=[WEBSITEPANELDIR];ServerPassword=[SERVER_ACCESS_PASSWORD]" />
<CustomAction Id="CA_MaintenanceServer" BinaryKey="Assembly_CA" DllEntry="MaintenanceServer" Impersonate="no" Execute="deferred" HideTarget="no" />
<CustomAction Id="CA_PropertyMaintenanceEServer" Property="CA_MaintenanceEServer" Value="InstallerFolder=[WEBSITEPANELDIR];ComponentCode=enterpriseserver;BaseDirectory=[WEBSITEPANELDIR];ServerAdminPassword=[SERVERADMIN_PASSWORD];" />
<CustomAction Id="CA_PropertyMaintenanceEServer" Property="CA_MaintenanceEServer" Value="InstallerFolder=[WEBSITEPANELDIR];ComponentCode=enterprise server;BaseDirectory=[WEBSITEPANELDIR];ServerAdminPassword=[SERVERADMIN_PASSWORD];" />
<CustomAction Id="CA_MaintenanceEServer" BinaryKey="Assembly_CA" DllEntry="MaintenanceEServer" Impersonate="no" Execute="deferred" HideTarget="no" />
<CustomAction Id="CA_PropertyMaintenancePortal" Property="CA_MaintenancePortal" Value="InstallerFolder=[WEBSITEPANELDIR];ComponentCode=portal;BaseDirectory=[WEBSITEPANELDIR];EnterpriseServerUrl=[PI_ESERVER_URL]" />
<CustomAction Id="CA_MaintenancePortal" BinaryKey="Assembly_CA" DllEntry="MaintenancePortal" Impersonate="no" Execute="deferred" HideTarget="no" />
@ -649,7 +649,7 @@
<Custom Action="CA_PropertyMaintenancePortal" After="InstallInitialize"><![CDATA[&PortalFeature=-1 AND !PortalFeature=3]]></Custom>
<Custom Action="CA_MaintenancePortal" After="CA_PropertyMaintenancePortal"><![CDATA[&PortalFeature=-1 AND !PortalFeature=3]]></Custom>
<!---->
<Custom Action="CA_PreFillSettings" After="SetWEBSITEPANELDIR">1</Custom>
<!--<Custom Action="CA_PreFillSettings" After="SetWEBSITEPANELDIR">1</Custom>-->
</InstallExecuteSequence>
<InstallUISequence>
<Custom Action="CA_PreFillSettings" Before="CA_InstallWebFeatures" />

View file

@ -39,6 +39,7 @@ namespace WebsitePanel.Setup
public const string DefaultInstallPathRoot = @"C:\WebsitePanel";
public const string LoopbackIPv4 = "127.0.0.1";
public const string InstallerProductCode = "cfg core";
public const string DefaultProductName = "WebsitePanel";
public abstract class Parameters
{

View file

@ -170,9 +170,13 @@ namespace WebsitePanel.Setup.Internal
}
public static string GetComponentID(SetupVariables Ctx)
{
var XmlPath = string.Format("//component[.//add/@key='ComponentCode' and .//add/@value='{0}']", Ctx.ComponentCode);
return GetComponentID(GetFullConfigPath(Ctx), Ctx.ComponentCode);
}
public static string GetComponentID(string Cfg, string ComponentCode)
{
var XmlPath = string.Format("//component[.//add/@key='ComponentCode' and .//add/@value='{0}']", ComponentCode);
var Xml = new XmlDocument();
Xml.Load(GetFullConfigPath(Ctx));
Xml.Load(Cfg);
var Node = Xml.SelectSingleNode(XmlPath) as XmlElement;
return Node == null ? null : Node.GetAttribute("id");
}
@ -3926,20 +3930,20 @@ namespace WebsitePanel.Setup.Internal
try
{
Log.WriteStart("RestoreXmlConfigs");
var Backup = BackupRestore.Find(Ctx.InstallerFolder, "WebsitePanel", Ctx.ComponentName);
var Backup = BackupRestore.Find(Ctx.InstallerFolder, Global.DefaultProductName, Ctx.ComponentName);
switch(Ctx.ComponentCode)
{
case "server":
case Global.Server.ComponentCode:
{
Backup.XmlFiles.Add("Web.config");
}
break;
case "enterpriseserver":
case Global.EntServer.ComponentCode:
{
Backup.XmlFiles.Add("Web.config");
}
break;
case "portal":
case Global.WebPortal.ComponentCode:
{
Backup.XmlFiles.Add("Web.config");
Backup.XmlFiles.Add(@"App_Data\Countries.config");
@ -3957,9 +3961,7 @@ namespace WebsitePanel.Setup.Internal
break;
}
var MainCfg = Path.Combine(Ctx.InstallerFolder, BackupRestore.MainConfig);
var XCfg = new XmlDocument();
XCfg.Load(MainCfg);
if (XCfg.SelectSingleNode("//components").ChildNodes.Count == 0)
if (!BackupRestore.HaveChild(MainCfg, "//components"))
{
Log.WriteInfo("Restoring main config...");
XmlDocumentMerge.Process(Backup.BackupMainConfigFile, MainCfg);

View file

@ -8,7 +8,7 @@ using Ionic.Zip;
namespace WebsitePanel.Setup.Internal
{
class BackupRestore
public class BackupRestore
{
struct DirectoryTag
{
@ -47,9 +47,7 @@ namespace WebsitePanel.Setup.Internal
Version BckpVersion;
var StrVersion = VersionName.Substring(FullId.Length);
if (Version.TryParse(StrVersion, out BckpVersion))
{
DirList.Add(new DirectoryTag { Name = VersionItem, Date = date, Version = BckpVersion });
}
}
}
}
@ -61,6 +59,16 @@ namespace WebsitePanel.Setup.Internal
}
return Result;
}
public static bool HaveChild(string XmlDocPath, string XmlPath)
{
var Result = false;
var XCfg = new XmlDocument();
XCfg.Load(XmlDocPath);
var Node = XCfg.SelectSingleNode(XmlPath);
if (Node != null)
Result = Node.ChildNodes.Count > 0;
return Result;
}
private static string GetComponentRoot(DirectoryTag DirTag, string Id)
{
var Cfg = GetMainConfig(DirTag);

View file

@ -27,6 +27,7 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Configuration.Install;
using System.Data;
using System.Data.Sql;
@ -87,6 +88,102 @@ namespace WebsitePanel.WIXInstaller
var Ctx = session;
Ctx.AttachToSetupLog();
Log.WriteStart("PreFillSettings");
var WSP = Ctx["WEBSITEPANELDIR"];
var CfgStr = string.Empty;
Func<string, string> GetCfg = (string CfgDir) =>
{
if (Directory.Exists(CfgDir))
{
var CfgFile = Path.Combine(CfgDir, BackupRestore.MainConfig);
if (File.Exists(CfgFile) && BackupRestore.HaveChild(CfgFile, "//components"))
return CfgFile;
else
{
var Names = new string[] { Global.Server.ComponentName, Global.EntServer.ComponentName, Global.WebPortal.ComponentName };
foreach (var Name in Names)
{
var Backup = BackupRestore.Find(CfgDir, Global.DefaultProductName, Name);
if (Backup != null && BackupRestore.HaveChild(Backup.BackupMainConfigFile, "//components"))
return CfgStr = Backup.BackupMainConfigFile;
}
}
}
return string.Empty;
};
Func<Session, string, string, bool> SetProperty = (Session CtxSession, string Prop, string Value) =>
{
if(!string.IsNullOrWhiteSpace(Value))
{
CtxSession[Prop] = Value;
return true;
}
return false;
};
CfgStr = GetCfg(WSP);
if(string.IsNullOrWhiteSpace(CfgStr))
{
var Drives = from Drive in DriveInfo.GetDrives() where Drive.DriveType == DriveType.Fixed select Drive;
foreach(var Drive in Drives)
{
var Dir = Path.Combine(Drive.RootDirectory.FullName, Global.DefaultProductName);
CfgStr = GetCfg(Dir);
if (!string.IsNullOrWhiteSpace(CfgStr))
break;
}
}
if (!string.IsNullOrWhiteSpace(CfgStr))
{
var EServerUrl = string.Empty;
AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = CfgStr });
var CtxVars = new SetupVariables();
CtxVars.ComponentId = WiXSetup.GetComponentID(CfgStr, Global.Server.ComponentCode);
if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId))
{
AppConfig.LoadComponentSettings(CtxVars);
Ctx["COMPFOUND_SERVER"] = "1";
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_PASSWORD", CtxVars.UserPassword);
SetProperty(Ctx, "PI_SERVER_PASSWORD_CONFIRM",CtxVars.UserPassword);
SetProperty(Ctx, "PI_SERVER_DOMAIN", CtxVars.UserDomain);
SetProperty(Ctx, "SERVER_ACCESS_PASSWORD", CtxVars.ServerPassword);
SetProperty(Ctx, "SERVER_ACCESS_PASSWORD_CONFIRM", CtxVars.ServerPassword);
}
CtxVars.ComponentId = WiXSetup.GetComponentID(CfgStr, Global.EntServer.ComponentCode);
if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId))
{
AppConfig.LoadComponentSettings(CtxVars);
Ctx["COMPFOUND_ESERVER"] = "1";
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_PASSWORD", CtxVars.UserPassword);
SetProperty(Ctx, "PI_ESERVER_PASSWORD_CONFIRM", CtxVars.UserPassword);
SetProperty(Ctx, "PI_ESERVER_DOMAIN", CtxVars.UserDomain);
SetProperty(Ctx, "SERVERADMIN_PASSWORD", CtxVars.ServerAdminPassword);
SetProperty(Ctx, "SERVERADMIN_PASSWORD_CONFIRM", CtxVars.ServerAdminPassword);
EServerUrl = string.Format("http://{0}:{1}", CtxVars.WebSiteIP, CtxVars.WebSitePort);
}
CtxVars.ComponentId = WiXSetup.GetComponentID(CfgStr, Global.WebPortal.ComponentCode);
if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId))
{
AppConfig.LoadComponentSettings(CtxVars);
Ctx["COMPFOUND_PORTAL"] = "1";
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_PASSWORD", CtxVars.UserPassword);
SetProperty(Ctx, "PI_PORTAL_PASSWORD_CONFIRM", CtxVars.UserPassword);
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);
}
}
TryApllyNewPassword(Ctx, "PI_SERVER_PASSWORD");
TryApllyNewPassword(Ctx, "PI_ESERVER_PASSWORD");
TryApllyNewPassword(Ctx, "PI_PORTAL_PASSWORD");

View file

@ -47,6 +47,7 @@
<HintPath>..\..\Lib\Microsoft.Web.Administration.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />