Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.50 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. ## Author : Joshua S. Day (haxmeister)
  4. ## Purpose : A anonymous funtoo data reporting tool
  5.  
  6. ## written with the following additional packages
  7. ## from gentoo/funtoo repository:
  8. ##
  9. ## dev-perl/JSON-2.900.0
  10.  
  11. ## version 1.0
  12.  
  13. use strict;
  14. use warnings;
  15. use JSON;
  16. use Term::ANSIColor;
  17. use lib "$ENV{PWD}/modules";
  18. use Report;
  19.  
  20. if (@ARGV) {
  21.     if ( $ARGV[0] eq 'show-json' ) {
  22.         my %report      = report_from_config();
  23.         my $json        = JSON->new->allow_nonref;
  24.         my $json_pretty = $json->pretty->encode( \%report );
  25.         print $json_pretty;
  26.     }
  27.  
  28.     if ( $ARGV[0] eq 'send' ) {
  29.         print "\n\nReporter is not currently capable of sending the report anywyhere\n\n";
  30.     }
  31.  
  32.     if ( $ARGV[0] eq 'help' ) {
  33.         show_help();
  34.     }
  35.  
  36. }
  37. else {
  38.     show_help();
  39. }
  40.  
  41. sub show_help {
  42.     print color('bold');
  43.     print "Funtoo anonymous data reporting tool usage: \n\n";
  44.     print color ('bold blue');
  45.     print "report send";
  46.     print color ('reset');
  47.     print "\t\t \"Send the report to funtoo's data collection\"\n";
  48.     print color ('bold blue');
  49.     print "report show-json";
  50.     print color ('reset');
  51.     print " \t \"Show the output that will be sent, in JSON format\"\n";
  52.     print color ('bold blue');
  53.     print "report help";
  54.     print color ('reset');
  55.     print " \t\t \"Show this help list\"\n";
  56.     print color ('bold');
  57.     print "\nOutput can be ommitted by modifying the /etc/report.conf file\n";
  58.     print color ('reset');
  59. }
  60.  
  61. sub report_from_config {
  62.     my %config = Report::user_config();
  63.     my %hash;
  64.  
  65.     if ( $config{'cpu-info'} eq 'y' ) {
  66.         $hash{'cpu-info'} = { Report::get_cpu_info() };
  67.     }
  68.  
  69.     if ( $config{'mem-info'} eq 'y' ) {
  70.         $hash{'mem-info'} = { Report::get_mem_info() };
  71.     }
  72.  
  73.     if ( $config{'kernel-info'} eq 'y' ) {
  74.         $hash{'kernel-info'} = { Report::get_kernel_info() };
  75.     }
  76.  
  77.     if ( $config{'boot-dir-info'} eq 'y' ) {
  78.         $hash{'boot-dir-info'} = { Report::get_boot_dir_info() };
  79.     }
  80.  
  81.     if ( $config{'version-info'} eq 'y' ) {
  82.         $hash{'version-info'} = { Report::get_version_info() };
  83.     }
  84.  
  85.     if ( $config{'world-info'} eq 'y' ) {
  86.         $hash{'world-file'} = \@{ Report::get_world_info() };
  87.     }
  88.     if ( $config{'profile-info'} eq 'y' ) {
  89.         $hash{'profile-info'} = { Report::get_profile_info() };
  90.     }
  91.     if ( $config{'kit-info'} eq 'y' ) {
  92.         $hash{'kit-info'} = { Report::get_kit_info() };
  93.     }
  94.     return %hash;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement