| Line 1... | Line 1... | 
          
            | 1 | #! /usr/bin/perl -w
 | 1 | #!/usr/bin/env perl
 | 
          
            | - |   | 2 |  
 | 
          
            | - |   | 3 | use strict;
 | 
          
            | - |   | 4 | use warnings;
 | 
          
            | 2 |  
 | 5 |  
 | 
          
            | 3 | # v0.2 20160205 RWR
 | 6 | # v0.2 20160205 RWR
 | 
          
            | 4 | # Removed echoing the results from parse_sysinfo for all normally processed
 | 7 | # Removed echoing the results from parse_sysinfo for all normally processed
 | 
          
            | 5 | # reports. Only if a report is invalid, duped, or waiting on user input
 | 8 | # reports. Only if a report is invalid, duped, or waiting on user input
 | 
          
            | 6 | # is anything from parse_sysinfo echoed.
 | 9 | # is anything from parse_sysinfo echoed.
 | 
          
            | Line 41... | Line 44... | 
          
            | 41 | sub loadConfig {
 | 44 | sub loadConfig {
 | 
          
            | 42 |    my ( $confFileName, @searchPaths ) = @_;
 | 45 |    my ( $confFileName, @searchPaths ) = @_;
 | 
          
            | 43 |    my $configuration;
 | 46 |    my $configuration;
 | 
          
            | 44 |  
 | 47 |  
 | 
          
            | 45 |  
 | 48 |  
 | 
          
            | 46 |    for ( $i = 0; $i < @searchPaths; $i++ ) {
 | 49 |    for ( my $i = 0; $i < @searchPaths; $i++ ) {
 | 
          
            | 47 |       $filename = $searchPaths[$i] . '/' . $confFileName;
 | 50 |       my $filename = $searchPaths[$i] . '/' . $confFileName;
 | 
          
            | 48 |       if ( -e $filename ) {
 | 51 |       if ( -e $filename ) {
 | 
          
            | 49 |          #print "Found $filename\n";
 | 52 |          #print "Found $filename\n";
 | 
          
            | 50 |          open CONF, "<$filename" or warn "Could not read $filename: $!\n";
 | 53 |          open CONF, "<$filename" or warn "Could not read $filename: $!\n";
 | 
          
            | 51 |          $configuration = Load( join( '', <CONF> ) );
 | 54 |          $configuration = Load( join( '', <CONF> ) );
 | 
          
            | 52 |          close CONF;
 | 55 |          close CONF;
 | 
          
            | Line 88... | Line 91... | 
          
            | 88 | # just some convenience variables
 | 91 | # just some convenience variables
 | 
          
            | 89 | $DATADIR = $$config{'datapath'};
 | 92 | $DATADIR = $$config{'datapath'};
 | 
          
            | 90 | $UNPROCESSED=$DATADIR . '/' . $$config{'unprocessed_path'};
 | 93 | $UNPROCESSED=$DATADIR . '/' . $$config{'unprocessed_path'};
 | 
          
            | 91 |  
 | 94 |  
 | 
          
            | 92 | # check that the executables exist before continuing
 | 95 | # check that the executables exist before continuing
 | 
          
            | 93 | $getMailScript = "$MY_DIRECTORY/" . $$config{'getMailScript'};
 | 96 | my $getMailScript = "$MY_DIRECTORY/" . $$config{'getMailScript'};
 | 
          
            | 94 | $processMailScript = "$MY_DIRECTORY/" . $$config{'processMailScript'};
 | 97 | my $processMailScript = "$MY_DIRECTORY/" . $$config{'processMailScript'};
 | 
          
            | 95 | $reportScript = "$MY_DIRECTORY/" . $$config{'reportScript'};
 | 98 | my $reportScript = "$MY_DIRECTORY/" . $$config{'reportScript'};
 | 
          
            | 96 |  
 | 99 |  
 | 
          
            | 97 | die "Could not find the getMailScript [$getMailScript] in $MY_DIRECTORY\n" unless -e $getMailScript;
 | 100 | die "Could not find the getMailScript [$getMailScript] in $MY_DIRECTORY\n" unless -e $getMailScript;
 | 
          
            | 98 | die "Could not find the processMailScript [$processMailScript] in $MY_DIRECTORY\n" unless -e $processMailScript;
 | 101 | die "Could not find the processMailScript [$processMailScript] in $MY_DIRECTORY\n" unless -e $processMailScript;
 | 
          
            | 99 | die "Could not find the reportScript [$reportScript] in $MY_DIRECTORY\n" unless -e $reportScript;
 | 102 | die "Could not find the reportScript [$reportScript] in $MY_DIRECTORY\n" unless -e $reportScript;
 | 
          
            | 100 |  
 | 103 |  
 | 
          
            | Line 102... | Line 105... | 
          
            | 102 | # fetch all messages pending from e-mail accounts
 | 105 | # fetch all messages pending from e-mail accounts
 | 
          
            | 103 | `php $getMailScript` if $CHECKMAIL;
 | 106 | `php $getMailScript` if $CHECKMAIL;
 | 
          
            | 104 |  
 | 107 |  
 | 
          
            | 105 | # get a list of all messages waiting to be processed
 | 108 | # get a list of all messages waiting to be processed
 | 
          
            | 106 | opendir ( my $dh, $UNPROCESSED ) or die "Could not open $UNPROCESSED for read: $!";
 | 109 | opendir ( my $dh, $UNPROCESSED ) or die "Could not open $UNPROCESSED for read: $!";
 | 
          
            | 107 | @files = map{ "$UNPROCESSED\/$_" } sort grep { ! /^\./ && -f "$UNPROCESSED/$_" } readdir( $dh );
 | 110 | my @files = map{ "$UNPROCESSED\/$_" } sort grep { ! /^\./ && -f "$UNPROCESSED/$_" } readdir( $dh );
 | 
          
            | 108 | closedir $dh;
 | 111 | closedir $dh;
 | 
          
            | 109 |  
 | 112 |  
 | 
          
            | 110 | my $count = 0;
 | 113 | my $count = 0;
 | 
          
            | - |   | 114 | my $results = '';
 | 
          
            | 111 |  
 | 115 |  
 | 
          
            | 112 | foreach my $thisFile ( sort @files ) {
 | 116 | foreach my $thisFile ( sort @files ) {
 | 
          
            | - |   | 117 |    my $exitCode;
 | 
          
            | - |   | 118 |    my $tempResults;
 | 
          
            | - |   | 119 |    
 | 
          
            | 113 |    if ( $PROCESS ) {
 | 120 |    if ( $PROCESS ) {
 | 
          
            | 114 |       $tempResults .=  `php $processMailScript <'$thisFile'`;
 | 121 |       $tempResults .=  `php $processMailScript <'$thisFile'`;
 | 
          
            | 115 |       if ( $? == -1 ) {
 | 122 |       if ( $? == -1 ) {
 | 
          
            | 116 |          $exitCode = -1;
 | 123 |          $exitCode = -1;
 | 
          
            | 117 |          die "Parsing failed: $!\n";
 | 124 |          die "Parsing failed: $!\n";
 |