]>
git.proxmox.com Git - pve-manager.git/blob - bin/pveupdate
17 use PVE
::RPCEnvironment
;
18 use PVE
::API2
::Subscription
;
22 initlog
('pveupdate', 'daemon');
24 die "please run as root\n" if $> != 0;
26 $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
28 PVE
::INotify
::inotify_init
();
30 my $rpcenv = PVE
::RPCEnvironment-
>init('cli');
32 $rpcenv->init_request();
33 $rpcenv->set_language($ENV{LANG
});
34 $rpcenv->set_user('root@pam');
36 my $nodename = PVE
::INotify
::nodename
();
38 eval { PVE
::API2
::Subscription-
>update({ node
=> $nodename }); };
40 syslog
('err', "update subscription info failed: $err");
43 my $dccfg = PVE
::Cluster
::cfs_read_file
('datacenter.cfg');
44 eval { PVE
::APLInfo
::update
($dccfg->{http_proxy
}); };
46 syslog
('err', "update appliance info failed - see /var/log/pveam.log for details");
49 my $info = PVE
::INotify
::read_file
('subscription');
50 # We assume that users with subscriptions want informations
52 my $notify = ($info && $info->{status
} eq 'Active') ?
1 : 0;
53 eval { PVE
::API2
::APT-
>update_database({ node
=> $nodename, notify
=> $notify, quiet
=> 1 }); };
55 syslog
('err', "update apt database failed: $err");
59 my $node_config = PVE
::NodeConfig
::load_config
($nodename);
60 if ($node_config && $node_config->{acme
}) {
61 my $cert = PVE
::CertHelpers
::cert_path_prefix
($nodename).".pem";
63 if (PVE
::Certificate
::check_expiry
($cert, time() + 30*24*60*60)) {
64 PVE
::API2
::ACME-
>renew_certificate({ node
=> $nodename });
66 syslog
('info', 'Custom certificate does not expire soon, skipping ACME renewal.');
69 syslog
('info', 'ACME config found for node, but no custom certificate exists. Skipping ACME renewal until initial certificate has been deployed.');
73 syslog
('err', "Renewing ACME certificate failed: $@") if $@;
77 my $taskdir = "/var/log/pve/tasks";
78 my $filename = "$taskdir/index.1";
80 my $fh = IO
::File-
>new($filename, O_RDONLY
);
84 while (defined(my $line = <$fh>)) {
85 if ($line =~ m/^(\S+)(\s([0-9A-Za-z]{8})(\s(\S.*))?)?$/) {
94 # print "delete task older that $endtime\n" . localtime($endtime) . "\n";
101 return if $filename !~ m/^UPID:/;
104 if (($st = stat($filename)) && ($st->mtime < $endtime)) {
110 foreach my $subdir (qw(0 1 2 3 4 5 6 7 8 9 A B C D E F)) {
111 my $path = "$taskdir/$subdir";
112 find
($wanted, $path);
116 syslog
('info', "cleanup removed $count task logs");