1
0
mirror of https://github.com/rancher/os.git synced 2025-08-31 14:23:11 +00:00

Only set rancher password if non-empty

This commit is contained in:
Josh Curl
2016-12-08 15:22:43 -08:00
parent f1f41dffa2
commit 328bd5bd2e

View File

@@ -52,15 +52,17 @@ func consoleInitAction(c *cli.Context) error {
}
password := config.GetCmdline("rancher.password")
cmd := exec.Command("chpasswd")
cmd.Stdin = strings.NewReader(fmt.Sprint("rancher:", password))
if err := cmd.Run(); err != nil {
log.Error(err)
}
if password != "" {
cmd := exec.Command("chpasswd")
cmd.Stdin = strings.NewReader(fmt.Sprint("rancher:", password))
if err := cmd.Run(); err != nil {
log.Error(err)
}
cmd = exec.Command("bash", "-c", `sed -E -i 's/(rancher:.*:).*(:.*:.*:.*:.*:.*:.*)$/\1\2/' /etc/shadow`)
if err := cmd.Run(); err != nil {
log.Error(err)
cmd = exec.Command("bash", "-c", `sed -E -i 's/(rancher:.*:).*(:.*:.*:.*:.*:.*:.*)$/\1\2/' /etc/shadow`)
if err := cmd.Run(); err != nil {
log.Error(err)
}
}
if err := setupSSH(cfg); err != nil {
@@ -92,7 +94,7 @@ func consoleInitAction(c *cli.Context) error {
}
}
cmd = exec.Command("bash", "-c", `echo 'RancherOS \n \l' > /etc/issue`)
cmd := exec.Command("bash", "-c", `echo 'RancherOS \n \l' > /etc/issue`)
if err := cmd.Run(); err != nil {
log.Error(err)
}