diff --git a/etc/yum-cron-hourly.conf b/etc/yum-cron-hourly.conf index 5265d03f..31365adb 100644 --- a/etc/yum-cron-hourly.conf +++ b/etc/yum-cron-hourly.conf @@ -44,6 +44,8 @@ emit_via = stdio # formatted to. output_width = 80 +# Send messages even when there are no packages needing updates. +emit_when_up_to_date = no [email] # The address to send email messages from. diff --git a/etc/yum-cron-security.conf b/etc/yum-cron-security.conf index db9f350c..58e0a513 100644 --- a/etc/yum-cron-security.conf +++ b/etc/yum-cron-security.conf @@ -47,6 +47,9 @@ emit_via = stdio # formatted to. output_width = 80 +# Send messages even when there are no packages needing updates. +emit_when_up_to_date = no + [email] # The address to send email messages from. diff --git a/etc/yum-cron.conf b/etc/yum-cron.conf index 6a3d5ca4..cdd88865 100644 --- a/etc/yum-cron.conf +++ b/etc/yum-cron.conf @@ -46,6 +46,9 @@ emit_via = stdio # formatted to. output_width = 80 +# Send messages even when there are no packages needing updates. +emit_when_up_to_date = no + [email] # The address to send email messages from. diff --git a/yum-cron/TODO b/yum-cron/TODO index 28e19646..0c29021d 100644 --- a/yum-cron/TODO +++ b/yum-cron/TODO @@ -7,7 +7,6 @@ Documentation: Mail: - Use a different subject for success and failure mail -- Make receiving mail when nothing happens optional General: - Break out check-updates and download-updates into their own actions; diff --git a/yum-cron/yum-cron.py b/yum-cron/yum-cron.py index fd593d62..11ab0051 100755 --- a/yum-cron/yum-cron.py +++ b/yum-cron/yum-cron.py @@ -46,6 +46,12 @@ def updatesAvailable(self, summary): self.output.append('The following updates are available on %s:' % self.opts.system_name) self.output.append(summary) + def updatesUnavailable(self): + """Appends a message to the output list stating that there are + no updates available. + """ + self.output.append('Yum indicates that there are no updates available') + def updatesDownloading(self, summary): """Append a message to the output list stating that downloading updates has started. @@ -164,6 +170,13 @@ def updatesAvailable(self, summary): super(EmailEmitter, self).updatesAvailable(summary) self.subject = "Yum: Updates Available on %s" % self.opts.system_name + def updatesUnavailable(self): + """Appends a message to the output list stating that there are + no updates available, and set an appropiate subject line. + """ + super(EmailEmitter, self).updatesUnavailable() + self.subject = "Yum: Up-To-Date" + def updatesDownloaded(self): """Append a message to the output list stating that updates have been downloaded successfully, and set an appropriate @@ -284,6 +297,7 @@ class YumCronConfig(BaseConfig): lock_retries = IntOption(5) lock_sleep = IntOption(60) emit_via = ListOption(['email','stdio']) + emit_when_up_to_date = BoolOption(False) email_to = ListOption(["root"]) email_from = Option("root") email_host = Option("localhost") @@ -634,6 +648,10 @@ def updatesCheck(self): gups = self.refreshGroupUpdates() # If neither have updates, we can just exit. if not (pups or gups): + if self.opts.emit_when_up_to_date: + self.emitUnavailable() + self.sendMessages() + self.releaseLocks() sys.exit(0) # Build the transaction to find the additional dependencies @@ -669,6 +687,10 @@ def emitAvailable(self): summary = self.listTransaction() map(lambda x: x.updatesAvailable(summary), self.emitters) + def emitUnavailable(self): + """Emit a notice stating updates are not avaialble.""" + map(lambda x: x.updatesUnavailable(), self.emitters) + def emitDownloading(self): """Emit a notice stating that updates are downloading.""" summary = self.listTransaction()