NEW: script to look for updates and create a transaction file

This commit is contained in:
xpk 2020-04-22 18:51:36 +08:00
parent 842333dd19
commit bc9a41ef35
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86

15
sh/yum-notifycation.sh Normal file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Get yum transaction
yum --assumeno update | tee /root/yum-check.txt
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
# /root/yum-notice.txt can now be sent to user