Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public virtual bool Execute()
        {
            var decryptedPassword = EncrytionHelper.Decrypt(SshPassword);
            var client            = new Renci.SshNet.SshClient(SshHost, SshLogin, decryptedPassword);

            client.Connect();

            var termkvp = new Dictionary <TerminalModes, uint>();

            termkvp.Add(TerminalModes.ECHO, 53);

            var shellStream = client.CreateShellStream("xterm", 80, 24, 800, 600, 1024, termkvp);

            if (IsRoot)
            {
                SwitchToRoot(decryptedPassword, shellStream);
            }

            WriteStream(Command, shellStream);
            var result = ReadStream(shellStream);

            _log.Information(result);

            _log.Success("Command Execute finished!");
            client.Disconnect();
            return(true);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            var decryptedPassword = EncrytionHelper.Decrypt(SftpPassword);
            var client            = new SshClient(SftpHost, SftpLogin, decryptedPassword);

            client.Connect();
            var termkvp = new Dictionary <TerminalModes, uint>();

            termkvp.Add(TerminalModes.ECHO, 53);

            _log.Information("Execute FolderBackupTask begin");
            var shellStream = client.CreateShellStream("xterm", 80, 24, 800, 600, 1024, termkvp);

            SwithToRoot(decryptedPassword, shellStream);
            var backupfolder = GetBackupFolderPath();

            WriteStream($"mkdir {backupfolder}", shellStream);
            var result = ReadStream(shellStream);

            _log.Information(result);

            WriteStream($"cp -r {FromPath}/* {backupfolder}", shellStream);
            result = ReadStream(shellStream);

            _log.Information(result);
            _log.Success("Execute FolderBackupTask finished!");

            client.Disconnect();
            return(true);
        }
Exemple #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            var httpClient = new HttpClient();
            var result = httpClient.GetAsync(BlockServiceUrl);
            result.Wait();

            if (!result.Result.IsSuccessStatusCode)
            {
                _log.Warning(result.Result?.Content?.ReadAsStringAsync().Result ?? "Empty content");
                _log.Error("Block service faulted");

                httpClient.Dispose();
                return false;
            }

            _log.Success(result.Result?.Content?.ReadAsStringAsync().Result ?? "Empty content");
            _log.Information("Waiting 3 seconds");
            httpClient.Dispose();

            Thread.Sleep(3000);
            _log.Information("Waiting 3 seconds finished");
            _log.Information("Block service finished");

            return true;
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public virtual bool Execute()
        {
            var decryptedPassword = EncrytionHelper.Decrypt(SshPassword);
            var client            = new SshClient(SshHost, SshLogin, decryptedPassword);

            client.Connect();

            var termkvp = new Dictionary <TerminalModes, uint>();

            termkvp.Add(TerminalModes.ECHO, 53);

            var shellStream = client.CreateShellStream("xterm", 80, 24, 800, 600, 1024, termkvp);

            SwitchToRoot(decryptedPassword, shellStream);
            WriteStream($"systemctl {GetCommandName()} {ServiceName} -l", shellStream);

            var result = ReadStream(shellStream);

            _log.Information(result);

            if (IsWaitStatusChange())
            {
                WaitStatusChange(shellStream);
            }

            _log.Success("Execute systemctl finished!");
            client.Disconnect();
            return(true);
        }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            var decryptedPassword = EncrytionHelper.Decrypt(SftpPassword);
            var sftpClient        = new SftpClient(SftpHost, SftpLogin, decryptedPassword);

            sftpClient.Connect();
            _log.Information("Files copy begin");

            _filesTotalSize  = GetTotalSize();
            _filesCopiedSize = _filesTotalSize;

            UploadDirectory(sftpClient, FromPath, ToPath);
            sftpClient.Disconnect();
            sftpClient.Dispose();

            _log.Success("Files copy success");
            return(true);
        }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            var httpClient = new HttpClient();
            var result     = httpClient.GetAsync(UnlockServiceUrl);

            result.Wait();

            if (!result.Result.IsSuccessStatusCode)
            {
                _log.Warning(result.Result?.Content?.ReadAsStringAsync().Result ?? "Empty content");
                _log.Error("Unlock service faulted");

                httpClient.Dispose();
                return(false);
            }

            _log.Success(result.Result?.Content?.ReadAsStringAsync().Result ?? "Empty content");
            _log.Information("Unlock service finished");

            httpClient.Dispose();
            return(true);
        }
Exemple #7
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public bool Execute()
 {
     _log.Success("Hello Task!");
     _log.Success($"My Name is: {Name}");
     return(true);
 }
Exemple #8
0
 /// <summary>
 ///
 /// </summary>
 private void ShowSuccess()
 {
     _log.Information(string.Empty);
     _log.Success("Publish success");
 }
Exemple #9
0
 /// <summary>
 ///
 /// </summary>
 private void ShowSuccess()
 {
     _log.Information(string.Empty);
     _log.Success("Cmd execute success");
 }