I have an open source shell/bash script for setting up and configuring hosting servers, and to install cloudflare I am pulling the version of RHEL using this command:
RHEL_VERSION=$(rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release) );
The problem is that if there is a minor version, that will be returned instead of just the major version. With the cmd above it will return 7.2
... problem is, I only need the major version number.
I'm thinking that I can probably just use the rpm -q --whatprovides redhat-release
which would return something like cloudlinux-release-7.2-1.el7.x86_64
, and then just sed
, awk
, etc to get just the el7
portion of the string.
I need this to be able to use the string when creating the package URL:
PACKAGE_URL="http://pkg.cloudflare.com/cloudflare-release-latest.el${RHEL_VERSION}.rpm"