aboutsummaryrefslogtreecommitdiffstats
path: root/mgaadv
blob: d40762c5c6e22c3fbe1280ca3204a8ec584ca29f (plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl -w

use strict;
use MGA::Advisories;

my %actions = (
    mksite => \&mksite,
    usage  => \&usage,
);

my %usage = (
    mksite => <<END,
$0 mksite

Generates the advisories web site
END
    usage => <<END,
$0 usage [action]

Show action usage
END
);

sub usage {
    if ($_[1] && $usage{$_[1]}) {
        print STDERR $usage{$_[1]};
    } else {
        print STDERR "$0 [action] [options]\n";
        print STDERR "$0 usage [action]\n\n";
        print STDERR "Available actions:\n";
        print STDERR map { " - $_\n" } keys %actions;
    }
}

sub mksite {
    my %advdb;
    $advdb{advisories} = MGA::Advisories::get_advisories();
    MGA::Advisories::publish_advisories(\%advdb);
    MGA::Advisories::sort_advisories(\%advdb);
    MGA::Advisories::output_pages(\%advdb);
    MGA::Advisories::dumpdb(\%advdb);
    MGA::Advisories::send_adv_mail(\%advdb);
    MGA::Advisories::send_report_mail(\%advdb);
}

if (@ARGV == 0 || !$actions{$ARGV[0]}) {
    usage();
    exit 1;
}
$actions{$ARGV[0]}->(@ARGV);