public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Dominic Jäger" <d.jaeger@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 2/5 v2] apt update: Inform users about missing subscriptions
Date: Wed, 14 Jul 2021 12:09:30 +0200	[thread overview]
Message-ID: <20210714100933.54491-2-d.jaeger@proxmox.com> (raw)
In-Reply-To: <20210714100933.54491-1-d.jaeger@proxmox.com>

We assume that users want update notifications for production systems.
Those systems should also have an active subscription.

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
---
v2: new

 PVE/API2/APT.pm | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/APT.pm b/PVE/API2/APT.pm
index bd60db33..b6a86595 100644
--- a/PVE/API2/APT.pm
+++ b/PVE/API2/APT.pm
@@ -36,6 +36,15 @@ my $get_apt_cache = sub {
     return $apt_cache;
 };
 
+# avoid a wall of text in the code
+my $get_subscription_message = sub {
+    my $hostname = shift;
+    return "You do not have a valid subscription for the server '$hostname'.\n\n" .
+    "A subscription gives access to the Proxmox VE Enterprise Repository.\n" .
+    "This repository contains the most stable packages and is recommended for production use.\n" .
+    "Please visit www.proxmox.com to get a list of available options.\n\n\n"
+};
+
 use base qw(PVE::RESTHandler);
 
 __PACKAGE__->register_method({
@@ -345,7 +354,12 @@ __PACKAGE__->register_method({
 		    my $mailfrom = $dcconf->{email_from} || "root";
 		    my $subject = "New software packages available ($hostname)";
 
-		    my $data = "The following updates are available:\n\n";
+		    my $info = PVE::INotify::read_file('subscription');
+		    my $has_subscription = $info && $info->{status} eq 'Active';
+
+		    my $data = "";
+		    $data .= $get_subscription_message->($hostname) if !$has_subscription;
+		    $data .= "The following updates are available:\n\n";
 
 		    my $count = 0;
 		    foreach my $p (sort {$a->{Package} cmp $b->{Package} } @$pkglist) {
-- 
2.30.2





  reply	other threads:[~2021-07-14 10:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14 10:09 [pve-devel] [PATCH cluster 1/5 v2] Close #1295: Add notifications to datacenter schema Dominic Jäger
2021-07-14 10:09 ` Dominic Jäger [this message]
2021-07-14 10:09 ` [pve-devel] [PATCH manager 3/5 v2] Close #1295: Make apt notifications configurable Dominic Jäger
2021-07-14 10:09 ` [pve-devel] [PATCH manager 4/5 v2] dc options: Add apt notifications GUI checkbox Dominic Jäger
2021-07-14 10:09 ` [pve-devel] [PATCH manager 5/5 v2] dc options: Allow both package_update options Dominic Jäger

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=20210714100933.54491-2-d.jaeger@proxmox.com \
    --to=d.jaeger@proxmox.com \
    --cc=pve-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal