Tools/Linux_reinstall/updatemotd/90-footer

17 lines
529 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:00 +08:00
apt update
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