]> git.proxmox.com Git - pmg-api.git/blame - bin/pmg-daily
rename safe_browsing_score to clamav_heuristic_score
[pmg-api.git] / bin / pmg-daily
CommitLineData
d0d5b944
DM
1#!/usr/bin/perl -T
2
3$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
4
5delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
6
7use strict;
8use warnings;
9use Time::Local;
10
11use PVE::SafeSyslog;
12use PVE::INotify;
13use PVE::RESTEnvironment;
14
15use PMG::Utils;
16use PMG::Config;
17use PMG::ClusterConfig;
18use 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
29PVE::RESTEnvironment->setup_default_cli_env();
30
31initlog('pmg-daily', 'mail');
32
33my $cfg = PMG::Config->new();
34
152ac93e
DM
35if (my $statlifetime = $cfg->get ('admin', 'statlifetime')) {
36 my $count = 0;
d0d5b944
DM
37 eval {
38 my $dbh = PMG::DBTools::open_ruledb();
8fb6f404 39 $count = PMG::DBTools::purge_statistic_database($dbh, $statlifetime);
d0d5b944
DM
40 };
41 if (my $err = $@) {
b902c0b8 42 syslog('err', $err);
d0d5b944 43 } else {
152ac93e 44 syslog('info', "cleanup removed $count entries from statistic database") if $count;
d0d5b944 45 }
d0d5b944
DM
46}
47
d0d5b944
DM
48# fixme: check for available updates
49
50# rotate razor log file
51rename('/root/.razor/razor-agent.log', '/root/.razor/razor-agent.log.0');
52
7122424b
DC
53# update spamassassin rules
54if (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
d0d5b944
DM
60# run bayes database maintainance
61system('sa-learn --force-expire >/dev/null 2>&1');
62
63exit (0);
64