diff options
author | Peter Mikus <pmikus@cisco.com> | 2019-06-05 08:59:37 +0000 |
---|---|---|
committer | Peter Mikus <pmikus@cisco.com> | 2019-06-05 09:36:56 +0000 |
commit | e5c9717d241c005b4546ada80b5b85a40cde2061 (patch) | |
tree | 23dc39048594e5ffdec01795ddc05091a69cc49c /resources/libraries/bash/function/common.sh | |
parent | ea6e8be86d47b288df5e11ca5515f6bda71dbd08 (diff) |
FIX: OS detection
Change-Id: I3ba6c7dc6a72e376419990ce7f5acc8d373f246f
Signed-off-by: Peter Mikus <pmikus@cisco.com>
Diffstat (limited to 'resources/libraries/bash/function/common.sh')
-rw-r--r-- | resources/libraries/bash/function/common.sh | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/resources/libraries/bash/function/common.sh b/resources/libraries/bash/function/common.sh index 399b449fa0..02c65c82c2 100644 --- a/resources/libraries/bash/function/common.sh +++ b/resources/libraries/bash/function/common.sh @@ -765,27 +765,29 @@ function select_os () { set -exuo pipefail - # Variables read: - # - OS - os or distro for selecting container image. # Variables set: # - VPP_VER_FILE - Name of File in CSIT dir containing vpp stable version. # - IMAGE_VER_FILE - Name of File in CSIT dir containing the image name. # - PKG_SUFFIX - Suffix of OS package file name, "rpm" or "deb." - case "${OS}" in - "ubuntu"*) - IMAGE_VER_FILE="VPP_DEVICE_IMAGE_UBUNTU" - VPP_VER_FILE="VPP_STABLE_VER_UBUNTU_BIONIC" - PKG_SUFFIX="deb" - ;; - "centos"*) - IMAGE_VER_FILE="VPP_DEVICE_IMAGE_CENTOS" - VPP_VER_FILE="VPP_STABLE_VER_CENTOS" - PKG_SUFFIX="rpm" - ;; - *) - die "Unable to identify distro or os from ${OS}" - ;; + os_id=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') || { + die "Get OS release failed." + } + + case "${os_id}" in + "ubuntu"*) + IMAGE_VER_FILE="VPP_DEVICE_IMAGE_UBUNTU" + VPP_VER_FILE="VPP_STABLE_VER_UBUNTU_BIONIC" + PKG_SUFFIX="deb" + ;; + "centos"*) + IMAGE_VER_FILE="VPP_DEVICE_IMAGE_CENTOS" + VPP_VER_FILE="VPP_STABLE_VER_CENTOS" + PKG_SUFFIX="rpm" + ;; + *) + die "Unable to identify distro or os from ${OS}" + ;; esac } |