eyre.os
gather-os
(gather-os {:keys [exec shell]})Gathers operating system, kernel and distribution facts from the host reachable via exec.
Arguments
Takes a map with:
:exec- an executor function that runs a script string on the target host and returns{:exit int :out string :err string}.:shell- the shell map returned byeyre.shell/gather-shell; its:typeselects which embedded collection script is run. Shells without a specific script fall back to the POSIX script.
Returns
A map with:
:family- keyword OS family derived from the kernel name::linux,:darwin,:freebsd,:netbsd,:openbsd,:dragonfly,:sunos,:aixor:windows.:kernel- a map{:name :release :version}with the kernel name (e.g."Linux"), release (e.g."6.12.91-1-MANJARO") and full build/version string. On Windows only:nameand:releaseare present.:machine- hardware architecture string, e.g."x86_64". WindowsPROCESSOR_ARCHITECTUREvalues are normalized to uname style, so"AMD64"becomes"x86_64"and"ARM64"becomes"aarch64".:distro- distribution/product details (see below); omitted for unix families other than:linuxand:darwin.
The :distro map is sourced from /etc/os-release and lsb_release on Linux, from sw_vers on macOS (with :codename guessed from the release number) and from ver and WMI on Windows:
;; linux
{:id :ubuntu,
:codename :noble,
:description "Ubuntu 24.04.4 LTS",
:name "Ubuntu",
:release "24.04"}
;; macos
{:id :macos
:codename :sonoma
:name "macOS"
:release "14.4"
:build "23E214"}
;; windows
{:id :windows
:caption "Microsoft Windows 11 Pro"
:release "10.0.22631"
:build "22631"}
Example
(os/gather-os {:exec local-exec :shell shell})
;; => {:family :linux
;; :kernel {:name "Linux" :release "6.12.91-1-MANJARO"
;; :version "#1 SMP PREEMPT_DYNAMIC ..."}
;; :machine "x86_64"
;; :distro {:id :manjaro :name "Manjaro Linux" :release "24.04"}}
gather-script
(gather-script shell-type)Returns the embedded collection script for shell-type. Falls back to the POSIX script when no specific script is available.
process-os
(process-os shell-type sections)Processes parsed OS collection sections into an OS facts map.