]> git.proxmox.com Git - pmg-api.git/blob - bin/pmg-cron-hourly
Makefile: cleanup, install pmg-cron-hourly as extra script
[pmg-api.git] / bin / pmg-cron-hourly
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
10 use PVE::SafeSyslog;
11 use PVE::INotify;
12 use PVE::RESTEnvironment;
13
14 use PMG::Utils;
15 use PMG::Config;
16 use PMG::ClusterConfig;
17 use PMG::LDAPSet;
18
19 $SIG{'__WARN__'} = sub {
20 my $err = $@;
21 my $t = $_[0];
22 chomp $t;
23 print STDERR "$t\n";
24 syslog('warning', "%s", $t);
25 $@ = $err;
26 };
27
28 PVE::RESTEnvironment->setup_default_cli_env();
29
30 initlog('pmg-cron-hourly', 'mail');
31
32 my $cfg = PMG::Config->new();
33
34 my $demo = $cfg->get('admin', 'demo');
35
36 my $cluster = PMG::ClusterConfig->new();
37
38 if ($demo) {
39 # fixme: generate fake statistics
40
41 return;
42 }
43
44 PMG::Utils::service_cmd('pmgpolicy', 'restart');
45
46 my $ldap_cfg = PVE::INotify::read_file("pmg-ldap.conf");
47 PMG::LDAPSet::ldap_resync($ldap_cfg);
48
49 # sync bayes journal to database
50 system('sa-learn --sync >/dev/null 2>&1');
51
52 # make sure clamav-daemon is running
53 PMG::Utils::service_cmd('clamav-daemon', 'start');
54
55 exit(0);
56