diff --git a/scripts/update-motd.d/40-updates b/scripts/update-motd.d/40-updates index 94025453b5..521782be55 100644 --- a/scripts/update-motd.d/40-updates +++ b/scripts/update-motd.d/40-updates @@ -27,7 +27,7 @@ import time import os import os.path as path -def refreshdata (): +def refreshdata(): # update procedure DISTRO = subprocess.Popen(["lsb_release", "-c", "-s"], stdout=subprocess.PIPE).communicate()[0].strip() @@ -131,18 +131,17 @@ def refreshdata (): myfile = "/var/cache/apt/archives/updates.number" now = time.time() twodays_ago = now - 60*60*24*2 # Number of seconds in two days -lastupgrade = os.stat('/var/cache/apt/archives').st_mtime +lastupgrade = path.getmtime('/var/lib/dpkg/status') -if os.path.isfile(myfile): +if path.isfile(myfile): fileCreation = path.getmtime(myfile) - if (fileCreation < twodays_ago or lastupgrade != fileCreation): - refreshdata () + if (fileCreation < twodays_ago or lastupgrade > fileCreation): + refreshdata() else: - refreshdata () + refreshdata() # display if there are some upgrades - file = open(myfile, 'r+') updates = int(file.read()) if updates > 0: - print("[ \033[92m%d updates to install\033[0m: apt-get upgrade ]\n" % (updates)) + print("\n[ \033[92m%d updates to install\033[0m: apt-get upgrade ]\n" % (updates))