package FS::Yori;
# a reporting program, to report information to the MCP

use strict;
use base 'Exporter';

our @EXPORT_OK = qw( reports report );

sub reports { #should be autogenerated i guess
  qw( freeside_version debian_version pg_version
      apache_version apache_mpm
    );
      #ssh_vulnkey
}

sub report {
  my $report = shift;
  $report =~ /^(\w+)$/ or die;
  eval "report_$report();";
}

sub report_all {
  foreach my $report ( reports() ) {
    print "$report: ". report($report). "\n";
  }
}

sub report_freeside_version {
  chomp( my $fs_version =
    `grep '^VERSION=' /home/ivan/freeside/Makefile | cut -d= -f2`
  );
  $fs_version;
}

sub report_debian_version {
  chomp( my $deb_version = `cat /etc/debian_version` );
  $deb_version;
}

sub report_pg_version {
  chomp( my $pg_version = `echo 'show server_version' | psql -t freeside` );
  chomp($pg_version); #two?
  $pg_version =~ s/^ +//;
  $pg_version;
}

sub report_apache_version {
  chomp( my $apache_version =
    `/usr/sbin/apache2 -v | head -1 | cut -d: -f2 | cut -d/ -f2 | cut -d' ' -f1`
  );
  $apache_version;
}

sub report_apache_mpm {
  chomp( my $apache_mpm =
    `/usr/sbin/apache2 -V | grep '^Server MPM' | cut -d: -f2`
  );
  $apache_mpm =~ s/^ +//;
  $apache_mpm;
}

#sub report_ssh_vulnkey{
#  my $ssh_vulnkey = `ssh-vulnkey -a | grep COMPROMISED`;
#  $ssh_vulnkey;
#}
