package cmd

import (
	"os/exec"
	"bytes"
	"strings"
	"fmt"
)

func GetLocalArchType() string {
	cmd := exec.Command("arch")
	var buf bytes.Buffer
	cmd.Stdout = &buf
	cmd.Run()
	if buf.String() != "" {
		lines := strings.Split(buf.String(),"\n")
		if len(lines) == 2 {
			return strings.Trim(lines[0]," ")
		}
		return ""
	}
	return ""
}

func GetLocalUuid() string {
	cmd := exec.Command("dmidecode")
	var buf ,errbuf bytes.Buffer
	cmd.Stdout = &buf
	cmd.Stderr = &errbuf
	err := cmd.Start()
	if err != nil {
		fmt.Println("Start",err)
	}
	err = cmd.Wait()
	if err != nil {
		fmt.Println("Wait",err)
	}
	fmt.Println("err",errbuf.String())
	fmt.Println("uuid",buf.String())
	if buf.String() != "" {
		lines := strings.Split(buf.String(),"\n")
		if len(lines) >0 {
			for _,l := range lines {
				if strings.Contains(l,"UUID") {
					return strings.Trim(l," ")
				}
			}

		}
	}
	return ""
}