@@ -539,20 +539,22 @@ func updateUserdataFile(driverOpts *rpcdriver.RPCFlags, machineName, userdataFla
539539// writeCloudConfig sets custom install script path to the runcmd directive
540540// and passes the script path to commonCloudConfig
541541func writeCloudConfig (machineName , encodedData , machineOS string , cf map [interface {}]interface {}, newUserDataFile * os.File ) error {
542- command := "sh /usr/local/custom_script/install.sh"
542+ command := "sh"
543+ path := "/usr/local/custom_script/install.sh"
543544 if strings .Contains (machineOS , "windows" ) {
544545 // the writeFile path should ideally be C:\usr\local\custom_script\install.ps1
545546 // but we can't guarantee that directory exists or can be created on the target machine
546- command = "powershell C:\\ install.ps1"
547+ command = "powershell"
548+ path = "C:\\ install.ps1"
547549 }
548- return commonCloudConfig (machineName , machineOS , encodedData , command , cf , newUserDataFile )
550+ return commonCloudConfig (machineName , machineOS , encodedData , command , path , cf , newUserDataFile )
549551}
550552
551553// commonCloudConfig contains the shared cloud-config logic for writeCloudConfig
552554// it adds content to the write_files directive of the cloud-config file as well as sets the hostname
553555// the content added is based on the OS passed with a hard default to linux
554556// windows is the only other supported OS
555- func commonCloudConfig (machineName , machineOS , encodedData , command string , cf map [interface {}]interface {}, newUserDataFile * os.File ) error {
557+ func commonCloudConfig (machineName , machineOS , encodedData , command , path string , cf map [interface {}]interface {}, newUserDataFile * os.File ) error {
556558 writeFile := map [string ]string {
557559 "encoding" : "gzip+b64" ,
558560 "content" : fmt .Sprintf ("%s" , encodedData ),
@@ -564,7 +566,7 @@ func commonCloudConfig(machineName, machineOS, encodedData, command string, cf m
564566 }
565567
566568 // Add to the runcmd directive
567- if err := addToCloudConfig (cf , "runcmd" , fmt .Sprintf ("%s" , writeFile ["path" ])); err != nil {
569+ if err := addToCloudConfig (cf , "runcmd" , fmt .Sprintf ("%s %s" , command , writeFile ["path" ])); err != nil {
568570 return err
569571 }
570572
0 commit comments