Created
March 14, 2013 01:59
-
-
Save mricon/5158209 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.