Port 7.7 - WIP
This commit is contained in:
@@ -48,6 +48,7 @@ namespace Umbraco.Web.Install
|
||||
new FilePermissionsStep(),
|
||||
new MajorVersion7UpgradeReport(_databaseBuilder, Current.RuntimeState, Current.DatabaseContext, Current.ScopeProvider),
|
||||
new Version73FileCleanup(_httpContext, _logger),
|
||||
new ConfigureMachineKey(),
|
||||
new DatabaseConfigureStep(_databaseBuilder),
|
||||
new DatabaseInstallStep(_databaseBuilder, Current.RuntimeState, Current.Logger),
|
||||
new DatabaseUpgradeStep(_databaseBuilder, Current.Services.MigrationEntryService, Current.RuntimeState, Current.MigrationCollectionBuilder, Current.Logger),
|
||||
|
||||
75
src/Umbraco.Web/Install/InstallSteps/ConfigureMachineKey.cs
Normal file
75
src/Umbraco.Web/Install/InstallSteps/ConfigureMachineKey.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Web.Configuration;
|
||||
using System.Xml.Linq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Web.Install.Models;
|
||||
|
||||
namespace Umbraco.Web.Install.InstallSteps
|
||||
{
|
||||
[InstallSetupStep(InstallationType.NewInstall,
|
||||
"ConfigureMachineKey", "machinekey", 2,
|
||||
"Updating some security settings...",
|
||||
PerformsAppRestart = true)]
|
||||
internal class ConfigureMachineKey : InstallSetupStep<bool?>
|
||||
{
|
||||
private readonly ApplicationContext _appContext;
|
||||
|
||||
public ConfigureMachineKey(ApplicationContext appContext)
|
||||
{
|
||||
if (appContext == null) throw new ArgumentNullException("appContext");
|
||||
_appContext = appContext;
|
||||
}
|
||||
|
||||
public override string View
|
||||
{
|
||||
get { return HasMachineKey() == false ? base.View : ""; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Don't display the view or execute if a machine key already exists
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool HasMachineKey()
|
||||
{
|
||||
var section = (MachineKeySection)WebConfigurationManager.GetSection("system.web/machineKey");
|
||||
return section.ElementInformation.Source != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The step execution method
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public override InstallSetupResult Execute(bool? model)
|
||||
{
|
||||
if (model.HasValue && model.Value == false) return null;
|
||||
|
||||
//install the machine key
|
||||
var fileName = IOHelper.MapPath(string.Format("{0}/web.config", SystemDirectories.Root));
|
||||
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
|
||||
|
||||
var systemWeb = xml.Root.DescendantsAndSelf("system.web").Single();
|
||||
|
||||
// Update appSetting if it exists, or else create a new appSetting for the given key and value
|
||||
var machineKey = systemWeb.Descendants("machineKey").FirstOrDefault();
|
||||
if (machineKey != null) return null;
|
||||
|
||||
var generator = new MachineKeyGenerator();
|
||||
var generatedSection = generator.GenerateConfigurationBlock();
|
||||
systemWeb.Add(XElement.Parse(generatedSection));
|
||||
|
||||
xml.Save(fileName, SaveOptions.DisableFormatting);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override bool RequiresExecution(bool? model)
|
||||
{
|
||||
return HasMachineKey() == false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Web.Install.Models;
|
||||
|
||||
namespace Umbraco.Web.Install.InstallSteps
|
||||
@@ -12,6 +13,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
internal class DatabaseConfigureStep : InstallSetupStep<DatabaseModel>
|
||||
{
|
||||
private readonly DatabaseBuilder _databaseBuilder;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public DatabaseConfigureStep(DatabaseBuilder databaseBuilder)
|
||||
{
|
||||
@@ -80,8 +82,9 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
result.DetermineInstalledVersion();
|
||||
return false;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error<DatabaseConfigureStep>("An error occurred, reconfiguring...", ex);
|
||||
//something went wrong, could not connect so probably need to reconfigure
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
_databaseBuilder = databaseBuilder;
|
||||
}
|
||||
|
||||
//TODO: Change all logic in this step to use ASP.NET Identity NOT MembershipProviders
|
||||
private MembershipProvider CurrentProvider
|
||||
{
|
||||
get
|
||||
|
||||
@@ -12,18 +12,21 @@ using Umbraco.Web.Security;
|
||||
namespace Umbraco.Web.Install.InstallSteps
|
||||
{
|
||||
[InstallSetupStep(InstallationType.NewInstall,
|
||||
"StarterKitDownload", "starterKit", 30, "Adding a simple website to Umbraco, will make it easier for you to get started")]
|
||||
"StarterKitDownload", "starterKit", 30, "Adding a simple website to Umbraco, will make it easier for you to get started",
|
||||
PerformsAppRestart = true)]
|
||||
internal class StarterKitDownloadStep : InstallSetupStep<Guid?>
|
||||
{
|
||||
private readonly InstallHelper _installHelper;
|
||||
private readonly IContentService _contentService;
|
||||
private readonly WebSecurity _security;
|
||||
private readonly HttpContextBase _httpContext;
|
||||
|
||||
public StarterKitDownloadStep(IContentService contentService, InstallHelper installHelper, WebSecurity security)
|
||||
{
|
||||
_installHelper = installHelper;
|
||||
_contentService = contentService;
|
||||
_security = security;
|
||||
_httpContext = httpContext;
|
||||
}
|
||||
|
||||
private const string RepoGuid = "65194810-1f85-11dd-bd0b-0800200c9a66";
|
||||
@@ -48,6 +51,8 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
|
||||
var result = DownloadPackageFiles(starterKitId.Value);
|
||||
|
||||
_applicationContext.RestartApplicationPool(_httpContext);
|
||||
|
||||
return new InstallSetupResult(new Dictionary<string, object>
|
||||
{
|
||||
{"manifestId", result.Item2},
|
||||
|
||||
Reference in New Issue
Block a user