File: Debian.pm

package info (click to toggle)
faqomatic 2.721-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,984 kB
  • ctags: 548
  • sloc: perl: 13,356; sh: 69; makefile: 47
file content (38 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download | duplicates (2)
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;