Tools/Linux_reinstall/updatemotd/90-footer

34 lines
1.2 KiB
Text
Raw Normal View History

2022-11-11 21:31:56 +08:00
#!/bin/sh
2022-11-19 01:08:41 +08:00
#
2022-11-11 21:31:56 +08:00
# Authors:Leitbogioro
# https://github.com/leitbogioro/
# https://www.zhihu.com/column/originaltechnic
2022-11-19 01:08:41 +08:00
#
# 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.
2022-11-11 21:31:56 +08:00
UpdateLog="/var/log/packagesupdatefile.log"
2022-11-19 01:30:47 +08:00
if [ -f "$UpdateLog" ]; then
2022-11-11 21:31:56 +08:00
rm -rf $UpdateLog
fi
2022-11-19 01:08:41 +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-19 01:28:55 +08:00
UpdateNum=`expr $UpdateRemind - 1`
if [ "$UpdateNum" -ge "1" ]; then
printf "$UpdateNum packages can be upgraded. Run 'apt list --upgradable' to see them.\n"
2022-11-11 21:31:56 +08:00
fi
2022-11-19 01:08:41 +08:00
2022-11-11 21:31:56 +08:00
rm -rf $UpdateLog