]>
git.proxmox.com Git - pve-manager.git/blob - bin/pveupdate
14 use PVE
::RPCEnvironment
;
15 use PVE
::API2
::Subscription
;
18 initlog
('pveupdate', 'daemon');
20 die "please run as root\n" if $> != 0;
22 $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
24 PVE
::INotify
::inotify_init
();
26 my $rpcenv = PVE
::RPCEnvironment-
>init('cli');
28 $rpcenv->init_request();
29 $rpcenv->set_language($ENV{LANG
});
30 $rpcenv->set_user('root@pam');
32 my $nodename = PVE
::INotify
::nodename
();
34 eval { PVE
::API2
::Subscription-
>update({ node
=> $nodename }); };
36 syslog
('err', "update subscription info failed: $err");
39 my $dccfg = PVE
::Cluster
::cfs_read_file
('datacenter.cfg');
40 eval { PVE
::APLInfo
::update
($dccfg->{http_proxy
}); };
42 syslog
('err', "update appliance info failed - see /var/log/pveam.log for details");
45 my $info = PVE
::INotify
::read_file
('subscription');
46 # We assume that users with subscriptions want informations
48 my $notify = ($info && $info->{status
} eq 'Active') ?
1 : 0;
49 eval { PVE
::API2
::APT-
>update_database({ node
=> $nodename, notify
=> $notify, quiet
=> 1 }); };
51 syslog
('err', "update apt database failed: $err");
56 my $taskdir = "/var/log/pve/tasks";
57 my $filename = "$taskdir/index.1";
59 my $fh = IO
::File-
>new($filename, O_RDONLY
);
63 while (defined(my $line = <$fh>)) {
64 if ($line =~ m/^(\S+)(\s([0-9A-Za-z]{8})(\s(\S.*))?)?$/) {
73 # print "delete task older that $endtime\n" . localtime($endtime) . "\n";
80 return if $filename !~ m/^UPID:/;
83 if (($st = stat($filename)) && ($st->mtime < $endtime)) {
89 foreach my $subdir (qw(0 1 2 3 4 5 6 7 8 9 A B C D E F)) {
90 my $path = "$taskdir/$subdir";
95 syslog
('info', "cleanup removed $count task logs");