provisioner/shell: close source script file handle

This commit is contained in:
Mitchell Hashimoto 2013-07-07 20:50:53 -07:00
parent 3e8678f76d
commit 1745d4e831
1 changed files with 4 additions and 0 deletions

View File

@ -165,6 +165,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
if err != nil {
return fmt.Errorf("Error opening shell script: %s", err)
}
defer f.Close()
log.Printf("Uploading %s => %s", path, p.config.RemotePath)
err = comm.Upload(p.config.RemotePath, f)
@ -172,6 +173,9 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
return fmt.Errorf("Error uploading shell script: %s", err)
}
// Close the original file since we copied it
f.Close()
// Flatten the environment variables
flattendVars := strings.Join(p.config.Vars, " ")