示例#1
0
func getInitSystemType() int {
	if gotil.FileExistsInPath("systemctl") {
		return SystemD
	}

	if gotil.FileExistsInPath("update-rc.d") {
		return UpdateRcD
	}

	if gotil.FileExistsInPath("chkconfig") {
		return ChkConfig
	}

	return Unknown
}
示例#2
0
func (d *driver) Supported(
	ctx types.Context,
	opts types.Store) (bool, error) {

	// Use dmidecode if installed
	if gotil.FileExistsInPath(dmidecodeCmd) {
		out, err := exec.Command(
			dmidecodeCmd, "-s", "system-product-name").Output()
		if err == nil {
			outStr := strings.ToLower(gotil.Trim(string(out)))
			if outStr == "virtualbox" {
				return true, nil
			}
		}
		out, err = exec.Command(
			dmidecodeCmd, "-s", "system-manufacturer").Output()
		if err == nil {
			outStr := strings.ToLower(gotil.Trim(string(out)))
			if outStr == "innotek gmbh" {
				return true, nil
			}
		}
	}

	// No luck with dmidecode, try dmesg
	out, err := exec.Command("dmesg").Output()
	if err != nil {
		return false, nil
	}

	rdr := bytes.NewReader(out)
	scanner := bufio.NewScanner(rdr)

	for scanner.Scan() {
		if strings.Contains(scanner.Text(), "BIOS VirtualBox") {
			return true, nil
		}
	}

	return false, nil
}
示例#3
0
func (d *driver) Supported(ctx types.Context, opts types.Store) (bool, error) {
	// make sure NFS mounts can be done
	return gotil.FileExistsInPath("mount.nfs"), nil
}