fix #1295: pve daily update: honor new package-notification config

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2023-01-03 16:44:28 +01:00
parent b9e706fb85
commit 8432c6d351

View File

@ -51,8 +51,19 @@ if (my $err = $@) {
}
my $info = eval { PVE::API2::Subscription::read_etc_subscription() };
# Assume that users with subscriptions want informations about new packages.
my $notify = ($info && $info->{status} eq 'active') ? 1 : 0;
my $notify_on = $dccfg->{notify}->{'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 { PVE::API2::APT->update_database({ node => $nodename, notify => $notify, quiet => 1 }); };
if (my $err = $@) {
syslog ('err', "update apt database failed: $err");