1
0
mirror of https://github.com/rancher/os.git synced 2025-09-01 23:04:41 +00:00

set hostname from cloud-init

This commit is contained in:
wlan0
2015-03-25 15:27:33 -07:00
committed by Darren Shepherd
parent b339252a6f
commit 505174db35
3 changed files with 44 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package util
import (
"archive/tar"
"bufio"
"errors"
"fmt"
"io"
@@ -13,10 +14,11 @@ import (
"strings"
"syscall"
"gopkg.in/yaml.v2"
log "github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/mount"
"gopkg.in/yaml.v2"
)
var (
@@ -25,6 +27,23 @@ var (
ErrNotFound = errors.New("Failed to find resource")
)
func GetOSType() string {
f, err := os.Open("/etc/os-release")
defer f.Close()
if err != nil {
return "busybox"
}
scanner := bufio.NewScanner(f)
for scanner.Scan() {
line := scanner.Text()
if len(line) > 8 && line[:8] == "ID_LIKE=" {
return line[8:]
}
}
return "busybox"
}
func mountProc() error {
if _, err := os.Stat("/proc/self/mountinfo"); os.IsNotExist(err) {
if _, err := os.Stat("/proc"); os.IsNotExist(err) {