1
0
mirror of https://github.com/rancher/os.git synced 2025-09-04 16:21:07 +00:00

make centos/fedora consoles work by just starting bash

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>

WIP - dont merge

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
Sven Dowideit
2017-07-14 13:15:43 +10:00
parent d859052453
commit d9d3c2b0d8
4 changed files with 35 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ import (
"os/exec"
"runtime"
"strings"
"syscall"
"github.com/codegangsta/cli"
"github.com/rancher/os/config"
@@ -59,12 +60,36 @@ func autologinAction(c *cli.Context) error {
banner = banner + "\n"
fmt.Printf(banner)
cmd = exec.Command("/usr/bin/login", "-f", user)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
cmd.Stdin = os.Stdin
if err := cmd.Run(); err != nil {
log.Error(err)
loginBin := ""
args := []string{}
if cfg.Rancher.Console == "Acentos" || cfg.Rancher.Console == "Afedora" {
// For some reason, centos and fedora ttyS0 and tty1 don't work with `login -f rancher`
// until I make time to read their source, lets just give us a way to get work done
loginBin = "bash"
args = append(args, "--login")
} else {
loginBin = "login"
args = append(args, "-f", user)
}
return nil
loginBinPath, err := exec.LookPath(loginBin)
if err != nil {
fmt.Printf("error finding %s in path: %s", cmd.Args[0], err)
return err
}
os.Setenv("PS1", `[`+cfg.Rancher.Console+`: \l \u@\h \W]\$`)
return syscall.Exec(loginBinPath, args, os.Environ())
// cmd = exec.Command(loginBinPath, args...)
// cmd.Env = os.Environ()
// cmd.Stderr = os.Stderr
// cmd.Stdout = os.Stdout
// cmd.Stdin = os.Stdin
// if err := cmd.Run(); err != nil {
// log.Errorf("\nError starting %s: %s", cmd.Args[0], err)
// }
// return nil
}

View File

@@ -15,6 +15,7 @@ func recoveryInitAction(c *cli.Context) error {
}
os.Setenv("TERM", "linux")
os.Setenv("PS1", `[Recovery Console: \l \u@\h \W]\$`)
respawnBinPath, err := exec.LookPath("respawn")
if err != nil {

View File

@@ -171,7 +171,7 @@ if [ "$APPEND_INIT" != "" ]; then
fi
if [ "$BOOT_PXE" == "1" ]; then
KERNEL_ARGS="console=tty1 rancher.console=tty1 rancher.autologin=tty1 ${KERNEL_ARGS}"
KERNEL_ARGS="console=tty1 rancher.autologin=tty1 ${KERNEL_ARGS}"
set -ex
PIXIECORE=$(which pixiecore)
sudo -E $PIXIECORE boot \

View File

@@ -52,4 +52,4 @@ if [ "$ENGINE_REGISTRY_MIRROR" != "" ]; then
REGISTRY_MIRROR="rancher.bootstrap_docker.registry_mirror=${ENGINE_REGISTRY_MIRROR} rancher.system_docker.registry_mirror=${ENGINE_REGISTRY_MIRROR} rancher.docker.registry_mirror=${ENGINE_REGISTRY_MIRROR}"
fi
DEFAULT_KERNEL_ARGS="printk.devkmsg=on rancher.debug=true rancher.password=rancher console=${TTYCONS} rancher.autologin=${TTYCONS} ${REGISTRY_MIRROR} "
DEFAULT_KERNEL_ARGS="printk.devkmsg=on rancher.debug=true rancher.password=rancher console=tty1 rancher.autologin=tty1 console=${TTYCONS} rancher.autologin=${TTYCONS} ${REGISTRY_MIRROR} "