feature(devlop): support ssh cmd

This commit is contained in:
cuisongliu
2020-03-24 15:32:34 +08:00
parent d432e889b7
commit ecc731cb10
5 changed files with 6 additions and 7 deletions
+1 -2
View File
@@ -3,8 +3,7 @@ module github.com/fanux/sealos
go 1.13
require (
github.com/cuisongliu/sshcmd v0.0.0-20200324053034-6eac7d989bb2
github.com/cuisongliu/sshcmd v0.0.0-20200324072846-4d443aa0f947
github.com/fanux/sealgate v0.0.5
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.8.1
+2 -2
View File
@@ -30,8 +30,8 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cuisongliu/sshcmd v0.0.0-20200324053034-6eac7d989bb2 h1:MlEAdBvNN0raPJqyCch42HeBYp3QpasiC2KDWG5IJas=
github.com/cuisongliu/sshcmd v0.0.0-20200324053034-6eac7d989bb2/go.mod h1:jAEBZhFW5kNey9B+59lR8mfQaCQsyp8b8QaI7RhESxE=
github.com/cuisongliu/sshcmd v0.0.0-20200324072846-4d443aa0f947 h1:EPJlLNly+MjWGMDADOHQllYYlmp6A6xx7SW9j6Rc+Xk=
github.com/cuisongliu/sshcmd v0.0.0-20200324072846-4d443aa0f947/go.mod h1:jAEBZhFW5kNey9B+59lR8mfQaCQsyp8b8QaI7RhESxE=
github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+1 -1
View File
@@ -34,7 +34,7 @@ func (ss *SSH) CopyForMD5(host, localFilePath, remoteFilePath, md5 string) bool
}
func (ss *SSH) Md5Sum(host, remoteFilePath string) string {
cmd := fmt.Sprintf("md5sum %s | cut -d\" \" -f1", remoteFilePath)
remoteMD5 := ss.CmdToString(host, cmd)
remoteMD5 := ss.CmdToString(host, cmd, "")
return remoteMD5
}
+1 -1
View File
@@ -19,7 +19,7 @@ func (ss *SSH) LoggerFileSize(host, filename string, size int) {
for {
select {
case <-t.C:
length := ss.CmdToString(host, "ls -l "+filename+" | awk '{print $5}'")
length := ss.CmdToString(host, "ls -l "+filename+" | awk '{print $5}'", "")
length = strings.Replace(length, "\n", "", -1)
length = strings.Replace(length, "\r", "", -1)
lengthByte, _ := strconv.Atoi(length)
+1 -1
View File
@@ -10,7 +10,7 @@ github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests
github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses
github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils
github.com/aliyun/alibaba-cloud-sdk-go/services/ecs
# github.com/cuisongliu/sshcmd v0.0.0-20200324053034-6eac7d989bb2
# github.com/cuisongliu/sshcmd v0.0.0-20200324072846-4d443aa0f947
github.com/cuisongliu/sshcmd/pkg/filesize
github.com/cuisongliu/sshcmd/pkg/md5sum
github.com/cuisongliu/sshcmd/pkg/sshutil