Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Option to disable login prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
rancher-sy-bot authored and niusmallnan committed Aug 22, 2018
1 parent 909859c commit 038bb6d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmd/control/console_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,34 @@ func generateRespawnConf(cmdline, user string, sshd, recovery bool) string {
autologinBin = "/usr/bin/recovery"
}

config := config.LoadConfig()

autoLogin := true
for _, d := range config.Rancher.Disable {
if d == "autologin" {
autoLogin = false
break
}
}

for i := 1; i < 7; i++ {
tty := fmt.Sprintf("tty%d", i)

respawnConf.WriteString(gettyCmd)
if strings.Contains(cmdline, fmt.Sprintf("rancher.autologin=%s", tty)) {
if autoLogin && strings.Contains(cmdline, fmt.Sprintf("rancher.autologin=%s", tty)) {
respawnConf.WriteString(fmt.Sprintf(" -n -l %s -o %s:tty%d", autologinBin, user, i))
}
respawnConf.WriteString(fmt.Sprintf(" --noclear %s linux\n", tty))
}

for _, tty := range []string{"ttyS0", "ttyS1", "ttyS2", "ttyS3", "ttyAMA0"} {
log.Infof("console.......... %s", cmdline)
if !strings.Contains(cmdline, fmt.Sprintf("console=%s", tty)) {
continue
}

respawnConf.WriteString(gettyCmd)
if strings.Contains(cmdline, fmt.Sprintf("rancher.autologin=%s", tty)) {
if autoLogin && strings.Contains(cmdline, fmt.Sprintf("rancher.autologin=%s", tty)) {
respawnConf.WriteString(fmt.Sprintf(" -n -l %s -o %s:%s", autologinBin, user, tty))
}
respawnConf.WriteString(fmt.Sprintf(" %s\n", tty))
Expand Down

0 comments on commit 038bb6d

Please sign in to comment.