0

I am trying to figure a way to solve an issue I am facing. I have an offline standalone server at work. It is not connected to the internet and we have to manually patch the server each month. We transfer the packages of things to be downloaded from another linux server (same OS) in a folder. The folder has 50-100 rpm packages and we transfer it to the home folder of the standalone server.

We run the following to update the standalone server to upgrade it each month.

#cd November-os-updates

#yum clean all

#yum update *.rpm --disablerepo=*

What script can enable me to check that all the rpm packages in the November-os-updates is installed/upgraded successfully? If everything is successful, it will say something like all packages installed successfully! If there are packages that did not upgrade for whatever reason, it will say something like: "(package name) not installed!". This will help me tremendously to ensure we are patching it correctly. In the past, there has been instances where packages were not updated and that caused a big issue.

New contributor
user14135159 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • $ sudo yum update *.rpm --disablerepo=* 1>| update.log 2>| update_err.log ? or if you still want human eyes in the loop: $ sudo yum update *.rpm --disablerepo=* 2>| update_err.log | tee update.log . Both cmds will produce new logs at every batch update, clobbering the old logs if still present. Is it the general idea of what you need ? (In principle, yum output should be self-explanatory in terms of packages being successfully updated or not. Don't over design it.
    – Cbhihe
    Nov 25 at 8:47
  • You'll find your answer on either this first RedHat webpage - ch 8.1, or on this second RedHat webpage - ch 8.2. Nov 25 at 9:00
1

From 8.2.2. Listing Packages of Red Hat Deployment Guide:

yum list available

Lists all available packages in all enabled repositories

In addition, 8.2.3. Displaying Package Information of the same guide is also useful:

For example, to display information about the abrt package, type:

yum info abrt
...
Name       : abrt
Arch       : x86_64
Version    : 1.0.7
Release    : 5.el6
Size       : 578 k
Repo       : installed
From repo  : rhel
...

Compare packages in your November-os-updates directory with all packages from yum list available. Let me know if the following solution works.

#!/bin/bash

# - [ change working directory ]
cd 'path-to'/November-os-updates

# - [ define variables ]
ALL_PKG=($(yum list available))
INSTLLD=($(ls ./*))

# - [ remove cache of enabled repos ]
yum clean all

# - [ update every currently installed package ]
yum update *.rpm --disablerepo=*

# - [ verify installed packages ]
for ((i=0; i <= "${#ALL_PKG[@]}"; i++)); do
    for ((j=0; j <= "${#INSTLLD[@]}"; j++ )); do

        ## [1] - if installed, print [success]
        if [[ "${INSTLLD[j]}" == "${ALL_PKG[i]}"'.rpm' ]]; then
            echo "${INSTLLD[j]} - success"

        ## [2] - if not installed print [failure]
        else
            echo "${INSTLLD[j]} - failure"

        ## [3] - END
        fi

    done
done

Your Answer

user14135159 is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.