Add arch property to jailhost

This commit is contained in:
yo 2022-10-16 15:18:35 +02:00
parent be756edea7
commit 74602dc0df
2 changed files with 13 additions and 0 deletions

View File

@ -179,6 +179,15 @@ func getHostId() (string, error) {
return strings.Split(string(content), "\n")[0], nil
}
func getArch() (string, error) {
out, err := executeCommand("/usr/bin/uname -p")
if err != nil {
return "", fmt.Errorf("Error executing \"/usr/bin/uname -p\": %v", err)
}
return strings.Split(out, "\n")[0], nil
}
func getFreeBSDVersion() (FreeBSDVersion, error) {
var version FreeBSDVersion
regex := `([0-9]{1,2})(\.)?([0-9]{1,2})?\-([^\-]*)(\-)?(p[0-9]{1,2})?`
@ -219,6 +228,9 @@ func NewJailHost() (JailHost, error) {
if jh.hostname, err = getHostname(); err != nil {
return jh, err
}
if jh.arch, err = getArch(); err != nil {
return jh, err
}
if jh.hostid, err = getHostId(); err != nil {
return jh, err
}

View File

@ -213,6 +213,7 @@ type FreeBSDVersion struct {
type JailHost struct {
hostname string
hostid string
arch string
default_gateway4 string
default_gateway6 string
default_interface string