From 4cb09e2ac6f55f203d4effb80544f40472a54fb4 Mon Sep 17 00:00:00 2001 From: Jason-ZW Date: Tue, 9 Oct 2018 10:03:51 +0800 Subject: [PATCH] Add friendly tips on ros config syslinux --- cmd/control/config.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cmd/control/config.go b/cmd/control/config.go index e9e95014..09666525 100644 --- a/cmd/control/config.go +++ b/cmd/control/config.go @@ -1,6 +1,7 @@ package control import ( + "bufio" "fmt" "io" "io/ioutil" @@ -14,6 +15,7 @@ import ( "github.com/rancher/os/pkg/log" "github.com/codegangsta/cli" + "github.com/pkg/errors" "github.com/rancher/os/config" "github.com/rancher/os/pkg/util" ) @@ -153,6 +155,22 @@ func env2map(env []string) map[string]string { } func editSyslinux(c *cli.Context) error { + // check whether is Raspberry Pi or not + bytes, err := ioutil.ReadFile("/proc/device-tree/model") + if err == nil && strings.Contains(strings.ToLower(string(bytes)), "raspberry") { + buf := bufio.NewWriter(os.Stdout) + fmt.Fprintln(buf, "raspberry pi can not use this command") + buf.Flush() + return errors.New("raspberry pi can not use this command") + } + + if _, err := os.Stat("/proc/1/root/boot/global.cfg"); os.IsNotExist(err) { + buf := bufio.NewWriter(os.Stdout) + fmt.Fprintln(buf, "global.cfg can not be found") + buf.Flush() + return errors.New("global.cfg can not be found") + } + cmd := exec.Command("system-docker", "run", "--rm", "-it", "-v", "/:/host", "-w", "/host",