Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Azure Red Hat – RHUI Update

Posted on December 27, 2016January 9, 2017 By David Kittell

Most of the this script is based on the document “Red Hat Update Infrastructure (RHUI) for on-demand Red Hat Enterprise Linux VMs in Azure” at https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-update-infrastructure-redhat?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json

My change will first check if the update was already installed, if not it will follow the process to install

See updates at: https://gitlab.com/Kittell-RedHat/AzureRepo/raw/master/AzureRedHatRepoUpdate.sh

#!/bin/sh

#  AzureRedHatRepoUpdate.sh
#
#  This will update Azure Red Hat servers to the new RHUI Repo if needed.
#
#  Created by David Kittell on 12/27/16.
#

clear

cd ~/

echo -e "\033[32mChecking for Azure Red Hat Repo Update....\033[0m"
if rpm -qa | grep -q rhui-azure-rhel7-2.0-2.noarch; then
    echo "Installed"
    #exit 0
else
    echo "Not Installed.\nStarting process to update..."

    echo -e "\033[32mDownload (via curl) the public key signature\033[0m"
    curl -o RPM-GPG-KEY-microsoft-azure-release https://download.microsoft.com/download/9/D/9/9d945f05-541d-494f-9977-289b3ce8e774/microsoft-sign-public.asc

    echo -e "\033[32mValidate key\033[0m"
    if ! gpg --list-packets --verbose < RPM-GPG-KEY-microsoft-azure-release | grep -q "keyid: EB3E94ADBE1229CF"; then
        echo "Keyfile azure.asc NOT valid. Exiting."
        exit 1
    fi

    echo -e "\033[32mInstall Key\033[0m"
    sudo install -o root -g root -m 644 RPM-GPG-KEY-microsoft-azure-release /etc/pki/rpm-gpg
    sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-microsoft-azure-release

    echo -e "\033[32mDownload RPM package\033[0m"
    if grep -q "release 7" /etc/redhat-release; then
        ver=7
    elif  grep -q "release 6" /etc/redhat-release; then
        ver=6
    else
        echo "Version not supported, exiting"
        exit 1
    fi

    url=https://rhui-1.microsoft.com/pulp/repos/microsoft-azure-rhel$ver/rhui-azure-rhel$ver-2.0-2.noarch.rpm
    curl -o azureclient.rpm "$url"

    echo -e "\033[32mVerify package\033[0m"
    if ! rpm -Kv azureclient.rpm | grep -q "key ID be1229cf: OK"; then
        echo "RPM failed validation ($url)"
        exit 1
    fi

    echo -e "\033[32mInstall package\033[0m"
    sudo rpm -U azureclient.rpm

    echo -e "\033[32mCreating Yum Cache\033[0m"
    sudo yum -y makecache fast
    echo -e "\033[32mRunning Yum Update\033[0m"
    sudo yum -y update # Make sure you are up to date before you start

fi

Originally Posted on December 27, 2016
Last Updated on January 9, 2017
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Azure Code Red Hat UNIX UNIX Shell Scripts

Post navigation

Previous post
Next post

Related Posts

Bash – Running In Docker?

Posted on October 26, 2020August 17, 2024

docker=$(cat /proc/self/cgroup | awk -F/ ‘$2 == "docker"’) if [ ! -z "$docker" ]; then echo "Running in Docker" else echo "Not running in Docker" fi Originally Posted on October 26, 2020Last Updated on August 17, 2024 All information on this site is shared with the intention to help. Before…

Read More

System.Globalization String Format

Posted on June 24, 2015October 26, 2015

Recently I was asked to format a string into a different format, after some discussion they wanted the integer 500000 to show in a format attributed to India that looks like 5,00,000 The code below shows how best to convert the number, to see the code in action go to…

Read More

LDAP LastLogonTimeStamp Conversion

Posted on April 8, 2014October 26, 2015

In working with LDAP timestamps I found this script very helpful to be able to test with. (Get-Date "2/1/2014").ToFileTime() [datetime]::FromFileTime("128752344000000000") Reference: http://jai-maharaj.blogspot.com/2012/01/test.html Originally Posted on April 8, 2014Last Updated on October 26, 2015 All information on this site is shared with the intention to help. Before any source code or…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes