]>
Commit | Line | Data |
---|---|---|
dbf6a266 | 1 | #!/bin/sh |
43bfd57e | 2 | # Copyright (c) 2004-2017 Apple Inc. |
edebe297 | 3 | # |
dbf6a266 A |
4 | # get-mobility-info |
5 | # | |
6 | # Collect system & network configuration information. | |
7 | # | |
8 | ||
dbf6a266 A |
9 | PATH=/bin:/usr/bin:/sbin:/usr/sbin |
10 | ||
43bfd57e A |
11 | OUTDIR="" |
12 | NO_PCAP=0 | |
13 | NO_TAR=0 | |
14 | ||
15 | while getopts f:PT OPTION ; do | |
16 | case ${OPTION} in | |
17 | f) | |
18 | OUTDIR="${OPTARG}" | |
19 | if [ ! -d "${OUTDIR}" ]; then | |
20 | echo "# ${PROGNAME}: \"${OUTDIR}\" is not a directory" | |
21 | exit 1 | |
22 | fi | |
23 | ;; | |
24 | P) | |
25 | NO_PCAP=1 | |
26 | ;; | |
27 | T) | |
28 | NO_TAR=1 | |
29 | ;; | |
30 | \?) | |
31 | ;; | |
32 | esac | |
33 | done | |
34 | ||
085a2e6a A |
35 | # |
36 | # Disclaimer | |
37 | # | |
38 | cat <<_END_OF_DISCLAIMER | |
39 | ||
40 | This diagnostic tool generates files that allow Apple to investigate issues | |
41 | with your computer and help Apple to improve its products. The generated files | |
42 | may contain some of your personal information, which may include, but not be | |
43 | limited to, the serial number or similar unique number for your device, your | |
44 | user name, or your computer name. The information is used by Apple in | |
45 | accordance with its privacy policy (www.apple.com/privacy) and is not shared | |
46 | with any third party. By enabling this diagnostic tool and sending a copy of | |
78403150 | 47 | the generated files to Apple, you are consenting to Apple's use of the content |
085a2e6a A |
48 | of such files. |
49 | ||
50 | _END_OF_DISCLAIMER | |
51 | ||
52 | /bin/echo "Press 'Enter' to continue." | |
53 | read reply | |
54 | ||
55 | # | |
56 | # Setup | |
57 | # | |
dbf6a266 A |
58 | PRIV="" |
59 | if [ ${EUID} -ne 0 ]; then | |
60 | PRIV="sudo" | |
61 | fi | |
62 | ||
5e9ce69e A |
63 | if [ -x /usr/bin/tail ]; then |
64 | TAIL_2000="/usr/bin/tail -n 2000" | |
65 | TAIL_25000="/usr/bin/tail -n 25000" | |
66 | else | |
67 | TAIL_2000="/bin/cat" | |
68 | TAIL_25000="/bin/cat" | |
69 | fi | |
70 | ||
9de8ab86 | 71 | OUT="mobility-info-`date +'%Y.%m.%d.%H%M%S'`" |
43bfd57e A |
72 | |
73 | if [ -z $OUTDIR ]; then | |
74 | OUTDIR="/var/tmp" | |
75 | if [ -d ~/Desktop ]; then | |
76 | OUTDIR=~/Desktop | |
77 | elif [ "`readlink /tmp`" = "private/var/tmp" ]; then | |
1ef45fa4 A |
78 | OUTDIR=/Library/Logs/DiagnosticReports |
79 | if [ ! -d /Library/Logs/DiagnosticReports -a -d /Library/Logs/CrashReporter ]; then | |
80 | OUTDIR=/Library/Logs/CrashReporter | |
81 | fi | |
43bfd57e A |
82 | mkdir -p ${OUTDIR} |
83 | fi | |
edebe297 A |
84 | fi |
85 | ||
86 | umask 077 | |
87 | ||
88 | WORKDIR=`mktemp -d -q "/tmp/${OUT}"` | |
89 | if [ $? -ne 0 ]; then | |
90 | echo "Could not create snapshot directory" | |
91 | exit 1 | |
92 | fi | |
93 | ||
43bfd57e A |
94 | if [ $NO_TAR -eq 0 ]; then |
95 | GZ_EXT="" | |
96 | GZ_OPT="" | |
97 | if [ -x /usr/bin/gzip ]; then | |
98 | GZ_EXT=".gz" | |
99 | GZ_OPT="-z" | |
100 | fi | |
a40a14f8 | 101 | |
43bfd57e A |
102 | ARCHIVE=`mktemp -q "${OUTDIR}/${OUT}.tar${GZ_EXT}"` |
103 | if [ $? -ne 0 ]; then | |
104 | echo "Could not create snapshot archive" | |
105 | rm -rf "${WORKDIR}" | |
106 | exit 1 | |
107 | fi | |
edebe297 A |
108 | fi |
109 | ||
110 | cd "${WORKDIR}" | |
dbf6a266 | 111 | |
17d3ee29 A |
112 | echo "" |
113 | echo "Please wait, collecting information and statistics" | |
114 | echo "" | |
115 | ||
43bfd57e A |
116 | # |
117 | # collect packet capture with kernel ring buffer if available | |
118 | # | |
1ef45fa4 A |
119 | stop_pcap () { |
120 | # | |
121 | # Stop the packet capture | |
122 | # | |
123 | if [ ${PCAP_STARTED} -ne 0 ]; then | |
124 | trap '' SIGINT | |
125 | /usr/local/bin/netdiagnose stop packetcapture 2>&1 | |
126 | PCAP_STARTED=0 | |
127 | fi | |
128 | } | |
129 | ||
130 | PCAP_STARTED=0 | |
43bfd57e | 131 | if [ -x /usr/local/bin/netdiagnose -a ${NO_PCAP} -ne 1 ]; then |
1ef45fa4 | 132 | trap stop_pcap SIGINT |
43bfd57e | 133 | /usr/local/bin/netdiagnose -p "${WORKDIR}" start packetcapture 2>&1 |
1ef45fa4 | 134 | PCAP_STARTED=1 |
43bfd57e A |
135 | fi |
136 | ||
5e9ce69e | 137 | # |
9de8ab86 | 138 | # get-network-info |
5e9ce69e | 139 | # |
9de8ab86 | 140 | if [ -x /System/Library/Frameworks/SystemConfiguration.framework/Resources/get-network-info ]; then |
f715d946 | 141 | /bin/sh /System/Library/Frameworks/SystemConfiguration.framework/Resources/get-network-info -s -c -P "${WORKDIR}" |
9de8ab86 | 142 | elif [ -x /System/Library/Frameworks/SystemConfiguration.framework/get-network-info ]; then |
f715d946 | 143 | /bin/sh /System/Library/Frameworks/SystemConfiguration.framework/get-network-info -s -c -P "${WORKDIR}" |
9de8ab86 | 144 | elif [ -x /System/Library/PrivateFrameworks/SystemConfiguration.framework/get-network-info ]; then |
f715d946 | 145 | /bin/sh /System/Library/PrivateFrameworks/SystemConfiguration.framework/get-network-info -s -c -P "${WORKDIR}" |
5e9ce69e A |
146 | fi |
147 | ||
dbf6a266 A |
148 | # |
149 | # processes | |
150 | # | |
5e9ce69e A |
151 | if [ -x /bin/ps ]; then |
152 | /bin/ps axlww > ps 2>&1 | |
153 | fi | |
dbf6a266 | 154 | |
edebe297 A |
155 | # |
156 | # AirPort info | |
157 | # | |
158 | if [ -x /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport ]; then | |
159 | /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport --getinfo \ | |
160 | > airport 2>&1 | |
161 | fi | |
162 | ||
5e9ce69e A |
163 | # |
164 | # collect wifi dump | |
165 | # | |
78403150 | 166 | if [ -x /usr/bin/wdutil -a -x /bin/ls ]; then |
5e9ce69e A |
167 | ${PRIV} /usr/bin/wdutil dump |
168 | mkdir -p "wifi_dump" | |
169 | /bin/ls -1 /private/tmp/wifi-* 2>/dev/null \ | |
170 | | while read log | |
171 | do | |
172 | if [ -f "${log}" ]; then | |
173 | b="`basename ${log}`" | |
174 | ${PRIV} cat "${log}" > "wifi_dump/${b}" 2>&1 | |
175 | fi | |
176 | done | |
177 | fi | |
178 | ||
dbf6a266 A |
179 | # |
180 | # OS info | |
181 | # | |
182 | if [ -e /System/Library/CoreServices/SystemVersion.plist ]; then | |
183 | cat /System/Library/CoreServices/SystemVersion.plist \ | |
edebe297 | 184 | > SystemVersion.plist 2>&1 |
dbf6a266 | 185 | fi |
dbf6a266 A |
186 | |
187 | # | |
188 | # IOKit info | |
189 | # | |
5e9ce69e A |
190 | if [ -x /usr/sbin/ioreg ]; then |
191 | /usr/sbin/ioreg -i -l -w 0 > ioreg 2>&1 | |
192 | /usr/sbin/ioreg -i -l -p IODeviceTree -w 0 >> ioreg 2>&1 | |
193 | fi | |
edebe297 | 194 | |
17d3ee29 A |
195 | # |
196 | # Power Management info | |
197 | # | |
5e9ce69e A |
198 | if [ -x /usr/bin/pmset ]; then |
199 | echo "#" > pmset | |
200 | echo "# pmset -g everything" >> pmset | |
201 | echo "#" >> pmset | |
202 | /usr/bin/pmset -g everything 2>/dev/null | ${TAIL_25000} >> pmset | |
203 | fi | |
17d3ee29 | 204 | |
dbf6a266 A |
205 | # |
206 | # Host configuration | |
207 | # | |
5e9ce69e A |
208 | if [ -x /usr/bin/hostinfo ]; then |
209 | /usr/bin/hostinfo > hostinfo 2>&1 | |
210 | fi | |
dbf6a266 | 211 | if [ -e /etc/hostconfig ]; then |
edebe297 | 212 | cat /etc/hostconfig > etc.hostconfig 2>&1 |
dbf6a266 A |
213 | fi |
214 | ||
dbf6a266 A |
215 | # |
216 | # System / network preferences | |
217 | # | |
218 | for f in \ | |
dbf6a266 A |
219 | /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist \ |
220 | /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist \ | |
a40a14f8 | 221 | /Library/Preferences/SystemConfiguration/com.apple.wifi.plist \ |
a40a14f8 | 222 | /Library/Preferences/com.apple.alf.plist \ |
dbf6a266 | 223 | /Library/Preferences/com.apple.sharing.firewall.plist \ |
6bb65964 | 224 | /Library/Preferences/com.apple.wwand.plist \ |
dbf6a266 A |
225 | |
226 | do | |
edebe297 A |
227 | if [ -e "${f}" ]; then |
228 | b="`basename ${f}`" | |
229 | cat "${f}" > "${b}" 2>&1 | |
dbf6a266 A |
230 | fi |
231 | done | |
232 | ||
9de8ab86 A |
233 | # |
234 | # Install log | |
235 | # | |
236 | if [ -e /var/log/install.log ]; then | |
237 | cat /var/log/install.log > install.log 2>&1 | |
238 | fi | |
239 | ||
5e9ce69e A |
240 | # |
241 | # System / network preferences (from other volumes) | |
242 | # | |
9de8ab86 | 243 | mount -t hfs | grep "/Volumes/" | sed -e 's:^.* on /Volumes/::' -e 's: ([^(]*$::' \ |
5e9ce69e A |
244 | | while read volume |
245 | do | |
246 | V_PATH="/Volumes/${volume}" | |
78403150 A |
247 | if [ -h "${V_PATH}" ]; then |
248 | # if the path is a symlink | |
249 | continue | |
250 | fi | |
9de8ab86 | 251 | |
5e9ce69e A |
252 | for f in \ |
253 | /Library/Preferences/SystemConfiguration/Networkinterfaces.plist \ | |
254 | /Library/Preferences/SystemConfiguration/preferences.plist \ | |
255 | ||
256 | do | |
257 | if [ -f "${V_PATH}/${f}" ]; then | |
258 | mkdir -p "OtherPreferences/${volume}" | |
259 | b="`basename ${f}`" | |
260 | cat "${V_PATH}/${f}" > "OtherPreferences/${volume}/${b}" 2>&1 | |
261 | fi | |
262 | done | |
263 | done | |
264 | ||
6bb65964 A |
265 | # |
266 | # InternetSharing | |
267 | # | |
268 | if [ -e /etc/bootpd.plist ]; then | |
269 | cat /etc/bootpd.plist > bootpd.plist 2>&1 | |
17d3ee29 | 270 | cat /etc/com.apple.named.proxy.conf > com.apple.named.proxy.conf 2>/dev/null |
6bb65964 A |
271 | elif [ -e /Library/Preferences/SystemConfiguration/bootpd.plist ]; then |
272 | cat /Library/Preferences/SystemConfiguration/bootpd.plist > bootpd.plist 2>&1 | |
17d3ee29 | 273 | cat /Library/Preferences/SystemConfiguration/com.apple.named.proxy.conf > com.apple.named.proxy.conf 2>/dev/null |
6bb65964 A |
274 | fi |
275 | ||
dbf6a266 A |
276 | # |
277 | # mounted filesystems | |
278 | # | |
edebe297 | 279 | mount > mounted-filesystems 2>&1 |
dbf6a266 | 280 | |
5e9ce69e | 281 | ${PRIV} cat /etc/hosts > etc.hosts 2>/dev/null |
dbf6a266 A |
282 | |
283 | # | |
284 | # kernel extensions statistic | |
285 | # | |
edebe297 | 286 | if [ -x /usr/sbin/kextstat ]; then |
5e9ce69e | 287 | /usr/sbin/kextstat > kextstat 2>&1 |
dbf6a266 A |
288 | fi |
289 | ||
6bb65964 A |
290 | if [ -x /sbin/pfctl ]; then |
291 | echo "#" > pf | |
292 | echo "# pfctl -s all" >> pf | |
293 | echo "#" >> pf | |
5e9ce69e | 294 | ${PRIV} /sbin/pfctl -s all >> pf 2>&1 |
6bb65964 A |
295 | echo "==============================" >> pf |
296 | echo "#" >> pf | |
297 | echo "# pfctl -s References" >> pf | |
298 | echo "#" >> pf | |
5e9ce69e | 299 | ${PRIV} /sbin/pfctl -s References >> pf 2>&1 |
17d3ee29 | 300 | for ANCHOR in `${PRIV} pfctl -s Anchors -v 2>/dev/null` |
6bb65964 A |
301 | do |
302 | echo "==============================" >> pf | |
303 | echo "#" >> pf | |
304 | echo "# pfctl -a ${ANCHOR} -s all" >> pf | |
305 | echo "#" >> pf | |
5e9ce69e | 306 | ${PRIV} /sbin/pfctl -a ${ANCHOR} -s all >> pf 2>&1 |
6bb65964 A |
307 | done |
308 | fi | |
edebe297 | 309 | |
78403150 A |
310 | # |
311 | # mach port info | |
312 | # | |
313 | if [ -x /usr/local/bin/lsmp ]; then | |
314 | ${PRIV} /usr/local/bin/lsmp -a -v > lsmp 2>&1 | |
315 | fi | |
316 | ||
317 | # | |
318 | # open files | |
319 | # | |
6bb65964 | 320 | if [ -x /usr/sbin/lsof ]; then |
afb19109 | 321 | ${PRIV} /usr/sbin/lsof +c 0 -n -O -P -T q > lsof 2>&1 & |
9de8ab86 A |
322 | LSOF_PID=$! |
323 | # Init a watchdog for lsof | |
324 | ( | |
325 | WAIT_TIME=5 | |
326 | while [ $WAIT_TIME -gt 0 ] | |
327 | do | |
328 | ${PRIV} kill -0 ${LSOF_PID} 2>/dev/null | |
329 | if [ $? -eq 0 ]; then | |
330 | sleep 1 | |
331 | # lsof is gathering data.. | |
332 | WAIT_TIME=$((WAIT_TIME-1)) | |
333 | continue | |
334 | fi | |
335 | ||
336 | # lsof completed gathering data | |
337 | break | |
338 | done | |
339 | ||
340 | if [ $WAIT_TIME -eq 0 ]; then | |
341 | # lsof timed out | |
342 | ${PRIV} kill ${LSOF_PID} 2>/dev/null | |
343 | fi | |
344 | ) & | |
78403150 A |
345 | fi |
346 | ||
347 | # | |
348 | # [lib]dispatch info | |
349 | # | |
350 | if [ -x /usr/local/bin/ddt ]; then | |
351 | /bin/echo -n "" > dispatch-info | |
352 | for BIN in \ | |
353 | configd \ | |
9de8ab86 | 354 | discoveryd \ |
78403150 A |
355 | |
356 | do | |
357 | echo "#" >> dispatch-info | |
358 | echo "# ddt -vkp ${BIN}" >> dispatch-info | |
359 | echo "#" >> dispatch-info | |
360 | ${PRIV} /usr/local/bin/ddt -vkp ${BIN} >> dispatch-info 2>&1 | |
361 | done | |
6bb65964 | 362 | fi |
edebe297 A |
363 | |
364 | # | |
78403150 | 365 | # OpenDirectory info |
edebe297 | 366 | # |
6bb65964 A |
367 | if [ -x /usr/bin/odutil ]; then |
368 | echo "#" > od-info | |
369 | echo "# odutil show all" >> od-info | |
370 | echo "#" >> od-info | |
5e9ce69e | 371 | ${PRIV} /usr/bin/odutil show all >> od-info 2>&1 |
edebe297 A |
372 | fi |
373 | ||
edebe297 A |
374 | # |
375 | # Kerberos configuration | |
376 | # | |
a40a14f8 A |
377 | if [ -x /usr/bin/klist ]; then |
378 | echo "#" > kerberos | |
5e9ce69e A |
379 | echo "# klist --verbose --all-content" >> kerberos |
380 | echo "#" >> kerberos | |
381 | klist --verbose --all-content >> kerberos 2>&1 | |
382 | ||
a40a14f8 | 383 | echo "#" >> kerberos |
5e9ce69e A |
384 | echo "# ktutil list" >> kerberos |
385 | echo "#" >> kerberos | |
386 | ${PRIV} /usr/sbin/ktutil --verbose list >> kerberos 2>&1 | |
edebe297 | 387 | |
a40a14f8 | 388 | echo "#" >> kerberos |
5e9ce69e | 389 | echo "# gsstool list --verbose" >> kerberos |
a40a14f8 | 390 | echo "#" >> kerberos |
5e9ce69e | 391 | /System/Library/PrivateFrameworks/Heimdal.framework/Helpers/gsstool list --verbose >> kerberos 2>&1 |
a40a14f8 | 392 | fi |
edebe297 A |
393 | |
394 | # | |
5e9ce69e | 395 | # system profiler |
edebe297 | 396 | # |
5e9ce69e A |
397 | if [ -x /usr/sbin/system_profiler ]; then |
398 | system_profiler -xml SPEthernetDataType \ | |
399 | SPFibreChannelDataType \ | |
400 | SPFireWireDataType \ | |
401 | SPFirewallDataType \ | |
402 | SPModemDataType \ | |
403 | SPNetworkDataType \ | |
404 | SPThunderboltDataType \ | |
405 | SPWWANDataType \ | |
406 | SPAirPortDataType > system_profiler.spx 2>/dev/null | |
407 | fi | |
6bb65964 | 408 | |
5e9ce69e A |
409 | # |
410 | # system usage statistics | |
411 | # | |
78403150 | 412 | /bin/echo -n "" > system-statistics |
6bb65964 | 413 | |
5e9ce69e A |
414 | if [ -x /usr/bin/uptime ]; then |
415 | echo "#" >> system-statistics | |
416 | echo "# uptime" >> system-statistics | |
417 | echo "#" >> system-statistics | |
418 | /usr/bin/uptime >> system-statistics 2>&1 | |
419 | fi | |
6bb65964 | 420 | |
5e9ce69e A |
421 | if [ -x /usr/sbin/sysctl ]; then |
422 | echo "#" >> system-statistics | |
78403150 | 423 | echo "# sysctl kern hw net debug" >> system-statistics |
5e9ce69e | 424 | echo "#" >> system-statistics |
78403150 | 425 | /usr/sbin/sysctl kern hw net debug >> system-statistics 2>&1 |
5e9ce69e | 426 | fi |
6bb65964 | 427 | |
5e9ce69e A |
428 | if [ -x /usr/bin/zprint ]; then |
429 | echo "#" >> system-statistics | |
430 | echo "# zprint" >> system-statistics | |
431 | echo "#" >> system-statistics | |
432 | ${PRIV} /usr/bin/zprint >> system-statistics 2>&1 | |
433 | fi | |
6bb65964 | 434 | |
78403150 A |
435 | if [ -x /usr/sbin/lsof -a -x /bin/ls ]; then |
436 | N=0 | |
437 | /bin/ls -1 /Library/Preferences/SystemConfiguration/*-lock \ | |
438 | 2>/dev/null \ | |
439 | | while read lock | |
440 | do | |
441 | if [ ${N} -eq 0 ]; then | |
442 | echo "#" >> system-statistics | |
443 | echo "# lsof [SCPreferences lock files]" >> system-statistics | |
444 | fi | |
445 | N=`expr ${N} + 1` | |
446 | ||
447 | echo "#" >> system-statistics | |
afb19109 | 448 | ${PRIV} /usr/sbin/lsof +c 0 -- ${lock} >> system-statistics 2>&1 |
78403150 A |
449 | done |
450 | fi | |
451 | ||
5e9ce69e A |
452 | # |
453 | # collect executable and plugin info | |
454 | # | |
455 | report_binary_info() | |
6bb65964 | 456 | { |
78403150 | 457 | if [ ! -f "${1}" ]; then |
5e9ce69e A |
458 | return |
459 | fi | |
17d3ee29 | 460 | |
78403150 | 461 | VERSION=`what "${1}"` |
5e9ce69e | 462 | echo "${VERSION}" >> versions 2>&1 |
17d3ee29 | 463 | |
78403150 | 464 | SUM=`sum "${1}"` |
5e9ce69e | 465 | echo "\tsum: ${SUM}" >> versions 2>&1 |
17d3ee29 | 466 | |
78403150 | 467 | LSINFO=`ls -lu "${1}"` |
5e9ce69e | 468 | echo "\tadditional info: ${LSINFO}" >> versions 2>&1 |
17d3ee29 | 469 | |
5e9ce69e | 470 | echo "" >> versions 2>&1 |
6bb65964 A |
471 | } |
472 | ||
5e9ce69e | 473 | get_binary_info() |
6bb65964 | 474 | { |
5e9ce69e A |
475 | for BIN in \ |
476 | /usr/libexec/bootpd \ | |
477 | /usr/libexec/configd \ | |
9de8ab86 | 478 | /usr/libexec/discoveryd \ |
5e9ce69e | 479 | /usr/sbin/awacsd \ |
b7ffbc6a | 480 | /usr/sbin/mDNSResponder \ |
5e9ce69e A |
481 | /usr/sbin/pppd \ |
482 | /usr/sbin/racoon \ | |
9de8ab86 A |
483 | /usr/libexec/misd \ |
484 | /usr/libexec/InternetSharing \ | |
5e9ce69e A |
485 | /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \ |
486 | ||
487 | do | |
488 | report_binary_info "${BIN}" | |
489 | done | |
490 | ||
78403150 A |
491 | if [ -x /usr/bin/xcode-select -a -x /usr/bin/xcodebuild -a -x /usr/bin/xcrun ]; then |
492 | SDKPATH="`xcode-select --print-path 2>/dev/null`" | |
493 | if [ $? -eq 0 -a -n "${SDKPATH}" ]; then | |
494 | /usr/bin/xcodebuild -showsdks 2>/dev/null \ | |
495 | | grep iphone \ | |
496 | | awk '{ print $NF }' \ | |
497 | | while read SDK | |
5e9ce69e | 498 | do |
78403150 | 499 | SDKPATH="`xcrun --sdk $SDK --show-sdk-path`" |
5e9ce69e A |
500 | for BIN in \ |
501 | /usr/libexec/configd_sim \ | |
502 | /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \ | |
6bb65964 | 503 | |
5e9ce69e A |
504 | do |
505 | report_binary_info "${SDKPATH}${BIN}" | |
506 | done | |
507 | done | |
78403150 A |
508 | else |
509 | echo "*** NO SDKs ***" >> versions | |
510 | echo "" >> versions | |
511 | fi | |
5e9ce69e | 512 | fi |
6bb65964 A |
513 | } |
514 | ||
5e9ce69e | 515 | get_plugins_info() |
6bb65964 | 516 | { |
5e9ce69e | 517 | num=0 |
78403150 | 518 | cd /System/Library/SystemConfiguration |
5e9ce69e A |
519 | for PLUGIN in *.bundle |
520 | do | |
78403150 | 521 | plugins[$num]="${PLUGIN}" |
5e9ce69e A |
522 | num=$(( $num + 1 )) |
523 | done | |
524 | ||
525 | cd "${WORKDIR}" | |
526 | ||
527 | for PLUGIN in "${plugins[@]}" | |
528 | do | |
78403150 A |
529 | PLUGIN_DIR="/System/Library/SystemConfiguration/${PLUGIN}" |
530 | PLUGIN_INF="${PLUGIN_DIR}/Contents/Info.plist" | |
531 | if [ ! -f "${PLUGIN_INF}" ]; then | |
532 | PLUGIN_INF="${PLUGIN_DIR}/Info.plist" | |
533 | if [ ! -f "${PLUGIN_INF}" ]; then | |
5e9ce69e A |
534 | echo "${PLUGIN_INF}: No Info.plist" >> versions 2>&1 |
535 | fi | |
6bb65964 | 536 | fi |
6bb65964 | 537 | |
5e9ce69e A |
538 | echo "${PLUGIN}" >> versions 2>&1 |
539 | ||
540 | ENABLED="Enabled" | |
78403150 | 541 | BOOL=`scutil --get "${PLUGIN_INF}" / Enabled 2>/dev/null` |
6bb65964 | 542 | if [ $? -eq 0 ]; then |
5e9ce69e A |
543 | if [ ${BOOL} = "TRUE" ]; then |
544 | ENABLED="Enabled*" | |
545 | else | |
546 | ENABLED="Disabled" | |
547 | fi | |
6bb65964 | 548 | fi |
5e9ce69e | 549 | echo "\t${ENABLED}" >> versions 2>&1 |
17d3ee29 | 550 | |
5e9ce69e | 551 | VERBOSE="" |
78403150 | 552 | BOOL=`scutil --get "${PLUGIN_INF}" / Verbose 2>/dev/null` |
5e9ce69e A |
553 | if [ $? -eq 0 ]; then |
554 | if [ ${BOOL} = "TRUE" ]; then | |
555 | VERBOSE="Verbose" | |
556 | fi | |
6bb65964 | 557 | fi |
5e9ce69e A |
558 | if [ -n "${VERBOSE}" ]; then |
559 | echo "\t${VERBOSE}" >> versions 2>&1 | |
6bb65964 | 560 | fi |
17d3ee29 | 561 | |
78403150 | 562 | VERSION=`scutil --get "${PLUGIN_INF}" / CFBundleVersion 2>/dev/null` |
5e9ce69e | 563 | if [ $? -eq 1 ]; then |
78403150 | 564 | VERSION=`scutil --get "${PLUGIN_INF}" / CFBundleShortVersionString 2>/dev/null` |
5e9ce69e A |
565 | fi |
566 | echo "\tVersion: ${VERSION}" >> versions 2>&1 | |
17d3ee29 | 567 | |
78403150 A |
568 | if [ -f "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}" ]; then |
569 | SUM=`sum "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}"` | |
5e9ce69e | 570 | echo "\tsum: ${SUM}" >> versions 2>&1 |
17d3ee29 | 571 | |
78403150 | 572 | LSINFO=`ls -lu "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}"` |
5e9ce69e | 573 | echo "\tadditional info: ${LSINFO}" >> versions 2>&1 |
78403150 A |
574 | elif [ -f "${PLUGIN_DIR}/${PLUGIN%.*}" ]; then |
575 | SUM=`sum "${PLUGIN_DIR}/${PLUGIN%.*}"` | |
5e9ce69e | 576 | echo "\tsum: ${SUM}" >> versions 2>&1 |
edebe297 | 577 | |
78403150 | 578 | LSINFO=`ls -lu "${PLUGIN_DIR}/${PLUGIN%.*}"` |
5e9ce69e | 579 | echo "\tadditional info: ${LSINFO}" >> versions 2>&1 |
edebe297 | 580 | fi |
17d3ee29 | 581 | |
5e9ce69e A |
582 | echo "" >> versions 2>&1 |
583 | done | |
584 | } | |
17d3ee29 | 585 | |
5e9ce69e A |
586 | if [ -x /usr/bin/what -a -x /usr/bin/sum -a -x /bin/ls ]; then |
587 | get_binary_info | |
588 | get_plugins_info | |
589 | fi | |
17d3ee29 | 590 | |
5e9ce69e | 591 | # |
942cecd7 A |
592 | # collect the logarchive |
593 | # | |
594 | if [ -x /usr/bin/log ]; then | |
595 | LOGARCHIVE_START_TIME=`date -v -1d +"%Y-%m-%d %H:%M:%S"` | |
596 | LOGARCHIVE_OUTPUT="system_logs.logarchive" | |
597 | ${PRIV} /usr/bin/log collect --livedata --output "${LOGARCHIVE_OUTPUT}" --start "${LOGARCHIVE_START_TIME}" 2>/dev/null | |
598 | if [ -d ${LOGARCHIVE_OUTPUT} ]; then | |
599 | ${PRIV} chown -R ${UID} "${LOGARCHIVE_OUTPUT}" | |
5e9ce69e A |
600 | fi |
601 | fi | |
6bb65964 | 602 | |
5e9ce69e | 603 | # |
942cecd7 | 604 | # dmesg |
5e9ce69e | 605 | # |
942cecd7 A |
606 | if [ -x /sbin/dmesg ]; then |
607 | ${PRIV} /sbin/dmesg > dmesg | |
5e9ce69e A |
608 | fi |
609 | ||
610 | # | |
611 | # ppp log file(s) | |
612 | # | |
613 | scutil <<_END_OF_INPUT \ | |
614 | | awk -F' *: *' \ | |
615 | ' \ | |
616 | /Logfile : / { \ | |
617 | if (index($2, "/") == 1) { print $2 } \ | |
618 | else { print "/var/log/ppp/" $2 } \ | |
619 | } \ | |
620 | END { \ | |
621 | print "/tmp/pppotcp.log" \ | |
622 | } \ | |
623 | ' \ | |
624 | | sort -u \ | |
625 | | while read logFile | |
6bb65964 | 626 | open |
5e9ce69e | 627 | show Setup:/Network/Service/[^/]+/PPP pattern |
6bb65964 A |
628 | quit |
629 | _END_OF_INPUT | |
630 | do | |
5e9ce69e A |
631 | if [ -f "${logFile}" ]; then |
632 | b="`basename ${logFile}`" | |
633 | cat "${logFile}" > "${b}" 2>&1 | |
634 | fi | |
edebe297 | 635 | done |
dbf6a266 | 636 | |
5e9ce69e A |
637 | if [ -x /bin/ls ]; then |
638 | # | |
639 | # collect crash reports | |
640 | # | |
641 | for daemon in \ | |
78403150 A |
642 | InternetSharing \ |
643 | SCHelper \ | |
644 | SCMonitor \ | |
645 | awacsd \ | |
5e9ce69e A |
646 | bootpd \ |
647 | configd \ | |
9de8ab86 A |
648 | discoveryd \ |
649 | discoveryd_helper \ | |
5e9ce69e | 650 | eapolclient \ |
b7ffbc6a A |
651 | mDNSResponder \ |
652 | mDNSResponderHelper \ | |
5e9ce69e A |
653 | pppd \ |
654 | racoon \ | |
655 | socketfilterfw \ | |
a40a14f8 | 656 | |
5e9ce69e A |
657 | do |
658 | /bin/ls -1 /Library/Logs/DiagnosticReports/${daemon}_*.crash \ | |
78403150 | 659 | /Library/Logs/DiagnosticReports/${daemon}_*.ips \ |
5e9ce69e | 660 | /Library/Logs/CrashReporter/${daemon}_*.crash \ |
78403150 | 661 | /Library/Logs/CrashReporter/${daemon}_*.ips \ |
5e9ce69e A |
662 | /Library/Logs/CrashReporter/${daemon}_*.plist \ |
663 | 2>/dev/null \ | |
664 | | while read log | |
665 | do | |
666 | if [ -f "${log}" ]; then | |
667 | b="`basename ${log}`" | |
668 | ${PRIV} cat "${log}" > "${b}" 2>&1 | |
669 | fi | |
670 | done | |
671 | done | |
17d3ee29 A |
672 | fi |
673 | ||
78403150 A |
674 | # |
675 | # stackshot | |
676 | # | |
677 | if [ -x /usr/local/bin/crstackshot ]; then | |
678 | /usr/local/bin/crstackshot 2>/dev/null | |
679 | fi | |
6bb65964 | 680 | |
9de8ab86 A |
681 | # |
682 | # wait for background activity (eg: lsof) | |
683 | # | |
684 | wait | |
685 | ||
dbf6a266 | 686 | # |
43bfd57e | 687 | # Stop the packet capture |
dbf6a266 | 688 | # |
1ef45fa4 | 689 | stop_pcap |
edebe297 | 690 | |
43bfd57e A |
691 | if [ $NO_TAR -eq 0 ]; then |
692 | # | |
693 | # collect everything into a single archive | |
694 | # | |
695 | cd "${WORKDIR}/.." | |
696 | tar -c ${GZ_OPT} -f "${ARCHIVE}" "${OUT}" | |
697 | rm -rf "${WORKDIR}" | |
698 | ||
699 | if [ ${UID} -eq 0 ]; then | |
700 | if [ -n "${SUDO_UID}" -a -n "${SUDO_GID}" ]; then | |
701 | if [ ${UID} -ne ${SUDO_UID} ]; then | |
702 | chown ${SUDO_UID}:${SUDO_GID} "${ARCHIVE}" | |
703 | fi | |
edebe297 A |
704 | fi |
705 | fi | |
dbf6a266 | 706 | |
43bfd57e A |
707 | echo "Network data collected to \"${ARCHIVE}\"" |
708 | else | |
709 | mv "${WORKDIR}" "${OUTDIR}" | |
a40a14f8 | 710 | |
43bfd57e A |
711 | if [ ${UID} -eq 0 ]; then |
712 | if [ -n "${SUDO_UID}" -a -n "${SUDO_GID}" ]; then | |
713 | if [ ${UID} -ne ${SUDO_UID} ]; then | |
714 | chown -R ${SUDO_UID}:${SUDO_GID} "${OUTDIR}/${OUT}" | |
715 | fi | |
716 | fi | |
717 | fi | |
718 | echo "Network data collected to \"${OUTDIR}/${OUT}\"" | |
719 | fi |