check_exec.pl
changeset 3 211e08d0d2b8
parent 2 ded3b78c61b1
child 4 67e8bd9a87c5
equal deleted inserted replaced
2:ded3b78c61b1 3:211e08d0d2b8
    32 
    32 
    33 my $opt_url;
    33 my $opt_url;
    34 my $opt_path   = "/var/tmp/nagios";
    34 my $opt_path   = "/var/tmp/nagios";
    35 my $opt_binary = "/usr/bin/gpg";
    35 my $opt_binary = "/usr/bin/gpg";
    36 
    36 
       
    37 my $home_dir = (getpwuid($>))[7];
       
    38 
    37 MAIN: {
    39 MAIN: {
    38     Getopt::Long::Configure('bundling');
    40     Getopt::Long::Configure('bundling');
    39     GetOptions(
    41     GetOptions(
    40         "u|url=s"    => \$opt_url,
    42         "u|url=s"    => \$opt_url,
    41         "b|binary=s" => \$opt_binary,
    43         "b|binary=s" => \$opt_binary,
    64         exit $ERRORS{CRITICAL};
    66         exit $ERRORS{CRITICAL};
    65     };
    67     };
    66 
    68 
    67     my @cmd = ($run_file);
    69     my @cmd = ($run_file);
    68 
    70 
    69 	exec(@cmd) or print "EXEC CRITICAL: Couldn't exec $run_file ($!)";
    71     exec(@cmd) or print "EXEC CRITICAL: Couldn't exec $run_file ($!)";
    70 }
    72 }
    71 
    73 
    72 sub cleanup($) {
    74 sub cleanup($) {
    73     my $file = shift;
    75     my $file = shift;
    74 
    76 
   118 sub verify($) {
   120 sub verify($) {
   119     my $file     = shift;
   121     my $file     = shift;
   120     my $dir      = dirname($file);
   122     my $dir      = dirname($file);
   121     my $run_file = fileparse($file, qw/\.[^.]*/);
   123     my $run_file = fileparse($file, qw/\.[^.]*/);
   122 
   124 
   123     my $vc = qq{$opt_binary --verify};
   125     my $vc = qq{$opt_binary --homedir $home_dir/.gnupg --verify};
   124     my $dc = qq{$opt_binary --batch --yes};
   126     my $dc = qq{$opt_binary --homedir $home_dir/.gnupg --batch --yes};
   125 
   127 
   126     my @r = qx/$vc $file 2>&1/;
   128     my @r = qx/$vc $file 2>&1/;
   127     if ($?) {
   129     if ($?) {
   128         print "EXEC CRITICAL: @r";
   130         print "EXEC CRITICAL: @r";
   129         exit $ERRORS{CRITICAL};
   131         exit $ERRORS{CRITICAL};