Skip to content

Instantly share code, notes, and snippets.

@marinnedea
Last active November 27, 2018 14:41
Show Gist options
  • Save marinnedea/637348f54b3d5b65f3acecb64f6ea795 to your computer and use it in GitHub Desktop.
Save marinnedea/637348f54b3d5b65f3acecb64f6ea795 to your computer and use it in GitHub Desktop.
#!/bin/bash
####### Check if root is running this script, and bail if not root
# be root or exit
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
# Check RHEL release version
rhelrelease="$(cat /etc/redhat-release | awk '{print $7}')"
# Usage: version MIN CURRENT MAX
version(){
local h t v
[[ $2 = "$1" || $2 = "$3" ]] && return 0
v=$(printf '%s\n' "$@" | sort -V)
h=$(head -n1 <<<"$v")
t=$(tail -n1 <<<"$v")
[[ $2 != "$h" && $2 != "$t" ]]
}
if version 6.7 "$rhelrelease" 7.0; then
echo "$rhelrelease"
wget https://rhui-1.microsoft.com/pulp/repos/microsoft-azure-rhel6/rhui-azure-rhel6-2.2-74.noarch.rpm
# rpm -U rhui-azure-rhel6-2.2-74.noarch.rpm
fi
if version 7.1 "$rhelrelease" 7.6; then
echo "$rhelrelease"
wget https://rhui-1.microsoft.com/pulp/repos/microsoft-azure-rhel7/rhui-azure-rhel7-2.2-74.noarch.rpm
# rpm -U rhui-azure-rhel7-2.2-74.noarch.rpm
fi
if ! version 6.7 "$rhelrelease" 7.6; then
echo "RHEL Release Version $rhelrelease must be between higher than 6.7"
exit
fi
sudo yum clean all
sudo yum repolist
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment