Example #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);
        }
Example #2
0
        /// <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);
        }
Example #3
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);
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SftpCopyTaskEditor_OnLoaded(object sender, RoutedEventArgs e)
        {
            ViewModel = GetTaskData <SystemctlTaskEditorModel>() ?? new SystemctlTaskEditorModel();

            HostsCombobox.Text   = ViewModel.SshHost;
            LoginsCombobox.Text  = ViewModel.SshLogin;
            PasswordBox.Password = EncrytionHelper.Decrypt(ViewModel.SshPassword);
            ServiceTextBox.Text  = ViewModel.ServiceName;

            var hosts = HostDataManager.GetHostsInfos().Select(s => s.Host).ToList();

            hosts.ForEach(f => HostsCombobox.Items.Add(f));

            HostsCombobox.SelectionChanged  += Hosts_OnSelectionChanged;
            LoginsCombobox.SelectionChanged += Logins_OnSelectionChanged;
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static List <HostInfo> GetHostsInfos()
        {
            if (!File.Exists(HostsFile))
            {
                return(new List <HostInfo>());
            }

            var encryptedJson = File.ReadAllText(HostsFile);

            if (string.IsNullOrEmpty(encryptedJson))
            {
                return(new List <HostInfo>());
            }

            var json = EncrytionHelper.Decrypt(encryptedJson);

            return(JsonConvert.DeserializeObject <List <HostInfo> >(json));
        }
Example #6
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);
        }
Example #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SftpCopyTaskEditor_OnLoaded(object sender, RoutedEventArgs e)
 {
     ViewModel            = GetTaskData <SftpFolderBackupTaskEditorModel>() ?? new SftpFolderBackupTaskEditorModel();
     DataContext          = ViewModel;
     PasswordBox.Password = EncrytionHelper.Decrypt(ViewModel.SftpPassword);
 }