Skip to content

Commit

Permalink
CentOS Stream must be treated unstable; add os_pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
iliajie committed May 14, 2022
1 parent 432c8bc commit 38ba8c0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion slib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -522,19 +522,24 @@ get_distro () {
local os_string
os_string=$(cat /etc/oracle-release)
os_real='Oracle Linux'
os_pretty=$os_string
os_type='ol'
os_version=$(echo "$os_string" | grep -o '[0-9\.]*')
os_major_version=$(echo "$os_version" | cut -d '.' -f1)
elif [ -f /etc/redhat-release ]; then # RHEL/CentOS/Alma/Rocky
local os_string
os_string=$(cat /etc/redhat-release)
isrhel=$(echo "$os_string" | grep 'Red Hat')
iscentosstream=$(echo "$os_string" | grep 'CentOS Stream')
if [ ! -z "$isrhel" ]; then
os_real='RHEL'
elif [ ! -z "$iscentosstream" ]; then
os_real='CentOS Stream'
else
os_real=$(echo "$os_string" | cut -d' ' -f1) # Doesn't work for Scientific
fi
os_type=$(echo "$os_real" | tr '[:upper:]' '[:lower:]')
os_pretty=$os_string
os_type=$(echo "$os_real" | tr '[:upper:]' '[:lower:]' | tr ' ' '_')
os_version=$(echo "$os_string" | grep -o '[0-9\.]*')
os_major_version=$(echo "$os_version" | cut -d '.' -f1)
elif [ -f /etc/os-release ]; then # Debian/Ubuntu
Expand All @@ -544,6 +549,7 @@ get_distro () {
# Not technically correct, but os-release does not have 7.xxx for centos
# shellcheck disable=SC2153
os_real=$NAME
os_pretty=$PRETTY_NAME
os_type=$ID
os_version=$VERSION_ID
os_major_version=$(echo "${os_version}" | cut -d'.' -f1)
Expand Down

0 comments on commit 38ba8c0

Please sign in to comment.