From fce80136e3554bd0f1213403e6a6d7c868a727f8 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Fri, 30 Jan 2015 12:10:05 -0800 Subject: [PATCH] main: detects coreos --- main.go | 3 +++ pkg/coreos/coreos.go | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 pkg/coreos/coreos.go diff --git a/main.go b/main.go index 7983de712..3c3f47e42 100644 --- a/main.go +++ b/main.go @@ -30,6 +30,7 @@ import ( "github.com/coreos/etcd/etcdmain" "github.com/coreos/etcd/migrate/starter" + "github.com/coreos/etcd/pkg/coreos" ) func main() { @@ -41,6 +42,8 @@ func main() { if v { starter.StartDesiredVersion(os.Args[1:]) } + } else if coreos.IsCoreOS() { + starter.StartDesiredVersion(os.Args[1:]) } etcdmain.Main() } diff --git a/pkg/coreos/coreos.go b/pkg/coreos/coreos.go new file mode 100644 index 000000000..226d193c3 --- /dev/null +++ b/pkg/coreos/coreos.go @@ -0,0 +1,27 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package coreos + +import ( + "io/ioutil" + "strings" +) + +func IsCoreOS() bool { + b, err := ioutil.ReadFile("/usr/lib/os-release") + if err != nil { + return false + } + return strings.Contains(string(b), "ID=coreos") +}