2020-04-22 18:51:36 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Get yum transaction
|
2020-04-23 23:04:32 +08:00
|
|
|
yum --assumeno update > /root/yum-check.txt
|
|
|
|
grep -q yumtx /root/yum-check.txt || exit 0
|
2020-04-22 18:51:36 +08:00
|
|
|
cp $(tail -1 /root/yum-check.txt | awk '{print $NF}') /root/yum-transaction.yumtx
|
|
|
|
|
|
|
|
# Use yum output to construct a notification
|
|
|
|
echo "Updates available on $(date):" > /root/yum-notice.txt
|
|
|
|
grep -E '(base|updates).*[kM]' /root/yum-check.txt | awk '{print $1"-"$3}' >> /root/yum-notice.txt
|
|
|
|
echo -e "\n\nTo install these updates, run the following command:" >> /root/yum-notice.txt
|
|
|
|
echo "yum -y load-transaction /root/yum-transaction.yumtx" >> /root/yum-notice.txt
|
|
|
|
|
2020-07-31 16:35:20 +08:00
|
|
|
cat /root/yum-notice.txt | mailx -s "Update report from $(hostname)" -- you@acme.local
|
2020-04-22 18:51:36 +08:00
|
|
|
|