]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Subscription.pm
cgroup: cpu quota: fix resetting period length for v1
[pve-common.git] / src / PVE / Subscription.pm
index 8de1c027965064e501bcaadfbbc13bd329c92072..ffd86c0ed929885d387dde8b643d2bffc2f78c89 100644 (file)
@@ -68,7 +68,7 @@ sub check_fields {
 sub check_subscription {
     my ($key, $server_id, $proxy) = @_;
 
-    my $whmcsurl = "https://shop.maurer-it.com";
+    my $whmcsurl = "https://shop.proxmox.com";
 
     my $uri = "$whmcsurl/modules/servers/licensing/verify.php";
 
@@ -154,7 +154,7 @@ sub read_subscription {
        $data .= $line;
     }
 
-    if ($csum && $data) {
+    if ($key && $csum && $data) {
 
        chomp $csum;
 
@@ -171,13 +171,12 @@ sub read_subscription {
            my $age = time() -  $localinfo->{checktime};
 
            my $maxage = ($localkeydays + $allowcheckfaildays)*60*60*24;
-           if ($localinfo->{status} eq 'Active' && $age > $maxage) {
-               $localinfo->{status} = 'Invalid';
-               $localinfo->{message} = "subscription info too old";
-           }
+           die "subscription info too old\n"
+               if ($localinfo->{status} eq 'Active') && ($age > $maxage);
        };
        if (my $err = $@) {
-           warn $err;
+           chomp $err;
+           $info->{message} = $err;
        } else {
            $info = $localinfo;
        }
@@ -189,7 +188,23 @@ sub read_subscription {
 sub update_apt_auth {
     my ($key, $server_id) = @_;
 
-    my $auth = { 'enterprise.proxmox.com' => { login => $key, password => $server_id } };
+    my $repo;
+    if ($key =~ /^pmg/) {
+       $repo = 'pmg';
+    } elsif ($key =~ /^pve/) {
+       $repo = 'pve';
+    } else {
+       warn "unknown key format for '$key', defaulting to pve\n";
+       $repo = 'pve';
+    }
+
+    my $auth = {
+       "enterprise.proxmox.com" => undef, # for dropping the older, to generic match
+       "enterprise.proxmox.com/debian/$repo" => {
+           login => $key,
+           password => $server_id,
+       },
+    };
     PVE::INotify::update_file('apt-auth', $auth);
 }