Documentation ¶
Index ¶
- Constants
- func CRLF2LF(file string) error
- func ExecShell(ctx context.Context, servers []*RemoteServerInfo, fileParams *FileParams, ...)
- func GenMd5File(file string) (string, error)
- func Md5Sum(file string) (string, error)
- type FileParams
- type RemoteServerInfo
- type Result
- type SSHClient
- func (s *SSHClient) Close() error
- func (s *SSHClient) CloseSftp() error
- func (s *SSHClient) CreateSftp() error
- func (s *SSHClient) Exec(ctx context.Context, cmd string, result *Result)
- func (s *SSHClient) Execs(ctx context.Context, cmds []string, result *Result)
- func (s *SSHClient) SendContent(ctx context.Context, filename string, content []byte, remoteDir string) error
- func (s *SSHClient) SendFile(ctx context.Context, localFile string, remoteDir string) error
Constants ¶
View Source
const ( // ExecSuccess 执行成功标记字符 ExecSuccess = "successful execution, exit 0\n" // Separator 分隔符号 Separator = "\n\n" )
Variables ¶
This section is empty.
Functions ¶
func ExecShell ¶
func ExecShell(ctx context.Context, servers []*RemoteServerInfo, fileParams *FileParams, outMsg chan string)
ExecShell 在远程服务器执行shell脚本,支持多个服务器
func GenMd5File ¶
GenMd5File 在相同目录下生成标准md5文件,文件名:原文件名.md5
Types ¶
type FileParams ¶
type FileParams struct { // 本地文件参数 ShellFile string `json:"shellFile"` // 脚本文件,执行程序入口 CompressedFile string `json:"compressedFile"` // zip或tar.gz压缩文件 // 目标服务器路径 UploadPath string `json:"uploadPath"` // 上传文件到目标服务器的文件路径,默认路径为/tmp/upload }
FileParams 文件参数
type RemoteServerInfo ¶
RemoteServerInfo 远程服务器信息
func (*RemoteServerInfo) CheckConnect ¶
func (r *RemoteServerInfo) CheckConnect() error
CheckConnect 检查是否可以连接到远程服务器
func (*RemoteServerInfo) String ¶
func (r *RemoteServerInfo) String() string
type SSHClient ¶
type SSHClient struct {
// contains filtered or unexported fields
}
SSHClient 远程服务器信息
func NewKeySSHClient ¶
NewKeySSHClient 连接远程服务器,key方式
func NewPwdSSHClient ¶
NewPwdSSHClient 连接远程服务器,密码方式
Click to show internal directories.
Click to hide internal directories.