1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
package FAQ::OMatic::Debian;
use strict;
use warnings;
use Exporter;
use FAQ::OMatic::maintenance;
our @ISA = qw(Exporter);
our @EXPORT = qw(maintenance_job);
sub maintenance_job {
my $maint_conf_file = shift || '/var/lib/fom/meta/maintenance_job_conf';
my %vars;
open(F, "<$maint_conf_file") || die "cannot open $maint_conf_file: $!\n";
while (<F>) {
$vars{$1} = $2 if (m!^\s*([a-zA-Z]+)\s*=\s*([-a-zA-Z0-9/?&=.]+)\s*$!);
}
die "We are missing some vars from the maintenance job config file."
unless $vars{HOST} && $vars{PORT} && $vars{REQUEST};
# Check the parameters we read from our config file.
$vars{HOST} =~ /^([-a-zA-Z0-9]+\.?)*$/ || die "\$host var looks fishy";
$vars{PORT} =~ /^[0-9]{1,5}$/ || die "\$port var looks fishy";
$vars{REQUEST} =~ m!^[-a-zA-Z0-9/]+\?cmd=maintenance&secret=[0-9a-z]*!
|| die "\$request var looks fishy";
# croninvoke() does not return an accurate value but makes plenty
# of noise if it finds a problem, cron should mail this off.
FAQ::OMatic::maintenance::cronInvoke($vars{HOST}, $vars{PORT}, $vars{REQUEST});
}
1;
|