Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions scripts/vm/hypervisor/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,33 @@ DIST="Unknown Linux"
REV="X.Y"
CODENAME=""

if [ -f /etc/redhat-release ] ; then
function get_from_redhat_release {
DIST=`cat /etc/redhat-release | awk '{print $1}'`
CODENAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | awk '{print $3,$4}' | grep -o "[0-9.]*"`
elif [ -f /etc/lsb-release ] ; then
}

function get_from_lsb_release {
DIST=`cat /etc/lsb-release | grep DISTRIB_ID | tr "\n" ' '| sed s/.*=//`
REV=`cat /etc/lsb-release | grep DISTRIB_RELEASE | tr "\n" ' '| sed s/.*=//`
CODENAME=`cat /etc/lsb-release | grep DISTRIB_CODENAME | tr "\n" ' '| sed s/.*=//`
elif [ -f /etc/os-release ] ; then
}

function get_from_os_release {
DIST=`grep -e "^NAME=" /etc/os-release | awk -F\" '{print $2}'`
REV=`grep -e "^VERSION_ID=" /etc/os-release | awk -F\" '{print $2}'`
CODENAME=`grep -e "^PRETTY_NAME=" /etc/os-release | awk -F\" '{print $2}'`
}

if [ -f /etc/redhat-release ] ; then
get_from_redhat_release
if [ -z "$REV" ] && [ -f /etc/os-release ]; then
get_from_os_release
fi
elif [ -f /etc/lsb-release ] ; then
get_from_lsb_release
elif [ -f /etc/os-release ] ; then
get_from_os_release
fi

echo Host.OS=${DIST}
Expand Down