Skip to content

Commit

Permalink
Allow chef to be installed in nonstandard location
Browse files Browse the repository at this point in the history
  • Loading branch information
mhedgpeth committed Mar 5, 2017
1 parent 06ac70d commit 0604f5c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/cafe/Chef/ChefInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/cafe/Server/Controllers/InspecController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static InspecJobRunner CreateJobRunner()
public static InstallJob CreateInstallJob(string product, FileSystem fileSystem, FileSystemCommandsBoundary commands, string prefix, Func<ProductInstallationMetaData, bool> 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);
}
Expand Down
1 change: 1 addition & 0 deletions src/cafe/ServerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion src/cafe/server.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"ChefInterval": 0,
"Port": 59320
"Port": 59320,
"InstallRoot": "C:"
}

0 comments on commit 0604f5c

Please sign in to comment.