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