Skip to content

Instantly share code, notes, and snippets.

@mricon
Created March 14, 2013 01:59
Show Gist options
  • Save mricon/5158209 to your computer and use it in GitHub Desktop.
Save mricon/5158209 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Downtimes are third Sunday of the month. In order to plan
# for upgrades and reboots, we email ourselves the list of all
# outstanding security updates for each system on the 2nd
# Wednesday of the month.
# Critical security update alerts are sent daily.
# Requires yum-plugin-security and mailx.
WEEKOFMONTH=$((($(date +%d)-1)/7+1))
DAYOFWEEK=$(date +%u)
if [ "$WEEKOFMONTH" = "2" -a "$DAYOFWEEK" = "3" ]; then
SUMMARY=`/usr/bin/yum -q --security updateinfo`
ERRATA=`/usr/bin/yum -q updateinfo list security 2>&1`
SUBJECT="Security updates available for $HOSTNAME"
else
SUMMARY="Critical errata advisory list:"
ERRATA=`/usr/bin/yum -q updateinfo list security 2>&1 | grep -i 'Critical/Sec'`
SUBJECT="CRITICAL Security updates available for $HOSTNAME"
fi
if [ ! -z "$ERRATA" ]; then
echo -e "${SUMMARY}\n\n${ERRATA}" | mail -s "$SUBJECT" root
fi
@mricon
Copy link
Author

mricon commented Mar 14, 2013

This can be dropped in as-is into /etc/cron.daily. Just make sure the dependencies on yum-plugin-security and mailx are satisfied and that the file is chmod 0755.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment