Added file logger and default values for usernames, passwords.

This commit is contained in:
McMak 2015-05-08 20:50:54 +03:00
parent b35dec4356
commit ff7ccc7dab
4 changed files with 93 additions and 5 deletions

View file

@ -452,6 +452,7 @@
<Publish Dialog="FinishDlg" Control="Next" Event="NewDialog" Value="FinishDlg">1</Publish>
<!--ValidateDlg-->
<Publish Dialog="ValidateDlg" Control="Ok" Event="EndDialog" Value="Return">1</Publish>
<ProgressText Action="CA_InstallWebFeatures">Please wait while [ProductName] Installer configures IIS &amp; ASP.NET, this may take a few minutes. Thanks!</ProgressText>
</UI>
<Icon Id="WebSitePanel.ico" SourceFile="WebSitePanel.ico" />
<Binary Id="Assembly_CA" SourceFile="bin\WebsitePanel.WIXInstaller.CA.dll" />
@ -476,7 +477,7 @@
<!--SQL props.-->
<Property Id="DB_SERVER" Secure="yes" Value="localhost\SQLExpress" />
<Property Id="DB_CONN" Secure="yes" />
<Property Id="DB_DATABASE" Secure="yes" />
<Property Id="DB_DATABASE" Secure="yes" Value="WebsitePanel" />
<Property Id="DB_AUTH" Secure="yes" Value="Windows Authentication" />
<Property Id="DB_LOGIN" Secure="yes" />
<Property Id="DB_PASSWORD" Secure="yes" />
@ -503,7 +504,7 @@
<Property Id="PI_SERVER_IP" Secure="yes" Value="127.0.0.1" />
<Property Id="PI_SERVER_PORT" Secure="yes" Value="9003" />
<Property Id="PI_SERVER_HOST" Secure="yes" />
<Property Id="PI_SERVER_LOGIN" Secure="yes" />
<Property Id="PI_SERVER_LOGIN" Secure="yes" Value="WPServer"/>
<Property Id="PI_SERVER_PASSWORD" Secure="yes" />
<Property Id="PI_SERVER_PASSWORD_CONFIRM" Secure="yes" />
<Property Id="PI_SERVER_DOMAIN" Secure="yes" />
@ -512,7 +513,7 @@
<Property Id="PI_ESERVER_IP" Secure="yes" Value="127.0.0.1" />
<Property Id="PI_ESERVER_PORT" Secure="yes" Value="9002" />
<Property Id="PI_ESERVER_HOST" Secure="yes" />
<Property Id="PI_ESERVER_LOGIN" Secure="yes" />
<Property Id="PI_ESERVER_LOGIN" Secure="yes" Value="WPEnterpriseServer"/>
<Property Id="PI_ESERVER_PASSWORD" Secure="yes" />
<Property Id="PI_ESERVER_PASSWORD_CONFIRM" Secure="yes" />
<Property Id="PI_ESERVER_DOMAIN" Secure="yes" />
@ -522,7 +523,7 @@
<Property Id="PI_PORTAL_IP" Secure="yes" Value="127.0.0.1" />
<Property Id="PI_PORTAL_PORT" Secure="yes" Value="9001" />
<Property Id="PI_PORTAL_HOST" Secure="yes" />
<Property Id="PI_PORTAL_LOGIN" Secure="yes" />
<Property Id="PI_PORTAL_LOGIN" Secure="yes" Value="WPPortal" />
<Property Id="PI_PORTAL_PASSWORD" Secure="yes" />
<Property Id="PI_PORTAL_PASSWORD_CONFIRM" Secure="yes" />
<Property Id="PI_PORTAL_DOMAIN" Secure="yes" />
@ -590,9 +591,10 @@
<CustomAction Id="CA_OnPortalRemove" BinaryKey="Assembly_CA" DllEntry="OnPortalRemove" Impersonate="no" Execute="deferred" HideTarget="no" />
<!---->
<SetProperty Id="WEBSITEPANELDIR" After="AppSearch" Value="[WSP_ROOT]">WSP_ROOT</SetProperty>
<CustomAction Id="CA_PreFillSettings" BinaryKey="Assembly_CA" DllEntry="PreFillSettings" />
<!--Exe sequence.-->
<InstallExecuteSequence>
<Custom Action="CA_InstallWebFeatures" After="InstallValidate"><![CDATA[(&ServerFeature=3) OR (&EnterpriseServerFeature=3) OR (&PortalFeature=3) OR (&SchedulerServiceFeature=3) OR (&WDPortalFeature=3)]]></Custom>
<Custom Action="CA_InstallWebFeatures" Before="CostInitialize"><![CDATA[(&ServerFeature=3) OR (&EnterpriseServerFeature=3) OR (&PortalFeature=3) OR (&SchedulerServiceFeature=3) OR (&WDPortalFeature=3)]]></Custom>
<!--<Custom Action="CA_PropertyFinalizeInstall" After='InstallValidate'/>
<Custom Action="CA_FinalizeUnInstall" After="InstallValidate">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
<Custom Action="CA_FinalizeInstall" After="InstallFiles" >NOT Installed or REINSTALL</Custom>-->
@ -610,8 +612,10 @@
<Custom Action="CA_OnEServerRemove" Before="StopServices"><![CDATA[(&EnterpriseServerFeature=2) AND (!EnterpriseServerFeature=3)]]></Custom>
<Custom Action="CA_PropertyOnPortalRemove" After="InstallInitialize"><![CDATA[(&PortalFeature=2) AND (!PortalFeature=3)]]></Custom>
<Custom Action="CA_OnPortalRemove" After="CA_PropertyOnPortalRemove"><![CDATA[(&PortalFeature=2) AND (!PortalFeature=3)]]></Custom>
<Custom Action="CA_PreFillSettings" After="SetWEBSITEPANELDIR">1</Custom>
</InstallExecuteSequence>
<InstallUISequence>
<Custom Action="CA_PreFillSettings" Before="CA_InstallWebFeatures" />
<Custom Action="CA_InstallWebFeatures" Before="CA_PrereqCheck" />
<Custom Action="CA_PrereqCheck" After ="CostInitialize" />
<Custom Action="CA_PrereqCheckUI" After ="CA_PrereqCheck" />

