mirror of
https://github.com/rancher/os.git
synced 2025-09-04 08:14:21 +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 := config.Banner
|
||||||
banner = strings.Replace(banner, "\\v", config.Version, -1)
|
banner = strings.Replace(banner, "\\v", config.Version, -1)
|
||||||
banner = strings.Replace(banner, "\\s", "RancherOS "+runtime.GOARCH, -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, "\\n", cfg.Hostname, -1)
|
||||||
banner = strings.Replace(banner, "\\l", tty, -1)
|
banner = strings.Replace(banner, "\\l", tty, -1)
|
||||||
banner = strings.Replace(banner, "\\\\", "\\", -1)
|
banner = strings.Replace(banner, "\\\\", "\\", -1)
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"strings"
|
||||||
|
|
||||||
yaml "github.com/cloudfoundry-incubator/candiedyaml"
|
yaml "github.com/cloudfoundry-incubator/candiedyaml"
|
||||||
"github.com/rancher/os/util"
|
"github.com/rancher/os/util"
|
||||||
)
|
)
|
||||||
@@ -72,3 +75,12 @@ func Set(key string, value interface{}) error {
|
|||||||
|
|
||||||
return WriteToFile(modified, CloudConfigFile)
|
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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
composeConfig "github.com/docker/libcompose/config"
|
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
|
||||||
environment["NO_PROXY"] = cfg.Rancher.Network.NoProxy
|
environment["NO_PROXY"] = cfg.Rancher.Network.NoProxy
|
||||||
}
|
}
|
||||||
b, err := ioutil.ReadFile("/proc/version")
|
if v := config.GetKernelVersion(); v != "" {
|
||||||
if err == nil {
|
environment["KERNEL_VERSION"] = v
|
||||||
elem := strings.Split(string(b), " ")
|
log.Debugf("Using /proc/version to set rancher.environment.KERNEL_VERSION = %s", v)
|
||||||
environment["KERNEL_VERSION"] = elem[2]
|
|
||||||
log.Debugf("Using /proc/version to set rancher.environment.KERNEL_VERSION = %s", elem[2])
|
|
||||||
}
|
}
|
||||||
return environment
|
return environment
|
||||||
}
|
}
|
||||||
|
@@ -94,6 +94,12 @@ func sysInit(c *config.CloudConfig) (*config.CloudConfig, error) {
|
|||||||
|
|
||||||
func MainInit() {
|
func MainInit() {
|
||||||
log.InitDeferedLogger()
|
log.InitDeferedLogger()
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
fmt.Printf("Starting Recovery console: %v\n", r)
|
||||||
|
recovery(nil)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if err := RunInit(); err != nil {
|
if err := RunInit(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
Reference in New Issue
Block a user