]>
git.proxmox.com Git - pmg-api.git/blob - PMG/API2/ClamAV.pm
1 package PMG
::API2
::ClamAV
;
9 use PVE
::Exception
qw(raise_param_exc);
11 use PMG
::RESTEnvironment
;
12 use PVE
::JSONSchema
qw(get_standard_option);
16 use base
qw(PVE::RESTHandler);
19 __PACKAGE__-
>register_method ({
23 description
=> "Directory index.",
27 additionalProperties
=> 0,
29 node
=> get_standard_option
('pve-node'),
38 links
=> [ { rel
=> 'child', href
=> "{subdir}" } ],
45 push @$res, { subdir
=> "dbstat" };
50 __PACKAGE__-
>register_method({
51 name
=> 'database_status',
54 description
=> "ClamAV virus database status.",
56 additionalProperties
=> 0,
58 node
=> get_standard_option
('pve-node'),
66 type
=> { type
=> 'string' },
67 build_time
=> { type
=> 'string' },
68 version
=> { type
=> 'string', optional
=> 1 },
69 nsigs
=> { type
=> 'integer' },
76 return PMG
::Utils
::clamav_dbstat
();
79 __PACKAGE__-
>register_method({
80 name
=> 'update_database',
83 description
=> "Update ClamAV virus databases.",
86 additionalProperties
=> 0,
88 node
=> get_standard_option
('pve-node'),
91 returns
=> { type
=> 'string' },
95 my $rpcenv = PMG
::RESTEnvironment-
>get();
96 my $authuser = $rpcenv->get_user();
101 # remove mirrors.dat so freshclam checks all servers again
103 unlink "/var/lib/clamav/mirrors.dat";
105 my $cmd = ['/usr/bin/freshclam', '--stdout'];
107 PVE
::Tools
::run_command
($cmd);
110 return $rpcenv->fork_worker('avupdate', undef, $authuser, $realcmd);