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:
@@ -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)
|
||||
|
@@ -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]
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user