summaryrefslogtreecommitdiff
path: root/scripts/collect-debug-info.sh
blob: 5501f5206b390176ca271f21b1036e06f0297e29 (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
#!/usr/bin/env bash
# chmod +x collect-debug-info.sh && collect-debug-info.sh
# Define the directory to scan
directory_to_scan="$HOME/homebrew/plugins"
system_info_file="$HOME/decky-sysinfo.txt"
backend_info_file="$HOME/decky-backend-log.txt"
frontend_info_file="$HOME/cef_log.txt"
frontend_previnfo_file="$HOME/cef_log.previous.txt"
plugin_info_file="$HOME/decky-plugin-info.txt"
archive_file="$HOME/decky-debug-info.zip"

echo "Please wait while this script collects the following debugging information:"
echo -e "\tCollecting system information..."
echo -e "\tOS Name..."
echo -e "\tRunning command: grep ^NAME= /etc/os-release > \"$system_info_file\""
grep ^NAME= /etc/os-release > "$system_info_file"
echo -e "\tOS Version (if it's SteamOS)..."
echo -e "\tRunning command: grep ^VERSION_ID= /etc/os-release >> \"$system_info_file\""
grep ^VERSION_ID= /etc/os-release >> "$system_info_file"
echo -e "\tSteam Client Version (if it's SteamOS)..."
echo -e "\tRunning command: grep \"Client version:\" \"$HOME/.steam/steam/logs/steamui_system.txt\" | tail -n 1 | sed 's/^[^:]*: //' | sed 's/^/CLIENT_VERSION=/' >> \"$system_info_file\""
grep "Client version:" "$HOME/.steam/steam/logs/steamui_system.txt" | tail -n 1 | sed 's/.*Client version: /CLIENT_VERSION=/' >> "$system_info_file"
echo ""
echo -e "\tCollecting plugin information from \"$directory_to_scan\"..."
# Loop through each subdirectory (one level deep)
for dir in "$directory_to_scan"/*/package.json; do
  # Extract name and version from the package.json file using jq
  name=$(jq -r '.name' "$dir")
  version=$(jq -r '.version' "$dir")

  {
    # Output the name and version
    echo "Directory: ${dir}"
    echo "Package Name: $name"
    echo "Version: $version"
    echo "-----------------------------"
  } >> "$plugin_info_file"
done
echo -e "\tPlugin information saved to \"$plugin_info_file\""
echo ""
echo -e "\tCollecting backend logs..."
echo -e "\tRunning command: journalctl -b0  -u plugin_loader.service > \"$backend_info_file\""
journalctl -b0 -u plugin_loader.service > "$backend_info_file"
echo ""
echo -e "\tCollecting frontend logs..."
echo -e "\tRunning command: cp \"$HOME/.steam/steam/logs/cef_log.txt\" \"$frontend_info_file\""
cp "$HOME/.steam/steam/logs/cef_log.txt" "$frontend_info_file"
echo -e "\tRunning command: cp \"$HOME/.steam/steam/logs/cef_log.previous.txt\" \"$frontend_previnfo_file\""
cp "$HOME/.steam/steam/logs/cef_log.previous.txt" "$frontend_previnfo_file"
echo ""
echo -e "\tScrubbing frontend logs to remove personal information..."
echo -e "\tRunning command: mapfile -t usernames < <(sed -nE 's/.*OnLoginStateChange ([^ ]*).*/\1/p' $HOME/.steam/steam/logs/webhelper_js.txt | sort | uniq)"
mapfile -t usernames < <(sed -nE 's/.*OnLoginStateChange ([^ ]*).*/\1/p' $HOME/.steam/steam/logs/webhelper_js.txt | sort | uniq)
for username in "${usernames[@]}"; do
  echo -e "\tRunning command: sed -i \"s/$username/anonymous/Ig\" \"$frontend_info_file\""
  sed -i "s/$username/anonymous/Ig" "$frontend_info_file"
  echo -e "\tRunning command: sed -i \"s/$username/anonymous/Ig\" \"$frontend_previnfo_file\""
  sed -i "s/$username/anonymous/Ig" "$frontend_previnfo_file"
done
echo ""
echo "Zipping up logs to \"$archive_file\". This may take a moment..."
echo -e "\tRunning command: zip -j \"$archive_file\" \"$system_info_file\" \"$plugin_info_file\" \"$backend_info_file\" \"$frontend_info_file\" \"$frontend_previnfo_file\"
"
zip -j "$archive_file" "$system_info_file" "$plugin_info_file" "$backend_info_file" "$frontend_info_file" "$frontend_previnfo_file"
echo "Finished zipping logs."
echo ""
echo "The following files are no longer needed and can be deleted:"
echo -e "\t$system_info_file"
echo -e "\t$plugin_info_file"
echo -e "\t$backend_info_file"
echo -e "\t$frontend_info_file"
echo -e "\t$frontend_previnfo_file"
read -p "Would you like this script to remove them (y/N)? " cleanup
case $cleanup in
  [Yy]* )
    echo -e "\tRemoving unneeded files..."
    echo -e "\tRunning command: rm \"$system_info_file\" \"$plugin_info_file\" \"$backend_info_file\" \"$frontend_info_file\" \"$frontend_previnfo_file\""
    rm "$system_info_file" "$plugin_info_file" "$backend_info_file" "$frontend_info_file" "$frontend_previnfo_file"
    ;;
  * )
    echo -e "\tSkipping cleanup"
    ;;
esac
echo "Please upload decky-debug-info.zip when reporting decky-loader issues."