diff --git a/bmotd.sh b/bmotd.sh index 7174c78..a5dbf69 100755 --- a/bmotd.sh +++ b/bmotd.sh @@ -74,9 +74,16 @@ update() { KERNEL=$(uname -r) EXTERNAL=$(dig TXT +time=3 +tries=2 +short o-o.myaddr.l.google.com @ns1.google.com | tr -d '"') - # Get number of updates awaiting + # Check if pkg number cache exists test -f "$CACHEPATH/pkg_count" || PKG_REFRESH=1 - [[ $(date +%H%M) == "1510" ]] && PKG_REFRESH=1 + + # Check if pkg number cache is outdate + LASTMODIFICATION=$(date +%s -r "$CACHEPATH/pkg_count") + CURRENTTIME=$(date +%s) + UPDATEDAGO=$((CURRENTTIME - LASTMODIFICATION)) + [ "$UPDATEDAGO" -gt "86400" ] && PKG_REFRESH=1 + + # If cache old or non existent, get number of updates awaiting if [ $PKG_REFRESH ]; then case "$OSID" in debian|osmc|linuxmint)