aboutsummarylogtreecommitdiffstats
path: root/report.pl
blob: cb7db3318357ba5c5fbbe6fdfb7b77b6e9c26dc7 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/perl

# Autheur: Nicolas Guilloux
# Website: https://nicolasguilloux.eu/
# Email:   novares.x@gmail.com

use strict;
use warnings;


# Send to Hostbin
#
# @parem String Content
#
# @return String URL
sub share {
    open(my $fh, '>', '/var/tmp/report_shadow');
    print $fh $_[0];
    close $fh;

    my $url = `curl -sf --data-binary "@/var/tmp/report_shadow" https://nicolasguilloux.eu/hostbin`;

    system('rm /var/tmp/report_shadow');

    return $url;
}

# ------- Check AppImage ------- #
my $path = '/opt/Shadow Beta';
my $isAppImg = 0;

if( $#ARGV > -1 ) {
    if( $ARGV[0] eq '--appimage' ) {
        $path = './opt/Shadow Beta';
        $isAppImg = 1;
    }
}


my $return = "Shadow Report";

if( $isAppImg ) { $return .= " (AppImage)"; }

$return .= "\n";

# -------- AppImage version -------- #
if( -f 'shadow-appimage-version' ) {

    # Local version
    open(my $fh, '<:encoding(UTF-8)', 'shadow-appimage-version')
      or die "Could not open file 'shadow-appimage-version' $!";
    my $localVersion = <$fh>;
    chomp $localVersion;

    $return .= "AppImage $localVersion \n";
}

# -------- Distribution information -------- #
$return .= "\n-------------------------------------\n\n";
$return .= `cat /etc/*-release`;
$return .= `uname -mrs`;
$return .= "\n-------------------------------------\n\n";

# -------- Environment -------- #
$return .= 'Environment server: ' . `echo \$XDG_SESSION_TYPE`;
if( index(`groups \$USER`, 'input') == -1 ) {
    $return .= '/!\ The user is not in the "input" group.';
} else {
    $return .= 'The user is in the "input" group.';
}

# -------- Missing libraries -------- #
$return .= "\n\n-------------------------------------\n";
$return .= "          Missing libraries\n";
$return .= "-------------------------------------\n";

$return .= `ldd -v "$path/shadow-beta" | grep "not found"`;
$return .= `ldd -v "$path/resources/app.asar.unpacked/native/linux/ClientSDL" | grep "not found"`;

# -------- VA-API check -------- #
$return .= "\n-------------------------------------\n";
$return .= "               Vainfo\n";
$return .= "-------------------------------------\n";

if( -f '/usr/bin/vainfo' ) {
    $return .= `vainfo`;

} else {
    $return .= "'vainfo' is not installed.";
}

# -------- Logs -------- #
$return .= "\n-------------------------------------\n";
$return .= "                Logs\n";
$return .= "-------------------------------------\n";

if( -f $ENV{"HOME"} . '/.cache/blade/shadow/shadow.log' ){
    my @logs = split(/template_digit/, `cat ~/.cache/blade/shadow/shadow.log`);
    $return .= 'template_digit' . $logs[-1];

} else {
    $return .= 'Logs not found.';
}

# -------- Send to Hostbin -------- #
print share($return) . "\n";