View file

@ -0,0 +1,55 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;
namespace WebsitePanel.WIXInstaller.Common
{
public class WiXLogFileListener : TraceListener
{
public const uint FileFlushSize = 4096;
public const string DefaultLogFile = "WSPInstallation.log.txt";
public static string LogFile { get; private set; }
private StringBuilder m_Ctx;
static WiXLogFileListener()
{
LogFile = Path.Combine(Path.GetTempPath() + DefaultLogFile);
}
public WiXLogFileListener(string LogFileName = DefaultLogFile)
: base("WiXLogFileListener")
{
m_Ctx = new StringBuilder();
}
~WiXLogFileListener()
{
Dispose(false);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
Flush(true);
}
public override void Write(string Value)
{
m_Ctx.Append(Value);
Flush();
}
public override void WriteLine(string Value)
{
m_Ctx.AppendLine(Value);
Flush();
}
private void Flush(bool Force = false)
{
if(m_Ctx.Length >= FileFlushSize || Force)
{
using (var FileCtx = new StreamWriter(LogFile, true))
{
FileCtx.Write(m_Ctx.ToString());
}
m_Ctx.Clear();
}
}
}
}

View file

@ -54,6 +54,32 @@ namespace WebsitePanel.WIXInstaller
#region CustomActions
[CustomAction]
public static ActionResult PreFillSettings(Session session)
{
PopUpDebugger();
var Ctx = session;
Ctx.AttachToSetupLog();
Log.WriteStart("PreFillSettings");
TryApllyNewPassword(Ctx, "PI_SERVER_PASSWORD");
TryApllyNewPassword(Ctx, "PI_ESERVER_PASSWORD");
TryApllyNewPassword(Ctx, "PI_PORTAL_PASSWORD");
TryApllyNewPassword(Ctx, "SERVER_ACCESS_PASSWORD");
TryApllyNewPassword(Ctx, "SERVERADMIN_PASSWORD");
Log.WriteEnd("PreFillSettings");
return ActionResult.Success;
}
private static void TryApllyNewPassword(Session Ctx, string Id)
{
var Pass = Ctx[Id];
if(string.IsNullOrWhiteSpace(Pass))
{
Pass = Guid.NewGuid().ToString();
Ctx[Id] = Pass;
Ctx[Id + "_CONFIRM"] = Pass;
Log.WriteInfo("New password was applied to " + Id);
}
}
[CustomAction]
public static ActionResult InstallWebFeatures(Session session)
{
var Msg = string.Empty;
@ -406,6 +432,7 @@ namespace WebsitePanel.WIXInstaller
[CustomAction]
public static ActionResult FillIpListUI(Session session)
{
PopUpDebugger();
var Ctrls = new[]{ new ComboBoxCtrl(session, "PI_SERVER_IP"),
new ComboBoxCtrl(session, "PI_ESERVER_IP"),
new ComboBoxCtrl(session, "PI_PORTAL_IP") };
@ -758,6 +785,7 @@ namespace WebsitePanel.WIXInstaller
{
WiXSetup.InstallLogListener(new WiXLogListener(Ctx));
WiXSetup.InstallLogListener(new InMemoryStringLogListener("WIX CA IN MEMORY"));
WiXSetup.InstallLogListener(new WiXLogFileListener());
}
}

View file

@ -63,6 +63,7 @@
<Compile Include="Common\Tool.cs" />
<Compile Include="Common\Prop.cs" />
<Compile Include="Common\Util\IListCtrl.cs" />
<Compile Include="Common\WiXLogFileListener.cs" />
<Compile Include="Common\WiXLogListener.cs" />
<Compile Include="Common\YesNo.cs" />
<Compile Include="CustomAction.cs" />