|
|
|
|
@ -70,6 +70,8 @@ type Config struct {
|
|
|
|
|
// Whether to clean scripts up
|
|
|
|
|
SkipClean bool `mapstructure:"skip_clean"`
|
|
|
|
|
|
|
|
|
|
ExpectDisconnect *bool `mapstructure:"expect_disconnect"`
|
|
|
|
|
|
|
|
|
|
startRetryTimeout time.Duration
|
|
|
|
|
ctx interpolate.Context
|
|
|
|
|
}
|
|
|
|
|
@ -101,6 +103,11 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
|
|
|
|
|
p.config.ExecuteCommand = "chmod +x {{.Path}}; {{.Vars}} {{.Path}}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if p.config.ExpectDisconnect == nil {
|
|
|
|
|
t := true
|
|
|
|
|
p.config.ExpectDisconnect = &t
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if p.config.Inline != nil && len(p.config.Inline) == 0 {
|
|
|
|
|
p.config.Inline = nil
|
|
|
|
|
}
|
|
|
|
|
@ -283,11 +290,18 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
|
|
|
|
cmd = &packer.RemoteCmd{Command: command}
|
|
|
|
|
return cmd.StartWithUi(comm, ui)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if cmd.ExitStatus != 0 {
|
|
|
|
|
// If the exit code indicates a remote disconnect, fail unless
|
|
|
|
|
// we were expecting it.
|
|
|
|
|
if cmd.ExitStatus == packer.CmdDisconnect {
|
|
|
|
|
if !*p.config.ExpectDisconnect {
|
|
|
|
|
return fmt.Errorf("Script disconnected unexpectedly.")
|
|
|
|
|
}
|
|
|
|
|
} else if cmd.ExitStatus != 0 {
|
|
|
|
|
return fmt.Errorf("Script exited with non-zero exit status: %d", cmd.ExitStatus)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|