1
0
mirror of https://github.com/rancher/os.git synced 2025-07-03 10:06:13 +00:00

Option to disable login prompt

This commit is contained in:
Jason-ZW 2018-08-21 11:39:51 +08:00 committed by niusmallnan
parent 909859c1f6
commit 038bb6d89b

View File

@ -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))