Merge pull request #7833 from davidhao3300/david/sudo-scp
[Salt] Replace scp with scp + mv to handle non-root case
This commit is contained in:
commit
e229f75353
|
@ -399,9 +399,14 @@ func (p *Provisioner) uploadFile(ui packer.Ui, comm packer.Communicator, dst, sr
|
|||
}
|
||||
defer f.Close()
|
||||
|
||||
if err = comm.Upload(dst, f, nil); err != nil {
|
||||
_, temp_dst := filepath.Split(dst)
|
||||
|
||||
if err = comm.Upload(temp_dst, f, nil); err != nil {
|
||||
return fmt.Errorf("Error uploading %s: %s", src, err)
|
||||
}
|
||||
|
||||
p.moveFile(ui, comm, dst, temp_dst)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -468,14 +473,9 @@ func (p *Provisioner) removeDir(ui packer.Ui, comm packer.Communicator, dir stri
|
|||
}
|
||||
|
||||
func (p *Provisioner) uploadDir(ui packer.Ui, comm packer.Communicator, dst, src string, ignore []string) error {
|
||||
if err := p.createDir(ui, comm, dst); err != nil {
|
||||
_, temp_dst := filepath.Split(dst)
|
||||
if err := comm.UploadDir(temp_dst, src, ignore); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Make sure there is a trailing "/" so that the directory isn't
|
||||
// created on the other side.
|
||||
if src[len(src)-1] != '/' {
|
||||
src = src + "/"
|
||||
}
|
||||
return comm.UploadDir(dst, src, ignore)
|
||||
return p.moveFile(ui, comm, dst, temp_dst)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue