Last active
June 6, 2018 17:56
-
-
Save jparrill/583000753701f90c0655 to your computer and use it in GitHub Desktop.
Yum update checker with severities RHEL/CentOS/Fedora
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
##### | |
## Author: [email protected] | |
## Dept: Consulting/Infrastructure | |
## Detail: Script to check updates and their severity | |
## Example: yum_update_report.sh -s Moderate | |
##### | |
function validations () | |
{ | |
SEVERITY=$1 | |
case "${SEVERITY}" in | |
All|all) COMMAND="yum updateinfo list" | |
;; | |
Critical|critical) COMMAND="yum updateinfo list --security --sec-severity=Critical" | |
;; | |
Important|important) COMMAND="yum updateinfo list --security --sec-severity=Important" | |
;; | |
Moderate|moderate) COMMAND="yum updateinfo list --security --sec-severity=Moderate" | |
;; | |
Bugfix|bugfix) COMMAND="yum updateinfo list --bugfix" | |
;; | |
Enhancement|enhancement) COMMAND="yum updateinfo list | grep enhancement" | |
;; | |
esac | |
} | |
function check_updates () | |
{ | |
$COMMAND | |
} | |
function export () | |
{ | |
$COMMAND | awk '{print $3}' | grep `uname -m` > /tmp/yum_pending_updates.log | |
} | |
function usage () | |
{ | |
cat <<EOF | |
usage: $0 options | |
OPTIONS: | |
-s Severity: All, Critical, Important, Moderate, Bugfix, Enhancement | |
-h Show Help | |
EOF | |
} | |
## Main | |
while getopts "s:n:ha" OPTION | |
do | |
case $OPTION in | |
h) | |
usage | |
exit | |
;; | |
s) | |
SEVERITY=$OPTARG | |
;; | |
?) | |
usage | |
exit | |
;; | |
esac | |
done | |
if [[ -z $SEVERITY ]] | |
then | |
usage | |
exit 1 | |
else | |
validations $SEVERITY | |
check_updates | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On my Centos 6.x it always ignores the severity and includes all security updates.
Seems to be a problem with yum-plugin-security. The only error message I've spotted is:
Severity "Important" not found applicable for this system
But a point to note is that all my systems have been configured with Spacewalk (yum prints "This system is receiving updates from RHN Classic or Red Hat Satellite.") maybe it doesn't pass severities.