From 24229f0decccb7ebc77084c8b0784c4a20bf5b86 Mon Sep 17 00:00:00 2001 From: Jason-ZW Date: Wed, 9 Jan 2019 13:15:15 +0800 Subject: [PATCH] Add prompt message to ros os upgrade --- cmd/control/config.go | 2 +- cmd/control/os.go | 4 ++++ cmd/control/util.go | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/control/config.go b/cmd/control/config.go index 53837517..3ad8215c 100644 --- a/cmd/control/config.go +++ b/cmd/control/config.go @@ -164,7 +164,7 @@ func editSyslinux(c *cli.Context) error { return errors.New("raspberry pi can not use this command") } - if _, err := os.Stat("/proc/1/root/boot/global.cfg"); os.IsNotExist(err) { + if isExist := checkGlobalCfg(); !isExist { buf := bufio.NewWriter(os.Stdout) fmt.Fprintln(buf, "global.cfg can not be found") buf.Flush() diff --git a/cmd/control/os.go b/cmd/control/os.go index 0ddcfbe5..1fa4d6da 100644 --- a/cmd/control/os.go +++ b/cmd/control/os.go @@ -185,6 +185,10 @@ func osUpgrade(c *cli.Context) error { log.Fatalf("ros install / upgrade only supported on 'amd64', not '%s'", runtime.GOARCH) } + if isExist := checkGlobalCfg(); !isExist { + log.Fatalf("ros upgrade cannot be supported") + } + image := c.String("image") if image == "" { diff --git a/cmd/control/util.go b/cmd/control/util.go index cdcc5ea5..0df289a7 100644 --- a/cmd/control/util.go +++ b/cmd/control/util.go @@ -55,3 +55,11 @@ func symLinkEngineBinary(version string) []symlink { } return baseSymlink } + +func checkGlobalCfg() bool { + _, err := os.Stat("/proc/1/root/boot/global.cfg") + if err == nil || os.IsExist(err) { + return true + } + return false +}