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