-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsys-report.py
executable file
·112 lines (88 loc) · 2.7 KB
/
sys-report.py
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
107
108
109
110
111
112
#!/usr/bin/python3
import sys, os, shutil, subprocess
def installed(command):
return shutil.which(command) is not None
def prompt_install(command):
print(f"The command '{command}' is not installed. Please install it and try again.")
sys.exit(1)
def run_command(command):
try:
result = subprocess.run(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
check=True,
)
return result.stdout
except subprocess.CalledProcessError as e:
print(f"Error running command '{' '.join(command)}': {e.stderr}")
sys.exit(1)
def upload_to_termbin(data):
try:
process = subprocess.Popen(
["nc", "termbin.com", "9999"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
text=True,
)
url, _ = process.communicate(input=data)
if process.returncode == 0:
return url.strip()
else:
print("Failed to upload data to termbin.")
sys.exit(1)
except Exception as e:
print(f"Error uploading to termbin: {e}")
sys.exit(1)
def check_root() -> bool:
if os.geteuid():
print("This script must be run as root!", file=sys.stderr)
return False
return True
def main():
# Commands to gather debug data
ok = check_root()
progs = {
"inxi": "inxi",
"eglinfo": "mesa-utils",
"lsusb": "usbutils",
"lspci": "pciutils",
}
for i in progs.keys():
if not installed(i):
prompt_install(progs[i])
ok = False
neofetch_installed = installed("neofetch")
fastfetch_installed = installed("fastfetch")
commands = [
["lspci"],
["lsusb"],
["sh", "-c", "ls /dev/ttyACM* /dev/ttyUSB* /dev/ttyS* 2>/dev/null || true"],
["inxi", "-Fzxxx"],
["env"],
["pacman", "-Q"],
]
if fastfetch_installed:
commands.append(["fastfetch"])
elif neofetch_installed:
commands.append(["neofetch"])
else:
print(
"Neither neofetch or fastfetch are installed! For a complete report, please install either."
)
commands.append(["dmesg"]) # Big, leave it last.
if not ok:
return
# Run commands and gather outputs
debug_data = "BredOS System Reporter v1.1\n"
for cmd in commands:
debug_data += f"\n=== Output of {' '.join(cmd)} ===\n"
debug_data += run_command(cmd)
# Upload data to termbin
url = upload_to_termbin(debug_data)
print(
f"Debug data uploaded successfully: {url}Support: https://discord.gg/beSUnWGVH2"
)
if __name__ == "__main__":
main()