]>
Commit | Line | Data |
---|---|---|
d0d5b944 DM |
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 | ||
152ac93e DM |
35 | if (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 | |
51 | rename('/root/.razor/razor-agent.log', '/root/.razor/razor-agent.log.0'); | |
52 | ||
7122424b DC |
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 | ||
d0d5b944 DM |
60 | # run bayes database maintainance |
61 | system('sa-learn --force-expire >/dev/null 2>&1'); | |
62 | ||
63 | exit (0); | |
64 |