-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht2-info-tool.sh
More file actions
executable file
·193 lines (147 loc) · 4.05 KB
/
Copy patht2-info-tool.sh
File metadata and controls
executable file
·193 lines (147 loc) · 4.05 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/usr/bin/env sh
# Information Collection Tool for T2 Macs
set -eu
# shellcheck disable=SC3040
if ! (set -o pipefail > /dev/null 2>&1)
then
echo Warning: pipefail is not supported by your shell, it will not be enabled
else
# shellcheck disable=SC3040
set -o pipefail
fi
# Helpers
mkcdir() {
mkdir "$1"
cd "$1"
}
temp_dir="$(mktemp -d)"
distro="$(sed -n 's/PRETTY_NAME="\(.*\)"/\1/p' /etc/os-release)"
model="$(cat /sys/class/dmi/id/product_name)"
kernel_ver="$(uname -r)"
firmware_dir="/lib/firmware/"
udev_rules_dir="/usr/lib/udev/rules.d/"
session_type="unknown"
if command -v loginctl > /dev/null
then
session_type="$(loginctl show-session "$(loginctl | grep "$(whoami)" | sed "s/[[:blank:]]*\([0-9]*\) .*/\1/")" -p Type | cut -d = -f 2)"
fi
audio_config_dir=""
sound_server="none"
mbpfan_installed="no"
if command -v mbpfan > /dev/null
then
mbpfan_installed="yes"
fi
for server in "pipewire" "pulseaudio"
do
if path="$(command -v "$server")"
then
sound_server="$path"
break
fi
done
case "$sound_server" in
*pipewire)
audio_config_dir="/usr/share/alsa-card-profile/mixer/";;
*pulseaudio)
audio_config_dir="/usr/share/pulseaudio/alsa-mixer/";;
esac
for logger in "journalctl" "dmesg"
do
if command -v "$logger" > /dev/null
then
kernel_logger="$logger"
break
fi
done
case "$logger" in
journalctl)
kernel_logger_find="journalctl -kb -g";;
dmesg)
kernel_logger_find="dmesg | grep";;
esac
case "$distro" in
NixOS*)
firmware_dir="/run/current-system/firmware/"
udev_rules_dir="/etc/udev/rules.d/"
case "$sound_server" in
*pipewire)
audio_config_dir="$(ldd "$sound_server" | sed -n 's/[[:blank:]]*libpipewire.*=>[[:blank:]]*\(.*\)\/lib\/libpipewire.* (.*)/\1/p')/share/alsa-card-profile/mixer/";;
*pulseaudio)
audio_config_dir="$(dirname "$sound_server" | xargs dirname)/share/pulseaudio/alsa-mixer/";;
esac
# shellcheck disable=SC2016
path="$(nix shell nixpkgs\#pciutils nixpkgs\#usbutils -c sh -c 'echo $PATH' || nix-shell -p pciutils usbutils --run 'echo $PATH' || true)"
if [ -n "$path" ]
then
export PATH="$path"
fi;;
esac
cd "$temp_dir"
mkcdir result
# General information
echo "\
Distribution: $distro
Model: $model
Kernel Version: $kernel_ver
Sound Server: $sound_server
Audio Configuration Directory: $audio_config_dir
Firmware Directory: $firmware_dir
Udev Rules Directory: $udev_rules_dir
Kernel Logger: $kernel_logger
Session Type: $session_type
Mbpfan Installed: $mbpfan_installed" > info.txt
# Kernel logs
mkcdir kernel_logs
for i in "brcmfmac" "hci0" "apple-ib" "bce.vhci" "apple.bce" "aaudio" "apple.gmux" "amdgpu" "i915"
do
if out="$($kernel_logger_find $i: 2>&1 || true)"
then
echo "$out" > $i.txt
fi
done
cd .. # kernel_logs
# Audio related stuff
mkcdir audio
cat /proc/asound/cards > asound-cards.txt
ls "$udev_rules_dir" > udev-rule-list.txt
case "$sound_server" in
*pipewire)
pw-dump > pw-dump.txt
if command -v wireplumber > /dev/null
then
wpctl status > wpctl-status.txt
fi;;
*pulseaudio)
pactl info > pactl-info.txt
pactl list > pactl-list.txt;;
esac
if [ -d "$audio_config_dir" ]
then
mkcdir files
find "$audio_config_dir" -name "*t2*" -exec cp {} . ';'
cd .. # files
fi
cd .. # audio
# Installed firmware
mkcdir firmware
# shellcheck disable=SC2043
for i in "brcm"
do
sha256sum $firmware_dir/$i/* > $i.txt
done
cd .. # firmware
mkcdir misc
for command in "dkms status" "lspci -k" "lsusb -vv" "lsmod" "systemctl status bluetooth" "ip link" "mount" "rfkill" "lsblk"
do
if command -v "$(echo "$command" | cut -d " " -f 1)" > /dev/null
then
name="$(echo "$command" | sed "s/ /_/g")"
mkdir "$name"
$command > "$name/stdout.txt" 2> "$name/stderr.txt" || true
fi
done
cd .. # misc
cd .. # result
tar cf result.tar.gz result
echo Your report is in "$temp_dir/result.tar.gz"