-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebugging.sh
executable file
·159 lines (128 loc) · 3.4 KB
/
debugging.sh
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env bash
printf 'Welcome.\nThis script will ask you for sudo password, which is necessary to extract required information.\n'
# Get current username before escalating permissions
user=$USER
# Get board name
board="$(cat /sys/class/dmi/id/product_name)"
# Get current date and time
date="$(date +"%Y-%m-%d_%Hh%Mm")"
# Specify where to store logs
logdir="debug-logs-$board-$date"
logarchive="debug-logs-$board-$date.tar.gz"
# Create directory to store logs
mkdir -p $logdir
cd $logdir
# Download cbmem and mark it as executable
wget https://mrchromebox.tech/files/util/cbmem.tar.gz &> /dev/null
tar -xf cbmem.tar.gz
rm cbmem.tar.gz
chmod +x cbmem
# Grab logs necessary for debugging audio
if [ ! -z '$(pgrep pulseaudio)' ]
then
# Get logs from pipewire
systemctl --user stop pipewire.{socket,service}
systemctl --user stop pipewire-pulse.{socket,service}
if [ -z "$(which spa-acp-tool)" ]
then
printf 'spa-acp-tool not found. On distros using apt, install pipewire-bin\n'
touch no-spaacptool
fi
for card in $(grep '\[' /proc/asound/cards | awk '{print $1}')
do
echo "Pipewire card $card log:" >> audio-debug.log
spa-acp-tool -c $card -vvvv info &>> audio-debug.log
done
systemctl --user start pipewire.service
systemctl --user start pipewire-pulse.service
else
# Get logs from pulseaudio
systemctl --user stop pulseaudio.{socket,service}
echo "Pulseaudio log:" >> audio-debug.log
pulseaudio -v &>> audio-debug.log & sleep 5
killall pulseaudio
systemctl --user start pulseaudio.service
fi
# UCM logs
skip_ucm=0
if [ -z "$(which alsaucm)" ]
then
printf 'alsaucm not found. Please install alsa-utils.\n'
touch no-alsautils
skip_ucm=1
fi
if [ -z "$(which strace)" ]
then
printf 'strace not found. Please install strace.\n'
touch no-strace
skip_ucm=1
fi
if [ "$skip_ucm" = "0" ]
then
for card in $(grep '\[' /proc/asound/cards | awk '{print $1}')
do
echo "Alsa card $card UCM log:" >> alsa-ucm.log
strace alsaucm -c hw:$card reload &>> alsa-ucm.log
done
fi
lsmod > loaded-modules.log
find /lib/firmware > firmware.log
# grab journal on systemd distros
if [ ! -z "$(which journalctl)" ]
then
journalctl -b 0 > journal.log
fi
# Priviledge escalation [!!!]
{
sudo su <<EOF
# Grab logs and redirect output to files instead of stdout
dmesg >> dmesg.log
if [ -z "$(which lspci)" ]
then
printf 'lspci not found. Please install pciutils.\n'
touch no-lspci
else
lspci -vvvnn >> lspci.log
fi
if [ -z "$(which lsusb)" ]
then
printf 'lsusb not found. Please install usbutils.\n'
touch no-lsusb
else
lsusb -v >> lsusb.log
fi
if [ -z "$(which dmidecode)" ]
then
printf 'Dmidecode not found. Please install it.\n'
touch no-dmidecode
else
dmidecode >> dmidecode.log
fi
if [ -z "$(which libinput)" ]
then
printf 'libinput not found. Please install libinput utils.\n'
touch no-libinput
else
libinput list-devices >> libinput.log
fi
## Copy ACPI tables
mkdir acpi
cp /sys/firmware/acpi/tables/DSDT ./acpi/
cp /sys/firmware/acpi/tables/SSDT* ./acpi/
# Grab coreboot logs
./cbmem -c > cbmem.log
# Set file permissions for regular user
chown -R $user:$user *
chmod -R 755 *
EOF
} || {
echo "Error: Unable to gain root permission. Log archive will be incomplete!"
touch no-root
}
# Remove cbmem binary
rm cbmem
# Pack logs into archive and remove temporary folder that stores them
cd ..
tar -caf "$logarchive" "$logdir"
rm -r "$logdir"
printf "Log collection done.\nPlease upload ${logarchive} for analysis.\n"