From 0604f5ccbfe53fd0368443ce4a50df30d8e8bb9b Mon Sep 17 00:00:00 2001 From: Michael Hedgpeth Date: Sat, 4 Mar 2017 18:21:11 -0600 Subject: [PATCH] Allow chef to be installed in nonstandard location --- src/cafe/Chef/ChefInstaller.cs | 6 ++++-- src/cafe/Server/Controllers/InspecController.cs | 2 +- src/cafe/ServerSettings.cs | 1 + src/cafe/server.json | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cafe/Chef/ChefInstaller.cs b/src/cafe/Chef/ChefInstaller.cs index 1edbaa4..4efa77a 100644 --- a/src/cafe/Chef/ChefInstaller.cs +++ b/src/cafe/Chef/ChefInstaller.cs @@ -18,14 +18,16 @@ public class ProductInstaller : IProductInstaller private readonly IFileSystem _fileSystem; private readonly IFileSystemCommands _commands; private readonly string _prefix; + private readonly string _installLocation; private readonly ProcessExecutor _processExecutor; - public ProductInstaller(IFileSystem fileSystem, ProcessExecutor processExecutor, IFileSystemCommands commands, string prefix) + public ProductInstaller(IFileSystem fileSystem, ProcessExecutor processExecutor, IFileSystemCommands commands, string prefix, string installLocation) { _fileSystem = fileSystem; _processExecutor = processExecutor; _commands = commands; _prefix = prefix; + _installLocation = installLocation; } public Result Uninstall(string productCode) @@ -47,7 +49,7 @@ public Result Install(string version) } Logger.Debug($"Installing installer {fullPathToStagedInstaller}"); var msiexec = FindFullPathToMsiExec(); - var result = _processExecutor.ExecuteAndWaitForExit(msiexec, $"/qn /L*V \"logs/installation.log\" /i \"{fullPathToStagedInstaller}\"", + var result = _processExecutor.ExecuteAndWaitForExit(msiexec, $"/qn /L*V \"logs/installation.log\" /i \"{fullPathToStagedInstaller}\" INSTALLLOCATION={_installLocation}", LogInformation, LogError); Logger.Debug($"Result of installing {fullPathToStagedInstaller} is {result}"); return result; diff --git a/src/cafe/Server/Controllers/InspecController.cs b/src/cafe/Server/Controllers/InspecController.cs index 0186422..7896d05 100644 --- a/src/cafe/Server/Controllers/InspecController.cs +++ b/src/cafe/Server/Controllers/InspecController.cs @@ -30,7 +30,7 @@ public static InspecJobRunner CreateJobRunner() public static InstallJob CreateInstallJob(string product, FileSystem fileSystem, FileSystemCommandsBoundary commands, string prefix, Func productMatcher) { var chefProduct = new ChefProduct(product, new InstalledProductsFinder(), - new ProductInstaller(fileSystem, new ProcessExecutor(() => new ProcessBoundary()), commands, prefix), + new ProductInstaller(fileSystem, new ProcessExecutor(() => new ProcessBoundary()), commands, prefix, $@"{ServerSettings.Instance.InstallRoot}\opscode"), productMatcher); return new InstallJob(chefProduct, SystemClock.Instance); } diff --git a/src/cafe/ServerSettings.cs b/src/cafe/ServerSettings.cs index 0bd2c2a..d336820 100644 --- a/src/cafe/ServerSettings.cs +++ b/src/cafe/ServerSettings.cs @@ -4,6 +4,7 @@ public class ServerSettings { public int ChefInterval { get; set; } public int Port { get; set; } = DefaultPort; + public string InstallRoot { get; set; } = @"C:"; public const int DefaultPort = 59320; diff --git a/src/cafe/server.json b/src/cafe/server.json index 6a3a7ee..5cbb076 100644 --- a/src/cafe/server.json +++ b/src/cafe/server.json @@ -1,4 +1,5 @@ { "ChefInterval": 0, - "Port": 59320 + "Port": 59320, + "InstallRoot": "C:" } \ No newline at end of file