1
0
mirror of https://github.com/rancher/os.git synced 2025-09-03 15:54:24 +00:00

get the kernel version for the banner

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
Sven Dowideit
2017-07-13 23:06:57 +10:00
parent 180fe241d8
commit d859052453
4 changed files with 22 additions and 7 deletions

View File

@@ -52,7 +52,7 @@ func autologinAction(c *cli.Context) error {
banner := config.Banner
banner = strings.Replace(banner, "\\v", config.Version, -1)
banner = strings.Replace(banner, "\\s", "RancherOS "+runtime.GOARCH, -1)
banner = strings.Replace(banner, "\\r", "4.9....", -1)
banner = strings.Replace(banner, "\\r", config.GetKernelVersion(), -1)
banner = strings.Replace(banner, "\\n", cfg.Hostname, -1)
banner = strings.Replace(banner, "\\l", tty, -1)
banner = strings.Replace(banner, "\\\\", "\\", -1)

View File

@@ -1,6 +1,9 @@
package config
import (
"io/ioutil"
"strings"
yaml "github.com/cloudfoundry-incubator/candiedyaml"
"github.com/rancher/os/util"
)
@@ -72,3 +75,12 @@ func Set(key string, value interface{}) error {
return WriteToFile(modified, CloudConfigFile)
}
func GetKernelVersion() string {
b, err := ioutil.ReadFile("/proc/version")
if err != nil {
return ""
}
elem := strings.Split(string(b), " ")
return elem[2]
}

View File

@@ -2,7 +2,6 @@ package docker
import (
"fmt"
"io/ioutil"
"strings"
composeConfig "github.com/docker/libcompose/config"
@@ -43,11 +42,9 @@ func environmentFromCloudConfig(cfg *config.CloudConfig) map[string]string {
environment["no_proxy"] = cfg.Rancher.Network.NoProxy
environment["NO_PROXY"] = cfg.Rancher.Network.NoProxy
}
b, err := ioutil.ReadFile("/proc/version")
if err == nil {
elem := strings.Split(string(b), " ")
environment["KERNEL_VERSION"] = elem[2]
log.Debugf("Using /proc/version to set rancher.environment.KERNEL_VERSION = %s", elem[2])
if v := config.GetKernelVersion(); v != "" {
environment["KERNEL_VERSION"] = v
log.Debugf("Using /proc/version to set rancher.environment.KERNEL_VERSION = %s", v)
}
return environment
}

View File

@@ -94,6 +94,12 @@ func sysInit(c *config.CloudConfig) (*config.CloudConfig, error) {
func MainInit() {
log.InitDeferedLogger()
defer func() {
if r := recover(); r != nil {
fmt.Printf("Starting Recovery console: %v\n", r)
recovery(nil)
}
}()
if err := RunInit(); err != nil {
log.Fatal(err)