Installer mods.
This commit is contained in:
parent
c22d6b60f3
commit
47adf43407
23 changed files with 1381 additions and 567 deletions
|
@ -67,37 +67,21 @@ namespace WebsitePanel.Setup.Actions
|
|||
{
|
||||
OnInstallProgressChanged(LogStartInstallMessage, 0);
|
||||
Log.WriteStart(LogStartInstallMessage);
|
||||
|
||||
var file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile);
|
||||
vars.CryptoKey = Utils.GetRandomString(20);
|
||||
|
||||
// load file
|
||||
string content = string.Empty;
|
||||
using (StreamReader reader = new StreamReader(file))
|
||||
{
|
||||
content = reader.ReadToEnd();
|
||||
}
|
||||
|
||||
// expand variables
|
||||
content = Utils.ReplaceScriptVariable(content, "installer.cryptokey", vars.CryptoKey);
|
||||
//
|
||||
Log.WriteInfo(String.Format("The following cryptographic key has been generated: '{0}'", vars.CryptoKey));
|
||||
|
||||
// save file
|
||||
using (StreamWriter writer = new StreamWriter(file))
|
||||
{
|
||||
writer.Write(content);
|
||||
}
|
||||
//update log
|
||||
var file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile);
|
||||
vars.CryptoKey = Utils.GetRandomString(20);
|
||||
var Xml = new XmlDocument();
|
||||
Xml.Load(file);
|
||||
var CryptoNode = Xml.SelectSingleNode("configuration/appSettings/add[@key='WebsitePanel.CryptoKey']") as XmlElement;
|
||||
if (CryptoNode != null)
|
||||
CryptoNode.SetAttribute("value", vars.CryptoKey);
|
||||
Xml.Save(file);
|
||||
Log.WriteEnd(LogEndInstallMessage);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (Utils.IsThreadAbortException(ex))
|
||||
return;
|
||||
//
|
||||
Log.WriteError("Update web.config error", ex);
|
||||
//
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
@ -116,6 +100,10 @@ namespace WebsitePanel.Setup.Actions
|
|||
Begin(LogStartInstallMessage);
|
||||
|
||||
Log.WriteStart(LogStartInstallMessage);
|
||||
|
||||
var ServiceName = Global.Parameters.SchedulerServiceName;
|
||||
var ServiceFile = Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName);
|
||||
|
||||
Log.WriteInfo(String.Format("Scheduler Service Name: \"{0}\"", Global.Parameters.SchedulerServiceName));
|
||||
|
||||
if (ServiceController.GetServices().Any(s => s.DisplayName.Equals(Global.Parameters.SchedulerServiceName, StringComparison.CurrentCultureIgnoreCase)))
|
||||
|
@ -125,8 +113,13 @@ namespace WebsitePanel.Setup.Actions
|
|||
return;
|
||||
}
|
||||
|
||||
ManagedInstallerClass.InstallHelper(new[] { "/i", Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName) });
|
||||
ManagedInstallerClass.InstallHelper(new[] { "/i /LogFile=\"\" ", ServiceFile });
|
||||
Utils.StartService(Global.Parameters.SchedulerServiceName);
|
||||
|
||||
AppConfig.EnsureComponentConfig(vars.ComponentId);
|
||||
AppConfig.SetComponentSettingStringValue(vars.ComponentId, "ServiceName", ServiceName);
|
||||
AppConfig.SetComponentSettingStringValue(vars.ComponentId, "ServiceFile", ServiceFile);
|
||||
AppConfig.SaveConfiguration();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -166,7 +159,7 @@ namespace WebsitePanel.Setup.Actions
|
|||
{
|
||||
if (ServiceController.GetServices().Any(s => s.ServiceName.Equals(Global.Parameters.SchedulerServiceName, StringComparison.CurrentCultureIgnoreCase)))
|
||||
{
|
||||
ManagedInstallerClass.InstallHelper(new[] { "/u", Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName) });
|
||||
ManagedInstallerClass.InstallHelper(new[] { "/u /LogFile=\"\" ", Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -397,25 +390,14 @@ namespace WebsitePanel.Setup.Actions
|
|||
void IInstallAction.Run(SetupVariables vars)
|
||||
{
|
||||
Log.WriteStart("Updating web.config file (connection string)");
|
||||
//
|
||||
var file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile);
|
||||
//
|
||||
var content = String.Empty;
|
||||
// load file
|
||||
using (StreamReader reader = new StreamReader(file))
|
||||
{
|
||||
content = reader.ReadToEnd();
|
||||
}
|
||||
// Build connection string
|
||||
vars.ConnectionString = String.Format(vars.ConnectionString, vars.DatabaseServer, vars.Database, vars.Database, vars.DatabaseUserPassword);
|
||||
// Expand variables
|
||||
content = Utils.ReplaceScriptVariable(content, "installer.connectionstring", vars.ConnectionString);
|
||||
// Save file
|
||||
using (StreamWriter writer = new StreamWriter(file))
|
||||
{
|
||||
writer.Write(content);
|
||||
}
|
||||
//
|
||||
var Xml = new XmlDocument();
|
||||
Xml.Load(file);
|
||||
var ConnNode = Xml.SelectSingleNode("configuration/connectionStrings/add[@name='EnterpriseServer']") as XmlElement;
|
||||
if(ConnNode != null)
|
||||
ConnNode.SetAttribute("connectionString", vars.ConnectionString);
|
||||
Xml.Save(file);
|
||||
Log.WriteEnd(String.Format("Updated {0} file", vars.ConfigurationFile));
|
||||
}
|
||||
}
|
||||
|
@ -509,10 +491,11 @@ namespace WebsitePanel.Setup.Actions
|
|||
{
|
||||
void IInstallAction.Run(SetupVariables vars)
|
||||
{
|
||||
Log.WriteStart("SaveEntServerConfigSettingsAction");
|
||||
AppConfig.EnsureComponentConfig(vars.ComponentId);
|
||||
//
|
||||
AppConfig.SetComponentSettingStringValue(vars.ComponentId, "Database", vars.Database);
|
||||
AppConfig.SetComponentSettingBooleanValue(vars.ComponentId, "NewDatabase", true);
|
||||
AppConfig.SetComponentSettingBooleanValue(vars.ComponentId, "NewDatabase", vars.CreateDatabase);
|
||||
//
|
||||
AppConfig.SetComponentSettingStringValue(vars.ComponentId, "DatabaseUser", vars.Database);
|
||||
AppConfig.SetComponentSettingBooleanValue(vars.ComponentId, "NewDatabaseUser", vars.NewDatabaseUser);
|
||||
|
@ -523,6 +506,7 @@ namespace WebsitePanel.Setup.Actions
|
|||
AppConfig.SetComponentSettingStringValue(vars.ComponentId, Global.Parameters.CryptoKey, vars.CryptoKey);
|
||||
//
|
||||
AppConfig.SaveConfiguration();
|
||||
Log.WriteEnd("SaveEntServerConfigSettingsAction");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,25 +38,27 @@ namespace WebsitePanel.Setup
|
|||
public sealed class AppConfig
|
||||
{
|
||||
public const string AppConfigFileNameWithoutExtension = "WebsitePanel.Installer.exe";
|
||||
|
||||
static AppConfig()
|
||||
{
|
||||
ConfigurationPath = DefaultConfigurationPath;
|
||||
}
|
||||
private AppConfig()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static Configuration appConfig = null;
|
||||
private static XmlDocument xmlConfig = null;
|
||||
|
||||
public static void LoadConfiguration()
|
||||
public static string ConfigurationPath { get; set; }
|
||||
public static string DefaultConfigurationPath { get { return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppConfigFileNameWithoutExtension); } }
|
||||
public static void LoadConfiguration(ExeConfigurationFileMap FnMap = null, ConfigurationUserLevel CuLevel = ConfigurationUserLevel.None)
|
||||
{
|
||||
//
|
||||
var exePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppConfigFileNameWithoutExtension);
|
||||
//
|
||||
appConfig = ConfigurationManager.OpenExeConfiguration(exePath);
|
||||
//
|
||||
if (FnMap == null)
|
||||
appConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationPath);
|
||||
else
|
||||
appConfig = ConfigurationManager.OpenMappedExeConfiguration(FnMap, CuLevel);
|
||||
ConfigurationSection section = appConfig.Sections["installer"];
|
||||
if (section == null)
|
||||
throw new ConfigurationErrorsException("instalelr section not found");
|
||||
|
||||
throw new ConfigurationErrorsException("installer section not found in " + appConfig.FilePath);
|
||||
string strXml = section.SectionInformation.GetRawXml();
|
||||
xmlConfig = new XmlDocument();
|
||||
xmlConfig.LoadXml(strXml);
|
||||
|
|
|
@ -48,9 +48,9 @@ namespace WebsitePanel.Setup
|
|||
/// <param name="bar">Progress bar.</param>
|
||||
/// <param name="source">Source folder.</param>
|
||||
/// <param name="destination">Destination folder.</param>
|
||||
public CopyProcess(ProgressBar bar, string source, string destination)
|
||||
public CopyProcess(object bar, string source, string destination)
|
||||
{
|
||||
this.progressBar = bar;
|
||||
this.progressBar = bar as ProgressBar;
|
||||
this.sourceFolder = new DirectoryInfo(source);
|
||||
this.destFolder = new DirectoryInfo(destination);
|
||||
}
|
||||
|
@ -63,9 +63,13 @@ namespace WebsitePanel.Setup
|
|||
// unzip
|
||||
long totalSize = FileUtils.CalculateFolderSize(sourceFolder.FullName);
|
||||
long copied = 0;
|
||||
progressBar.Minimum = 0;
|
||||
progressBar.Maximum = 100;
|
||||
progressBar.Value = 0;
|
||||
|
||||
if (progressBar != null)
|
||||
{
|
||||
progressBar.Minimum = 0;
|
||||
progressBar.Maximum = 100;
|
||||
progressBar.Value = 0;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
List<DirectoryInfo> folders = new List<DirectoryInfo>();
|
||||
|
@ -122,7 +126,10 @@ namespace WebsitePanel.Setup
|
|||
copied += files[i].Length;
|
||||
if (totalSize != 0)
|
||||
{
|
||||
progressBar.Value = Convert.ToInt32(copied * 100 / totalSize);
|
||||
if (progressBar != null)
|
||||
{
|
||||
progressBar.Value = Convert.ToInt32(copied * 100 / totalSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,5 +170,7 @@ namespace WebsitePanel.Setup
|
|||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static TraceListenerCollection Listeners { get { return Trace.Listeners; } }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -286,7 +286,8 @@ namespace WebsitePanel.Setup
|
|||
Windows7,
|
||||
WindowsServer2008R2,
|
||||
Windows8,
|
||||
WindowsServer2012
|
||||
WindowsServer2012,
|
||||
WindowsServer2012R2
|
||||
}
|
||||
|
||||
public static string GetName(WindowsVersion version)
|
||||
|
@ -428,6 +429,9 @@ namespace WebsitePanel.Setup
|
|||
else
|
||||
ret = WindowsVersion.WindowsServer2012;
|
||||
break;
|
||||
case 3:
|
||||
ret = WindowsVersion.WindowsServer2012R2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -338,8 +338,8 @@ namespace WebsitePanel.Setup
|
|||
/// <param name="domain"></param>
|
||||
/// <returns></returns>
|
||||
internal static string GetSid(string userAccount, string domain)
|
||||
{
|
||||
if(domain == null)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(domain))
|
||||
domain = Environment.MachineName;
|
||||
|
||||
// try to get user account
|
||||
|
|
|
@ -481,11 +481,11 @@ namespace WebsitePanel.Setup
|
|||
public static void StopService(string serviceName)
|
||||
{
|
||||
ServiceController sc = new ServiceController(serviceName);
|
||||
// Start the service if the current status is stopped.
|
||||
// Stop the service if the current status is not stopped.
|
||||
if (sc.Status != ServiceControllerStatus.Stopped &&
|
||||
sc.Status != ServiceControllerStatus.StopPending)
|
||||
{
|
||||
// Start the service, and wait until its status is "Running".
|
||||
// Stop the service, and wait until its status is "Running".
|
||||
sc.Stop();
|
||||
sc.WaitForStatus(ServiceControllerStatus.Stopped);
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ namespace WebsitePanel.Setup
|
|||
FileUtils.CreateDirectory(path);
|
||||
|
||||
SecurityUtils.GrantNtfsPermissions(path, userDomain, userAccount, NtfsPermission.Modify, true, true);
|
||||
SecurityUtils.GrantNtfsPermissionsBySid(path, SystemSID.NETWORK_SERVICE, NtfsPermission.Modify, true, true);
|
||||
SecurityUtils.GrantNtfsPermissionsBySid(path, SystemSID.NETWORK_SERVICE, NtfsPermission.Modify, true, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -46,9 +46,9 @@ namespace WebsitePanel.Setup.Common
|
|||
int totalFiles = 0;
|
||||
int files = 0;
|
||||
|
||||
public ZipIndicator(ProgressBar progressBar, string sourcePath, string zipFile)
|
||||
public ZipIndicator(object progressBar, string sourcePath, string zipFile)
|
||||
{
|
||||
this.progressBar = progressBar;
|
||||
this.progressBar = progressBar as ProgressBar;
|
||||
this.sourcePath = sourcePath;
|
||||
this.zipFile = zipFile;
|
||||
}
|
||||
|
@ -71,8 +71,11 @@ namespace WebsitePanel.Setup.Common
|
|||
{
|
||||
string fileName = e.CurrentEntry.FileName;
|
||||
files++;
|
||||
this.progressBar.Value = Convert.ToInt32(files * 100 / totalFiles);
|
||||
this.progressBar.Update();
|
||||
if (this.progressBar != null)
|
||||
{
|
||||
this.progressBar.Value = Convert.ToInt32(files * 100 / totalFiles);
|
||||
this.progressBar.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,6 +143,7 @@
|
|||
<Compile Include="Common\ZipIndicator.cs" />
|
||||
<Compile Include="EnterpriseServer10.cs" />
|
||||
<Compile Include="EnterpriseServer20.cs" />
|
||||
<Compile Include="Internal\Adapter.cs" />
|
||||
<Compile Include="Portal10.cs" />
|
||||
<Compile Include="Portal20.cs" />
|
||||
<Compile Include="Server10.cs" />
|
||||
|
|
|
@ -127,13 +127,13 @@ namespace WebsitePanel.Setup
|
|||
switch (check.CheckType)
|
||||
{
|
||||
case CheckTypes.OperationSystem:
|
||||
status = CheckOS(out details);
|
||||
status = CheckOS(check.SetupVariables, out details);
|
||||
break;
|
||||
case CheckTypes.IISVersion:
|
||||
status = CheckIISVersion(out details);
|
||||
status = CheckIISVersion(check.SetupVariables, out details);
|
||||
break;
|
||||
case CheckTypes.ASPNET:
|
||||
status = CheckASPNET(out details);
|
||||
status = CheckASPNET(check.SetupVariables, out details);
|
||||
break;
|
||||
case CheckTypes.WPServer:
|
||||
status = CheckWPServer(check.SetupVariables, out details);
|
||||
|
@ -221,7 +221,7 @@ namespace WebsitePanel.Setup
|
|||
|
||||
}
|
||||
|
||||
private CheckStatuses CheckOS(out string details)
|
||||
internal static CheckStatuses CheckOS(SetupVariables setupVariables, out string details)
|
||||
{
|
||||
details = string.Empty;
|
||||
try
|
||||
|
@ -237,6 +237,7 @@ namespace WebsitePanel.Setup
|
|||
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 ))
|
||||
|
@ -260,20 +261,20 @@ namespace WebsitePanel.Setup
|
|||
return CheckStatuses.Error;
|
||||
}
|
||||
}
|
||||
private CheckStatuses CheckIISVersion(out string details)
|
||||
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 &&
|
||||
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)
|
||||
if (setupVariables.IISVersion.Major < 6)
|
||||
{
|
||||
details = "IIS 6.0 or greater required.";
|
||||
Log.WriteError(string.Format("IIS check: {0}", details), null);
|
||||
|
@ -291,26 +292,26 @@ namespace WebsitePanel.Setup
|
|||
}
|
||||
}
|
||||
|
||||
private CheckStatuses CheckASPNET(out string details)
|
||||
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 (setupVariables.IISVersion.Major == 6)
|
||||
{
|
||||
//
|
||||
if (Utils.CheckAspNet40Registered(SetupVariables) == false)
|
||||
if (Utils.CheckAspNet40Registered(setupVariables) == false)
|
||||
{
|
||||
// Register ASP.NET 4.0
|
||||
Utils.RegisterAspNet40(SetupVariables);
|
||||
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)
|
||||
if (Utils.GetAspNetWebExtensionStatus_Iis6(setupVariables) == WebExtensionStatus.Prohibited)
|
||||
{
|
||||
Utils.EnableAspNetWebExtension_Iis6();
|
||||
}
|
||||
|
@ -331,10 +332,10 @@ namespace WebsitePanel.Setup
|
|||
return CheckStatuses.Error;
|
||||
}
|
||||
// Register ASP.NET 4.0
|
||||
if (Utils.CheckAspNet40Registered(SetupVariables) == false)
|
||||
if (Utils.CheckAspNet40Registered(setupVariables) == false)
|
||||
{
|
||||
// Register ASP.NET 4.0
|
||||
Utils.RegisterAspNet40(SetupVariables);
|
||||
Utils.RegisterAspNet40(setupVariables);
|
||||
//
|
||||
ret = CheckStatuses.Warning;
|
||||
details = AspNet40HasBeenInstalledMessage;
|
||||
|
@ -359,17 +360,17 @@ namespace WebsitePanel.Setup
|
|||
}
|
||||
}
|
||||
|
||||
private CheckStatuses CheckIIS32Mode(out string details)
|
||||
internal static CheckStatuses CheckIIS32Mode(SetupVariables setupVariables, out string details)
|
||||
{
|
||||
details = string.Empty;
|
||||
CheckStatuses ret = CheckIISVersion(out details);
|
||||
CheckStatuses ret = CheckIISVersion(setupVariables, out details);
|
||||
if (ret == CheckStatuses.Error)
|
||||
return ret;
|
||||
|
||||
try
|
||||
{
|
||||
//IIS 6
|
||||
if (SetupVariables.IISVersion.Major == 6)
|
||||
if (setupVariables.IISVersion.Major == 6)
|
||||
{
|
||||
//x64
|
||||
if (Utils.IsWin64())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue