Tools/Linux_reinstall/Debian/updatemotd/90-footer

32 lines
1.3 KiB
Text
Raw Normal View History

2023-06-17 13:32:54 +08:00
#!/bin/sh
#
# Authors:Leitbogioro
# https://github.com/leitbogioro/
# https://www.zhihu.com/column/originaltechnic
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2023-07-17 15:36:49 +08:00
UpdateLog="/var/log/PackagesUpdatingStatus.log"
[[ -f "$UpdateLog" ]] && rm -rf $UpdateLog
2023-06-17 13:32:54 +08:00
apt list --upgradable | awk 'END{print NR}' | tee -a "$UpdateLog" > /dev/null 2>&1
2023-07-17 15:36:49 +08:00
UpdateRemind=$(cat $UpdateLog | tail -n 1)
UpdateNum=$(expr $UpdateRemind - 1)
[ "$UpdateNum" -eq "1" ] && printf "$UpdateNum package can be upgraded. Run 'apt list --upgradable' to see it.\n"
[ "$UpdateNum" -gt "1" ] && printf "$UpdateNum packages can be upgraded. Run 'apt list --upgradable' to see them.\n"
rm -rf $UpdateLog