Ejemplo n.º 1
0
        public async Task InstallAppRuntimeAsync(string pemFilePath, string ip, int port, string username, OsVersion osVersion, AppRuntimeVersion appRuntimeVersion)
        {
            try
            {
                await _feedbackChannel.SendFeedback($"- - - - Installing AppRuntimeVersion: {appRuntimeVersion} on Os: {osVersion} - - - -");

                _config.PemKey   = new PrivateKeyFile(pemFilePath);
                _config.Ip       = ip;
                _config.Port     = port;
                _config.Username = username;

                using (var client = _sshClient)
                {
                    client.Connect();

                    if (_scriptManager.GetScript(osVersion, appRuntimeVersion, out List <string> scriptLines))
                    {
                        foreach (var scriptLine in scriptLines)
                        {
                            await _feedbackChannel.SendFeedback($"$ {scriptLine}");

                            var output = await client.RunCommandAsync(scriptLine);

                            await _feedbackChannel.SendFeedback(output);
                        }

                        await _feedbackChannel.SendFeedback($"- - - - Finished installing AppRuntimeVersion: {appRuntimeVersion} on Os: {osVersion} - - - -");
                    }
                    else
                    {
                        await _feedbackChannel.SendFeedback($"{nameof(osVersion)} combined with {nameof(appRuntimeVersion)} is currently not a supported combination.");
                    }
                }
            }
            catch (Exception e)
            {
                await _feedbackChannel.SendFeedback($"- - - - Failed installing AppRuntimeVersion: {appRuntimeVersion} on Os: {osVersion}, with error: {e.Message} - - - - ");

                _logger.LogWarning(e.Message);
            }
        }