getFreeBSDInfo gets FreeBSD OS type and version
()
| 136 | |
| 137 | // getFreeBSDInfo gets FreeBSD OS type and version |
| 138 | func (d *Detector) getFreeBSDInfo() (osType, osVersion string, err error) { |
| 139 | osType = "FreeBSD" |
| 140 | |
| 141 | // Use freebsd-version for accurate version info |
| 142 | cmd := exec.Command("freebsd-version") |
| 143 | output, err := cmd.Output() |
| 144 | if err != nil { |
| 145 | d.logger.WithError(err).Warn("Failed to get FreeBSD version, falling back to uname -r") |
| 146 | // Fallback to uname -r |
| 147 | cmd = exec.Command("uname", "-r") |
| 148 | output, err = cmd.Output() |
| 149 | if err != nil { |
| 150 | return osType, "Unknown", nil |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | osVersion = strings.TrimSpace(string(output)) |
| 155 | |
| 156 | d.logger.WithFields(logrus.Fields{ |
| 157 | "os_type": osType, |
| 158 | "os_version": osVersion, |
| 159 | }).Debug("Detected FreeBSD system") |
| 160 | |
| 161 | return osType, osVersion, nil |
| 162 | } |
| 163 | |
| 164 | // DetectOS detects the operating system and version using /etc/os-release |
| 165 | func (d *Detector) DetectOS() (osType, osVersion string, err error) { |