|
|
|
|
@ -25,6 +25,9 @@ type config struct {
|
|
|
|
|
// in the context of a single shell.
|
|
|
|
|
Inline []string
|
|
|
|
|
|
|
|
|
|
// The shebang value used when running inline scripts.
|
|
|
|
|
InlineShebang string `mapstructure:"inline_shebang"`
|
|
|
|
|
|
|
|
|
|
// The local path of the shell script to upload and execute.
|
|
|
|
|
Script string
|
|
|
|
|
|
|
|
|
|
@ -69,6 +72,10 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
|
|
|
|
|
p.config.Inline = nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if p.config.InlineShebang == "" {
|
|
|
|
|
p.config.InlineShebang = "/bin/sh"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if p.config.RemotePath == "" {
|
|
|
|
|
p.config.RemotePath = DefaultRemotePath
|
|
|
|
|
}
|
|
|
|
|
@ -136,6 +143,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
|
|
|
|
|
|
|
|
|
// Write our contents to it
|
|
|
|
|
writer := bufio.NewWriter(tf)
|
|
|
|
|
writer.WriteString(fmt.Sprintf("#!%s\n", p.config.InlineShebang))
|
|
|
|
|
for _, command := range p.config.Inline {
|
|
|
|
|
if _, err := writer.WriteString(command + "\n"); err != nil {
|
|
|
|
|
return fmt.Errorf("Error preparing shell script: %s", err)
|
|
|
|
|
|