Skip to content

Commit

Permalink
Merge pull request #34 from lebauce/lebauce/more-distros
Browse files Browse the repository at this point in the history
Add support for more distributions
  • Loading branch information
nplanel authored Nov 12, 2021
2 parents d4e8ef6 + f6b7ea9 commit b026dcc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions host/host_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ func PlatformInformation() (platform string, family string, version string, err
if err == nil {
version = getRedhatishVersion(contents)
}
} else if common.PathExists(common.HostEtc("slackware-version")) {
platform = "slackware"
contents, err := common.ReadLines(common.HostEtc("slackware-version"))
if err == nil {
version = getSlackwareVersion(contents)
}
} else if common.PathExists(common.HostEtc("debian_version")) {
if lsb.ID == "Ubuntu" {
platform = "ubuntu"
Expand Down Expand Up @@ -341,9 +347,9 @@ func PlatformInformation() (platform string, family string, version string, err
family = "debian"
case "fedora":
family = "fedora"
case "oracle", "centos", "redhat", "scientific", "enterpriseenterprise", "amazon", "xenserver", "cloudlinux", "ibm_powerkvm":
case "oracle", "centos", "redhat", "scientific", "enterpriseenterprise", "amazon", "xenserver", "cloudlinux", "ibm_powerkvm", "rocky":
family = "rhel"
case "suse", "opensuse":
case "suse", "opensuse", "opensuse-leap", "opensuse-tumbleweed", "opensuse-tumbleweed-kubic", "sles", "sled", "caasp":
family = "suse"
case "gentoo":
family = "gentoo"
Expand All @@ -357,6 +363,8 @@ func PlatformInformation() (platform string, family string, version string, err
family = "alpine"
case "coreos":
family = "coreos"
case "solus":
family = "solus"
}

return platform, family, version, nil
Expand All @@ -379,6 +387,12 @@ func KernelVersion() (version string, err error) {
return version, nil
}

func getSlackwareVersion(contents []string) string {
c := strings.ToLower(strings.Join(contents, ""))
c = strings.Replace(c, "slackware ", "", 1)
return c
}

func getRedhatishVersion(contents []string) string {
c := strings.ToLower(strings.Join(contents, ""))

Expand Down

0 comments on commit b026dcc

Please sign in to comment.