Tools/Linux_reinstall/updatemotd/90-footer

17 lines
533 B
Text
Raw Normal View History

2022-11-11 21:31:56 +08:00
#!/bin/sh
# Authors:Leitbogioro
# https://github.com/leitbogioro/
# https://www.zhihu.com/column/originaltechnic
UpdateLog="/var/log/packagesupdatefile.log"
if [ -f "$UpdateLog" ]; then
rm -rf $UpdateLog
fi
2022-11-18 23:44:36 +08:00
apt-get update
2022-11-18 23:44:00 +08:00
apt list --upgradable | awk 'END{print NR}' | tee -a "$UpdateLog" > /dev/null 2>&1
2022-11-11 21:31:56 +08:00
UpdateRemind=`cat $UpdateLog | tail -n 1`
2022-11-18 23:44:00 +08:00
Result=$(echo $UpdateRemind)
if [ "$Result" -ge "1" ]; then
printf "$UpdateRemind packages can be upgraded. Run 'apt list --upgradable' to see them.\n"
2022-11-11 21:31:56 +08:00
fi
rm -rf $UpdateLog