Skip to content

Commit d14539a

Browse files
authored
Merge pull request #167 from thedadams/more-rancher-cert-fixes
More rancher cert fixes
2 parents 2daf6c8 + 732693f commit d14539a

3 files changed

Lines changed: 19 additions & 13 deletions

File tree

commands/create.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
541541
func 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

package/download_driver.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
driver_prefix=docker-machine-driver-
44

5+
if [ -n "${SSL_CERT_DIR}" ]; then
6+
ln -s /etc/ssl/certs/* "${SSL_CERT_DIR}"
7+
fi
8+
9+
if [ -x "$(command -v c_rehash)" ]; then
10+
# c_rehash is run here instead of update-ca-certificates because the latter requires root privileges
11+
# and the rancher-machine container is run as non-root user.
12+
c_rehash
13+
fi
14+
515
curl -sLO "$1"
616
driver_file=$(ls $driver_prefix*)
717
driver_name=$(echo "$driver_file" | sed -e "s/^$driver_prefix//" -e "s/[-_\.].*$//")
@@ -39,4 +49,4 @@ fi
3949

4050
chmod +x $driver_path
4151
mv $driver_path /usr/local/bin/$driver_prefix$driver_name
42-
rm -rf driver_dir $driver_file $driver_path
52+
rm -rf driver_dir $driver_file $driver_path

package/entrypoint.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
set -e
33
termination_log="/dev/termination-log"
44

5-
if [ -x "$(command -v c_rehash)" ]; then
6-
# c_rehash is run here instead of update-ca-certificates because the latter requires root privileges
7-
# and the rancher-machine container is run as non-root user.
8-
c_rehash
9-
fi
10-
115
for i; do
126
shift
137
case $i in
@@ -42,4 +36,4 @@ if [ -n "$driver_url" ]; then
4236
fi
4337
fi
4438

45-
{ { { { rancher-machine "$@" 2>&1; echo $? >&3; } | tee -a $termination_log >&4; } 3>&1; } | { read xs; exit $xs; } } 4>&1
39+
{ { { { rancher-machine "$@" 2>&1; echo $? >&3; } | tee -a $termination_log >&4; } 3>&1; } | { read xs; exit $xs; } } 4>&1

0 commit comments

Comments
 (0)