all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Mika Scheer <mscheer@cyberfusion.io>
To: pmg-devel@lists.proxmox.com
Cc: Mika Scheer <mscheer@cyberfusion.io>
Subject: [PATCH pmg-api 1/1] fix #2999: make package update notifications configurable
Date: Mon, 19 Oct 2026 17:43:15 +0200	[thread overview]
Message-ID: <20261019154401.94264-2-mscheer@cyberfusion.io> (raw)
In-Reply-To: <20261019154401.94264-1-mscheer@cyberfusion.io>

Signed-off-by: Mika Scheer <mscheer@cyberfusion.io>
---
 src/PMG/Config.pm | 15 +++++++++++++++
 src/bin/pmg-daily | 16 +++++++++++++---
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/src/PMG/Config.pm b/src/PMG/Config.pm
index 070a34f..ee8c397 100644
--- a/src/PMG/Config.pm
+++ b/src/PMG/Config.pm
@@ -196,6 +196,20 @@ EODESC
             format => 'pmg-log-tracker-base',
             default => '/var/log/syslog',
         },
+        'package-updates' => {
+            description =>
+                "Control whether the daily update job should send out notifications.",
+            verbose_description => <<EODESC,
+Control whether the daily update job should send out notifications:
+
+* 'auto' always send a notification for new pending updates on systems with a valid subscription, as those are assumed to be production-ready and thus should know about pending updates.
+* 'always' always send a notification for new pending updates.
+* 'never' never send a notification for new pending updates.
+EODESC
+            type => 'string',
+            enum => ['auto', 'always', 'never'],
+            default => 'auto',
+        },
     };
 }
 
@@ -218,6 +232,7 @@ sub options {
         'admin-mail-from' => { optional => 1 },
         'consent-text' => { optional => 1 },
         'log-tracker-base' => { optional => 1, root_only => 1 },
+        'package-updates' => { optional => 1 },
     };
 }
 
diff --git a/src/bin/pmg-daily b/src/bin/pmg-daily
index 656127b..7a85c8a 100755
--- a/src/bin/pmg-daily
+++ b/src/bin/pmg-daily
@@ -59,10 +59,20 @@ if (my $statlifetime = $cfg->get('admin', 'statlifetime')) {
 }
 
 # check for available updates
-# We assume that users with subscriptions want information
-# about new packages.
 my $info = eval { PMG::API2::Subscription::read_etc_subscription() };
-my $notify = ($info && $info->{status} eq 'active') ? 1 : 0;
+my $notify_on = $cfg->get('admin', 'package-updates') // 'auto';
+my $notify = 0;
+if ($notify_on eq 'auto') {
+    # hosts with subscriptions are likely production system and thus want infos about new packages
+    $notify = ($info && $info->{status} eq 'active') ? 1 : 0;
+} elsif ($notify_on eq 'always') {
+    $notify = 1;
+} elsif ($notify_on eq 'never') {
+    $notify = 0;
+} else {
+    warn "unexpected package-updates  notify configuration value '$notify_on'\n";
+}
+
 eval { PMG::API2::APT->update_database({ node => $nodename, notify => $notify, quiet => 1 }); };
 if (my $err = $@) {
     syslog('err', "update apt database failed: $err");
-- 
2.50.1 (Apple Git-155)





      reply	other threads:[~2026-10-22 11:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 15:43 [PATCH pmg-api 0/1] fix #2999: make package update notifications configurable Mika Scheer
2026-10-19 15:43 ` Mika Scheer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261019154401.94264-2-mscheer@cyberfusion.io \
    --to=mscheer@cyberfusion.io \
    --cc=pmg-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal