提升ssh sudo安装的稳定性

This commit is contained in:
刘祥超
2022-11-18 15:44:53 +08:00
parent 2d94b994fa
commit 06b44dc101
4 changed files with 62 additions and 18 deletions

View File

@@ -165,7 +165,14 @@ func (this *SSHClient) Mkdir(path string) error {
}
func (this *SSHClient) MkdirAll(path string) error {
return this.sftp.MkdirAll(path)
err := this.sftp.MkdirAll(path)
if err != nil && this.sudo {
_, _, err2 := this.execSudo("mkdir -p "+path, this.sudoPassword)
if err2 == nil {
return nil
}
}
return err
}
func (this *SSHClient) Chmod(path string, mode os.FileMode) error {