public void RunLegacyUpdate() { _installer.Install(new Dictionary <string, string> { { Constants.XenToolsSetupExecutablePath, String.Format("/S /norestart /D={0}", Constants.XenToolsPath) } }); _serviceRestarter.Restart("xensvc"); if (_serviceRestarter.ServiceExists("XenServerVssProvider")) { _serviceRestarter.Restart("XenServerVssProvider"); } }
private static bool InstallOrUninstallWithElevationContext(IEnumerable <ComponentHandle <IInstaller, InstallerTraits> > installerHandles, IElevationContext elevationContext, IProgressMonitor progressMonitor, InstallerOperation operation) { foreach (var installerHandle in installerHandles) { if (progressMonitor.IsCanceled) { return(false); } IProgressMonitor subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1); if (elevationContext != null && installerHandle.GetTraits().RequiresElevation) { elevationContext.Execute(InstallerElevatedCommand.ElevatedCommandId, new InstallerElevatedCommand.Arguments(installerHandle.Id, operation), subProgressMonitor); } else { IInstaller installer = installerHandle.GetComponent(); if (operation == InstallerOperation.Install) { installer.Install(progressMonitor.CreateSubProgressMonitor(1)); } else { installer.Uninstall(progressMonitor.CreateSubProgressMonitor(1)); } } } return(true); }
public async Task StartGame() { var currentProfile = _profileManager.GetLast(); await _installer.Install(currentProfile); _launchMinecraft(currentProfile); }
private void btn_Install_Click(object sender, EventArgs e) { Action resetInstallBtn = () => { btn_Install.Text = Localization.Install; btn_Install.Enabled = true; _installCts.Dispose(); }; if (btn_Install.Text == Localization.Install) { _installCts = new CancellationTokenSource(); btn_Install.Text = Localization.Cancel; _installTask = Task.Factory.StartNew(() => _install.Install(_installCts.Token)); _installTask.ContinueWith(task => { if (btn_Install.InvokeRequired) { btn_Install.Invoke(resetInstallBtn); } else { resetInstallBtn(); } }); } else { btn_Install.Text = Localization.CancelingWait; btn_Install.Enabled = false; _installCts.Cancel(); } }
/// <summary> /// Runs an installer, adding the installer's handlers to the disclose. /// </summary> /// <param name="installer"></param> public void Install(IInstaller installer) { if (installer == null) { throw new ArgumentNullException(nameof(installer)); } installer.Install(this); }
public string Install() { if (_installer.IsPartiallyInstalled) { _installer.Uninstall(); } if (_installer.IsInstalled == false) { return(_installer.Install()); } return(null); }
private async Task Run() { var isConnected = await _downloader.Connect(); if (!isConnected) { _logger.Log("Could not connect to remote host!"); return; } _logger.Log("Checking for update..."); var hasUpdate = _downloader.HasUpdate(_installProvider.Current.IdLatestBuild); if (!hasUpdate) { _logger.Log("No new version found!"); } else { _logger.Log("New version found!"); _logger.Log($"Download starting..."); var response = await _downloader.Download(OnProgress); if (response.Success && !string.IsNullOrEmpty(response.PathDownload)) { _logger.Log($"\nDownload Complete!"); var src = response.PathDownload; var dst = _settingsProvider.Current.DirectoryData; var tmp = _settingsProvider.Current.DirectoryTmp; _logger.Log("Installing..."); if (_installer.Install(src, dst, tmp)) { _installProvider.Current.IdLatestBuild = response.File.Id; _installProvider.Current.NameLatestBuild = response.File.Title; _installProvider.Save(); _logger.Log("Installation complete!"); } else { _logger.Log("Installation failed!"); } } else { _logger.Log($"\nDownload failed!"); } } _logger.Log("Press any key to exit..."); Console.Read(); }
public void should_execute_the_commands_passed_in() { logger.Stub(x => x.Log(Arg <string> .Is.Anything)); exec.Expect(x => x.Enqueue(Arg <string> .Is.Anything, Arg <string> .Is.Anything)) .Return(exec); exec.Expect(x => x.Go()).Repeat.Once(); installer.Install(new Dictionary <string, string> { { Constants.XenToolsUnzipPath, "/S /norestart /D=" + Constants.XenToolsPath } }); exec.AssertWasCalled(x => x.Enqueue(Constants.XenToolsUnzipPath, "/S /norestart /D=" + Constants.XenToolsPath)); }
protected override void ProcessRecord() { base.ProcessRecord(); var logger = new CommandLogger(this); var context = new InstallerContext(Parameters, logger); IInstaller installer = InstallerFactory.Create(); try { installer.Install(context); } catch (Exception exception) { logger.Error(exception); } }
public ExecutableResult Execute(string value) { try { Statics.ShouldPollXenStore = false; _logger.Log(String.Format("XenTools Update value: {0}\r\nWill resume in 60 seconds", value)); _sleeper.Sleep(60); var agentUpdateInfo = _agentUpdateMessageHandler.Handle(value); _downloader.Download(agentUpdateInfo.url, Constants.XenToolsReleasePackage); _checksumValidator.Validate(agentUpdateInfo.signature, Constants.XenToolsReleasePackage); _unzipper.Unzip(Constants.XenToolsReleasePackage, Constants.XenToolsUnzipPath, ""); _installer.Install(new Dictionary <string, string> { { Constants.XenToolsSetupExecutablePath, String.Format("/S /norestart /D={0}", Constants.XenToolsPath) } }); _serviceRestarter.Restart("xensvc"); if (_serviceRestarter.ServiceExists("XenServerVssProvider")) { _serviceRestarter.Restart("XenServerVssProvider"); } return(new ExecutableResult()); } catch (Exception ex) { _logger.Log(String.Format("Exception was : {0}\nStackTrace Was: {1}", ex.Message, ex.StackTrace)); return(new ExecutableResult { Error = new List <string> { "Update failed" }, ExitCode = "1" }); } finally { Statics.ShouldPollXenStore = true; _finalizer.Finalize(new List <string> { Constants.XenToolsUnzipPath, Constants.XenToolsReleasePackage }); } }
/// <summary> /// Installs the contents of the archive specified by<paramref name="downloadedFileName"/> /// according to the detected platform. /// </summary> /// <param name="downloadedFileName">The downloaded application files to install.</param> /// <param name="versionTag">The version tag corresponding to the selected release or /// the provided update zip file.</param> private async Task InstallOnPlatform(string downloadedFileName, string versionTag) { // Set the progress bar to "indeterminate" Dispatcher.UIThread.Post(() => { this.DownloadPercentage = 0; this.IsProgressIndeterminate = true; }); // Write the installation path to the config file so that // we can locate the installation later Log.Information($"Writing installation path to config file: \"{this.InstallationPath}\""); PathConf.ClientInstallPath = this.InstallationPath; // Check if client is running and kill it if necessary Log.Information($"Checking if client is running"); // On macOS, process names are truncated to 15 chararcters, // so we cannot match the full process name var procName = Path.GetFileNameWithoutExtension(_installer.GetClientExePath(this.InstallationPath)) .Substring(0, 15); Process[] processes = Process.GetProcesses() .Where(x => x.ProcessName.StartsWith(procName)).ToArray(); if (processes.Length > 0) { var clientProcess = processes[0]; Log.Warning($"Client is running, trying to kill it"); clientProcess.Kill(); // Since the below call to "WaitForExit()" could potentially block // forever if killing the client fails for some reason, we better // give an indication of what's going on in the UI and hopefully have the // user help out closing the client if our programmatic approach fails. Dispatcher.UIThread.Post(() => this.InstallStatus = _loc.GetLocalizationValue("InstallStatusWaitingForClientExit")); await Task.Run(() => clientProcess.WaitForExit()); Log.Information($"Client exited, continuing"); } else { Log.Information($"Client not running, continuing"); } // Set status "installing" in UI Dispatcher.UIThread.Post(() => this.InstallStatus = _loc.GetLocalizationValue("InstallStatusInstalling")); // Perform the actual installation Log.Information($"Launching installation"); try { await _installer.Install(downloadedFileName, this.InstallationPath, versionTag); } catch (Exception ex) { Log.Error($"Error during installation:\r\n{ex}"); SetErrorStatus(); return; } ((MainWindowViewModel)_mainWindow.DataContext).Content = new InstallationCompleteViewModel(_installer.GetClientExePath(this.InstallationPath)); }
public void Install() { _installer.Install(); }