]> git.proxmox.com Git - pmg-api.git/blob - bin/pmg-daily
rename safe_browsing_score to clamav_heuristic_score
[pmg-api.git] / bin / pmg-daily
1 #!/usr/bin/perl -T
2
3 $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
4
5 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
6
7 use strict;
8 use warnings;
9 use Time::Local;
10
11 use PVE::SafeSyslog;
12 use PVE::INotify;
13 use PVE::RESTEnvironment;
14
15 use PMG::Utils;
16 use PMG::Config;
17 use PMG::ClusterConfig;
18 use PMG::DBTools;
19
20 $SIG{'__WARN__'} = sub {
21 my $err = $@;
22 my $t = $_[0];
23 chomp $t;
24 print STDERR "$t\n";
25 syslog('warning', "%s", $t);
26 $@ = $err;
27 };
28
29 PVE::RESTEnvironment->setup_default_cli_env();
30
31 initlog('pmg-daily', 'mail');
32
33 my $cfg = PMG::Config->new();
34
35 if (my $statlifetime = $cfg->get ('admin', 'statlifetime')) {
36 my $count = 0;
37 eval {
38 my $dbh = PMG::DBTools::open_ruledb();
39 $count = PMG::DBTools::purge_statistic_database($dbh, $statlifetime);
40 };
41 if (my $err = $@) {
42 syslog('err', $err);
43 } else {
44 syslog('info', "cleanup removed $count entries from statistic database") if $count;
45 }
46 }
47
48 # fixme: check for available updates
49
50 # rotate razor log file
51 rename('/root/.razor/razor-agent.log', '/root/.razor/razor-agent.log.0');
52
53 # update spamassassin rules
54 if (system('sa-update') == 0) {
55 # if the exit code is 0, new updates were downloaded
56 # then restart the pmg-smtp-filter to load the new rules
57 PMG::Utils::service_cmd('pmg-smtp-filter', 'restart');
58 }
59
60 # run bayes database maintainance
61 system('sa-learn --force-expire >/dev/null 2>&1');
62
63 exit (0);
64