]> git.saurik.com Git - apple/configd.git/blame - get-mobility-info
configd-395.6.tar.gz
[apple/configd.git] / get-mobility-info
CommitLineData
dbf6a266 1#!/bin/sh
6bb65964 2# Copyright (c) 2004-2011 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
11PRIV=""
12if [ ${EUID} -ne 0 ]; then
13 PRIV="sudo"
14fi
15
edebe297
A
16OUT="mobility-info-`date +'%m.%d.%Y.%H%M%S'`"
17OUTDIR="/var/tmp"
18if [ -d ~/Desktop ]; then
19 OUTDIR=~/Desktop
a40a14f8
A
20elif [ "`readlink /tmp`" = "private/var/tmp" ]; then
21 OUTDIR=/Library/Logs/CrashReporter/SystemConfiguration
22 mkdir -p ${OUTDIR}
edebe297
A
23fi
24
25umask 077
26
27WORKDIR=`mktemp -d -q "/tmp/${OUT}"`
28if [ $? -ne 0 ]; then
29 echo "Could not create snapshot directory"
30 exit 1
31fi
32
a40a14f8
A
33GZ_EXT=""
34GZ_OPT=""
35if [ -x /usr/bin/gzip ]; then
36 GZ_EXT=".gz"
37 GZ_OPT="-z"
38fi
39
40ARCHIVE=`mktemp -q "${OUTDIR}/${OUT}.tar${GZ_EXT}"`
edebe297
A
41if [ $? -ne 0 ]; then
42 echo "Could not create snapshot archive"
43 rm -rf "${WORKDIR}"
44 exit 1
45fi
46
47cd "${WORKDIR}"
dbf6a266
A
48
49#
50# processes
51#
edebe297 52ps axlww > ps 2>&1
dbf6a266
A
53
54#
55# network interface configuration
56#
6bb65964
A
57ifconfig -a -L -b -m -r -v > ifconfig 2>&1
58if [ $? -ne 0 ]; then
59 ifconfig -a > ifconfig 2>&1
60fi
dbf6a266
A
61
62#
63# network route configuration
64#
edebe297 65netstat -n -r -a -l > netstat 2>&1
dbf6a266
A
66
67#
68# DHCP configuration
69#
70for if in `ifconfig -l`
71do
72 case ${if} in
73 lo* ) ;;
edebe297 74 en* ) ipconfig getpacket ${if} > ipconfig-${if} 2>&1
dbf6a266
A
75 ;;
76 esac
77done
78
edebe297
A
79#
80# AirPort info
81#
82if [ -x /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport ]; then
83 /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport --getinfo \
84 > airport 2>&1
85fi
86
dbf6a266
A
87#
88# OS info
89#
90if [ -e /System/Library/CoreServices/SystemVersion.plist ]; then
91 cat /System/Library/CoreServices/SystemVersion.plist \
edebe297 92 > SystemVersion.plist 2>&1
dbf6a266
A
93fi
94if [ -e /System/Library/CoreServices/ServerVersion.plist ]; then
95 cat /System/Library/CoreServices/ServerVersion.plist \
edebe297 96 > ServerVersion.plist 2>&1
dbf6a266
A
97fi
98
99#
100# IOKit info
101#
a40a14f8
A
102ioreg -i -l -w 0 > ioreg 2>&1
103ioreg -i -l -p IODeviceTree -w 0 >> ioreg 2>&1
edebe297
A
104
105#
106# Host name
107#
108hostname > hostname 2>&1
dbf6a266
A
109
110#
111# Host configuration
112#
edebe297 113hostinfo > hostinfo 2>&1
dbf6a266 114if [ -e /etc/hostconfig ]; then
edebe297 115 cat /etc/hostconfig > etc.hostconfig 2>&1
dbf6a266
A
116fi
117
118#
119# DNS configuration
120#
edebe297 121scutil --dns > dns-configuration 2>&1
dbf6a266 122if [ -e /etc/resolv.conf ]; then
edebe297 123 cat /etc/resolv.conf > etc.resolv.conf 2>&1
dbf6a266
A
124fi
125if [ -e /var/run/resolv.conf ]; then
edebe297 126 cat /var/run/resolv.conf > var.run.resolv.conf 2>&1
dbf6a266
A
127fi
128
129#
edebe297 130# Proxy configuration
dbf6a266 131#
edebe297 132scutil --proxy > proxy-configuration 2>&1
dbf6a266
A
133
134#
135# System / network preferences
136#
137for f in \
138 /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist \
139 /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist \
140 /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist \
141 /Library/Preferences/SystemConfiguration/com.apple.nat.plist \
edebe297
A
142 /Library/Preferences/SystemConfiguration/com.apple.network.identification.plist \
143 /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist \
a40a14f8 144 /Library/Preferences/SystemConfiguration/com.apple.wifi.plist \
dbf6a266 145 /Library/Preferences/SystemConfiguration/preferences.plist \
a40a14f8 146 /Library/Preferences/com.apple.alf.plist \
dbf6a266 147 /Library/Preferences/com.apple.sharing.firewall.plist \
6bb65964 148 /Library/Preferences/com.apple.wwand.plist \
dbf6a266
A
149
150do
edebe297
A
151 if [ -e "${f}" ]; then
152 b="`basename ${f}`"
153 cat "${f}" > "${b}" 2>&1
dbf6a266
A
154 fi
155done
156
6bb65964
A
157#
158# InternetSharing
159#
160if [ -e /etc/bootpd.plist ]; then
161 cat /etc/bootpd.plist > bootpd.plist 2>&1
162 cat /etc/com.apple.named.proxy.conf > com.apple.named.proxy.conf 2>&1
163elif [ -e /Library/Preferences/SystemConfiguration/bootpd.plist ]; then
164 cat /Library/Preferences/SystemConfiguration/bootpd.plist > bootpd.plist 2>&1
165 cat /Library/Preferences/SystemConfiguration/com.apple.named.proxy.conf > com.apple.named.proxy.conf 2>&1
166fi
167
dbf6a266
A
168#
169# configd's cache
170#
171${PRIV} scutil -p <<_END_OF_INPUT
172open
173snapshot
174quit
175_END_OF_INPUT
6bb65964
A
176if [ -f /var/tmp/configd-store.plist ]; then
177 cat /var/tmp/configd-store.plist > configd-store.plist 2>&1
dbf6a266 178fi
6bb65964
A
179if [ -f /var/tmp/configd-pattern.plist ]; then
180 cat /var/tmp/configd-pattern.plist > configd-pattern.plist 2>&1
dbf6a266 181fi
6bb65964
A
182if [ -f /var/tmp/configd-session.plist ]; then
183 cat /var/tmp/configd-session.plist > configd-session.plist 2>&1
edebe297
A
184fi
185if [ -f /var/tmp/configd-state ]; then
186 cat /var/tmp/configd-state > configd-state 2>&1
dbf6a266
A
187fi
188
6bb65964
A
189#
190# check configd's executable
191#
192if [ -x /usr/bin/codesign ]; then
193 echo "#" >> configd-state
194 echo "# codesign --verbose --display --entitlements - /usr/libexec/configd" >> configd-state
195 echo "#" >> configd-state
196 /usr/bin/codesign --verbose --display --entitlements - /usr/libexec/configd >> configd-state 2>&1
197
198 echo "#" >> configd-state
199 echo "# codesign --verbose --verify /usr/libexec/configd" >> configd-state
200 echo "#" >> configd-state
201 /usr/bin/codesign --verbose --verify /usr/libexec/configd >> configd-state 2>&1
202fi
203
dbf6a266
A
204#
205# network reachability
206#
edebe297 207scutil -d -v -r www.apple.com > reachability-info 2>&1
a40a14f8
A
208if [ -x /usr/bin/dig -a -f /etc/resolv.conf ]; then
209 /usr/bin/dig -t any -c any www.apple.com > dig-results 2>/dev/null
dbf6a266
A
210fi
211
212#
213# mounted filesystems
214#
edebe297 215mount > mounted-filesystems 2>&1
dbf6a266
A
216
217#
edebe297 218# mDNSResponder info
dbf6a266 219#
6bb65964
A
220if [ -x /usr/bin/killall ]; then
221 ${PRIV} killall -INFO mDNSResponder
222
223 # and wait a short amount of time for mDNSResponder
224 # to actually log the requested information
225 sleep 15
226fi
227
228#
229# awacsd info
230#
231if [ -x /usr/sbin/awacsd -a -x /usr/bin/killall ]; then
232 ${PRIV} killall -INFO awacsd 2>/dev/null
233
234 # and wait a short amount of time for awacsd
235 # to actually log the requested information
236 sleep 1
edebe297 237fi
dbf6a266
A
238
239#
a40a14f8
A
240# system log, kernel.log, early boot log messages
241#
242if [ -x /usr/bin/syslog ]; then
6bb65964 243 # save the recent activity
a40a14f8 244 ${PRIV} syslog | tail -n 25000 > syslog
6bb65964
A
245
246 # save just the "kernel" activity (in case some of the
247 # interesting/relevant message are before the messages
248 # captured above.
249 ${PRIV} syslog -k Facility kern | tail -n 25000 > kernel
250
a40a14f8 251 if [ -d /var/log/DiagnosticMessages ]; then
6bb65964 252 # save any MessageTracer activity
a40a14f8
A
253 ${PRIV} syslog -d /var/log/DiagnosticMessages \
254 -F raw \
255 -T local \
256 | tail -n 25000 > DiagnosticMessages
257 fi
258else
259 if [ -f /var/log/system.log ]; then
260 ${PRIV} tail -n 25000 /var/log/system.log > system.log
261 fi
262 if [ -f /var/log/kernel.log ]; then
263 ${PRIV} tail -n 25000 /var/log/kernel.log > kernel.log
264 fi
265fi
266${PRIV} dmesg > dmesg
267
268#
269# IPConfiguration log
dbf6a266 270#
a40a14f8
A
271if [ -f /var/log/com.apple.IPConfiguration.bootp ]; then
272 ${PRIV} tail -n 2000 /var/log/com.apple.IPConfiguration.bootp \
273 > com.apple.IPConfiguration.bootp
274fi
edebe297
A
275
276#
277# ppp log file(s)
278#
279scutil <<_END_OF_INPUT \
280| awk -F' *: *' \
281 ' \
282 /Logfile : / { \
283 if (index($2, "/") == 1) { print $2 } \
284 else { print "/var/log/ppp/" $2 } \
285 } \
286 END { \
287 print "/tmp/pppotcp.log" \
288 } \
289 ' \
290| sort -u \
291| while read logFile
292open
293show Setup:/Network/Service/[^/]+/PPP pattern
294quit
295_END_OF_INPUT
296do
297 if [ -f "${logFile}" ]; then
298 b="`basename ${logFile}`"
299 cat "${logFile}" > "${b}" 2>&1
a40a14f8 300 fi
edebe297
A
301done
302
303#
304# application firewall log
305#
306if [ -f /var/log/appfirewall.log ]; then
307 ${PRIV} tail -n 2000 /var/log/appfirewall.log > appfirewall.log
dbf6a266
A
308fi
309
310#
311# kernel extensions statistic
312#
edebe297
A
313if [ -x /usr/sbin/kextstat ]; then
314 kextstat > kextstat 2>&1
315elif [ -x /usr/sbin/kmodstat ]; then
316 kmodstat > kmodstat 2>&1
dbf6a266
A
317fi
318
319#
320# network statistics
321#
edebe297 322echo "#" > network-statistics
a40a14f8 323echo "# arp -n -a" >> network-statistics
edebe297 324echo "#" >> network-statistics
a40a14f8 325arp -n -a >> network-statistics 2>&1
edebe297
A
326
327echo "#" >> network-statistics
a40a14f8 328echo "# netstat -n -a -A" >> network-statistics
edebe297 329echo "#" >> network-statistics
a40a14f8
A
330netstat -n -a -A >> network-statistics 2>&1
331
edebe297
A
332echo "#" >> network-statistics
333echo "# netstat -s" >> network-statistics
334echo "#" >> network-statistics
335netstat -s >> network-statistics 2>&1
336
337echo "#" >> network-statistics
338echo "# netstat -mmm" >> network-statistics
339echo "#" >> network-statistics
340netstat -mmm >> network-statistics 2>&1
341
342echo "#" >> network-statistics
343echo "# netstat -i -n -d" >> network-statistics
344echo "#" >> network-statistics
345netstat -i -n -d >> network-statistics 2>&1
346
6bb65964 347if [ -x /usr/sbin/ndp ]; then
a40a14f8 348 echo "#" >> network-statistics
6bb65964 349 echo "# ndp -n -a" >> network-statistics
a40a14f8 350 echo "#" >> network-statistics
6bb65964 351 ndp -n -a >> network-statistics 2>&1
edebe297 352
a40a14f8 353 echo "#" >> network-statistics
6bb65964 354 echo "# ndp -n -p" >> network-statistics
a40a14f8 355 echo "#" >> network-statistics
6bb65964 356 ndp -n -p >> network-statistics 2>&1
dbf6a266 357
6bb65964
A
358 echo "#" >> network-statistics
359 echo "# ndp -n -r" >> network-statistics
360 echo "#" >> network-statistics
361 ndp -n -r >> network-statistics 2>&1
362fi
edebe297 363
6bb65964
A
364if [ -x /sbin/ipfw ]; then
365 echo "#" >> network-statistics
366 echo "# ipfw -at show" >> network-statistics
367 echo "#" >> network-statistics
368 ${PRIV} ipfw -at show >> network-statistics 2>&1
369fi
edebe297 370
6bb65964
A
371if [ -x /sbin/pfctl ]; then
372 echo "#" > pf
373 echo "# pfctl -s all" >> pf
374 echo "#" >> pf
375 ${PRIV} pfctl -s all >> pf 2>&1
376 echo "==============================" >> pf
377 echo "#" >> pf
378 echo "# pfctl -s References" >> pf
379 echo "#" >> pf
380 ${PRIV} pfctl -s References >> pf 2>&1
381 for ANCHOR in `pfctl -s Anchors 2>/dev/null`
382 do
383 echo "==============================" >> pf
384 echo "#" >> pf
385 echo "# pfctl -a ${ANCHOR} -s all" >> pf
386 echo "#" >> pf
387 ${PRIV} pfctl -a ${ANCHOR} -s all >> pf 2>&1
388 done
389fi
edebe297 390
6bb65964
A
391if [ -x /usr/sbin/lsof ]; then
392 echo "#" >> network-statistics
393 echo "# lsof -i -U -n -P" >> network-statistics
394 echo "#" >> network-statistics
395 ${PRIV} lsof -i -U -n -P >> network-statistics 2>&1
396fi
edebe297
A
397
398#
399# DirectoryService info
400#
6bb65964
A
401if [ -x /usr/bin/odutil ]; then
402 echo "#" > od-info
403 echo "# odutil show all" >> od-info
404 echo "#" >> od-info
405 ${PRIV} odutil show all >> od-info 2>&1
406elif [ -x /usr/bin/dscacheutil ]; then
edebe297
A
407 echo "#" > ds-info
408 echo "# dscacheutil -configuration" >> ds-info
409 echo "#" >> ds-info
410 dscacheutil -configuration >> ds-info 2>&1
411
412 echo "#" >> ds-info
413 echo "# dscacheutil -statistics" >> ds-info
414 echo "#" >> ds-info
415 dscacheutil -statistics >> ds-info 2>&1
416
417 echo "#" >> ds-info
418 echo "# dscacheutil -cachedump -entries" >> ds-info
419 echo "#" >> ds-info
420 dscacheutil -cachedump -entries >> ds-info 2>&1
421fi
422
423#
424# IPsec configuration
425#
426echo "#" > ipsec
427echo "# setkey -D" >> ipsec
428echo "#" >> ipsec
429${PRIV} setkey -D \
430| perl -nle '
431 if (/^(\s+[AE]:\s+\S+\s+)"?(.*)"?\s*$/) {
432 chop($sha1=`echo "$2" | openssl sha1`);
433 printf "%s[SHA-1:%s]\n", $1, $sha1;
434 } else {
435 printf "%s\n", $_;
436 }
437' >> ipsec
438
439echo "" >> ipsec
440echo "#" >> ipsec
441echo "# setkey -Pp -D" >> ipsec
442echo "#" >> ipsec
443${PRIV} setkey -Pp -D >> ipsec
444
a40a14f8 445for CF in /var/run/racoon/*.conf
edebe297 446do
a40a14f8
A
447 if [ ! -r "${CF}" ]; then
448 continue
449 fi
450
edebe297
A
451 echo "" >> ipsec
452 echo "#" >> ipsec
453 echo "# ${CF}" >> ipsec
454 echo "#" >> ipsec
455 ${PRIV} cat ${CF} \
456 | perl -nle '
457 if (/^(\s+shared_secret\s+use\s+)"?([^\s;"]+)"?(.*)/) {
458 chop($sha1=`echo "$2" | openssl sha1`);
459 printf "%s[SHA-1:%s]%s\n", $1, $sha1, $3;
460 } else {
461 printf "%s\n", $_;
462 }
463 ' >> ipsec
464done
465
466#
467# Kerberos configuration
468#
a40a14f8
A
469if [ -x /usr/bin/klist ]; then
470 echo "#" > kerberos
471 echo "# klist -e -c -A -f -a -n" >> kerberos
472 echo "#" >> kerberos
473 ${PRIV} klist -e -c -A -f -a -n >> kerberos 2>&1
edebe297 474
a40a14f8
A
475 echo "#" >> kerberos
476 echo "# klist -e -k -t -K" >> kerberos
477 echo "#" >> kerberos
478 ${PRIV} klist -e -k -t -K >> kerberos 2>&1
479fi
edebe297
A
480
481#
482# BTMM configuration
483#
6bb65964
A
484
485BTMM_CLEANUP()
edebe297 486{
6bb65964 487 rm -f .btmmfifo .btmminfo .digsync
edebe297
A
488}
489
6bb65964
A
490BTMM_SETUP()
491{
492 BTMM_CLEANUP
493 mkfifo .btmmfifo
494
495 BTMMPORT=40000
496 while nc -6z ::1 "${PORT}" > /dev/null 2>&1
497 do
498 BTMMPORT=$((PORT + 1))
499 done
500}
501
502BTMM_CHECKMACDOTCOM()
503{
504 TAIL=`echo "${1}" | cut -d. -f2-`
505 if [ "${TAIL}" = "members.mac.com" ]; then
506 return 0
507 fi
508
509 return 1
510}
511
512# get DNS info
513# params: QUERYNAME QUERYTYPE
514BTMM_DIG()
515{
516 rm -f .digsync
517
518 nc -6 -l "${BTMMPORT}" < .btmmfifo \
519 | openssl s_client -connect "${HOSTPORT}" -quiet > .btmmfifo 2>.digsync &
520
521 N_RETRY=0
522 while [ $N_RETRY -lt 50 -a ! -s .digsync ]
523 do
524 N_RETRY=$((N_RETRY + 1))
525 sleep 0.1
526 done
527
528 dig @::1 -p "${BTMMPORT}" \
529 -y "${TSIG}" \
530 +short \
531 +tcp \
532 "${1}" "${2}" 2>/dev/null
533
534 wait %1
535}
536
537# get the unique identifier used to lookup the keychain item for a zone
538# params: ZONE
539BTMM_UNIQUEIDFROMZONE()
540{
541 BTMM_CHECKMACDOTCOM "${1}"
542 if [ $? -eq 0 ]; then
543 echo "dns:${1}"
544 else
545 echo "btmmdns:${1}"
546 fi
547}
548
549# get hostname, port, TSIG name and TSIG data from keychain
550# params: UNIQUEID
551BTMM_GETINFO()
552{
553 ${PRIV} security find-generic-password \
554 -s "${1}" \
555 -g /Library/Keychains/System.keychain > .btmminfo 2>/dev/null
556 ${PRIV} security find-generic-password \
557 -s "${1}" \
558 -g /Library/Keychains/System.keychain \
559 2>&1 \
560 | sed -n 's/^password: \"\(.*\)\"$/\1/p'
561}
562
563# params: ZONE
564BTMM_URLISH()
565{
566 BTMM_CHECKMACDOTCOM "${1}"
567 if [ $? -eq 0 ]; then
568 echo "pm-members.mac.com.:443"
569 else
570 cat .btmminfo | sed -n 's/.*0x00000007 <blob>=\"\(.*\)\"/\1/p'
571 fi
572}
573
574BTMM_RELAYINFO()
575{
576 BTMM_CHECKMACDOTCOM "${1}"
577 if [ $? -eq 0 ]; then
578 return
579 fi
580
581 SECRET=`BTMM_GETINFO "btmmrelay:${1}"`
582
583 if [ -z "${SECRET}" ]; then
584 echo " No Relay keychain item." >> btmm
585 return
586 fi
587
588 if [ `echo "${SECRET}" | wc -l` -ne 1 ]; then
589 echo " More than one Relay keychain item." >> btmm
590 return
591 fi
592
593 URLISH=`BTMM_URLISH "${DOMAIN}"`
594 ACCOUNT=`cat .btmminfo | sed -n 's/.*\"acct\"<blob>=\"\(.*\)\"/\1/p'`
595 KEYHASH="[SHA-1:`echo ${SECRET} | openssl sha1`]"
596 echo " RHP: ${URLISH}" >> btmm
597 echo " RAC: ${ACCOUNT}" >> btmm
598 echo " RKY: ${KEYHASH}" >> btmm
599}
600
601BTMM_REPORTZONE()
602{
603 DOMAIN="${1}"
604
605 echo >> btmm
edebe297 606 echo "${DOMAIN}" >> btmm
6bb65964
A
607
608 DNSID=`BTMM_UNIQUEIDFROMZONE "${DOMAIN}"`
609 SECRET=`BTMM_GETINFO "${DNSID}"`
edebe297 610
6bb65964
A
611 if [ -z "${SECRET}" ]; then
612 echo " No DNS keychain item." >> btmm
613 return
edebe297 614 fi
6bb65964
A
615
616 if [ `echo "${SECRET}" | wc -l` -ne 1 ]; then
617 echo " More than one DNS keychain item." >> btmm
618 return
edebe297 619 fi
6bb65964
A
620
621 URLISH=`BTMM_URLISH "${DOMAIN}"`
622 HOSTPORT=`echo "${URLISH}" | cut -d@ -f2`
623 ACCOUNT=`cat .btmminfo | sed -n 's/.*\"acct\"<blob>=\"\(.*\)\"/\1/p'`
624 TSIG="${ACCOUNT}:${SECRET}"
edebe297 625
6bb65964 626 KEYHASH="[SHA-1:`echo ${SECRET} | openssl sha1`]"
a40a14f8 627 echo "" >> btmm
6bb65964
A
628 echo " DHP: ${URLISH}" >> btmm
629 echo " DAC: ${ACCOUNT}" >> btmm
630 echo " DKY: ${KEYHASH}" >> btmm
631
632 BTMM_RELAYINFO "${DOMAIN}"
a40a14f8 633
edebe297
A
634 for TYPE in \
635 _afpovertcp._tcp \
636 _airport._tcp \
637 _adisk._tcp \
a40a14f8 638 _http._tcp \
edebe297
A
639 _rfb._tcp \
640 _smb._tcp \
641 _ssh._tcp
642 do
6bb65964 643 BTMM_DIG "${TYPE}.${DOMAIN}" ptr \
edebe297
A
644 | while read -r REG
645 do
646 echo "" >> btmm
647 /bin/echo " ${REG}" >> btmm
648 echo "" >> btmm
649
650 INF_Q=`/bin/echo "${REG}" | sed -e "s/${TYPE}/_device-info._tcp/"`
6bb65964 651 INF=`BTMM_DIG "${INF_Q}" txt`
edebe297
A
652 echo " INF: ${INF}" >> btmm
653
6bb65964 654 SRV=`BTMM_DIG ${REG} srv`
edebe297
A
655 SRV1=`/bin/echo "${SRV}" | head -1`
656 echo " SRV: ${SRV1}" >> btmm
657 SRV2=`/bin/echo "${SRV}" | tail +2`
658 if [ -n "${SRV2}" ]; then
659 SRV="${SRV1}"
660 /bin/echo "${SRV2}" \
661 | sed -e 's/^/ *****: /' >> btmm
662 fi
663
6bb65964 664 TXT=`BTMM_DIG ${REG} txt`
edebe297
A
665 TXT1=`/bin/echo "${TXT}" | head -1`
666 echo " TXT: ${TXT1}" >> btmm
667 TXT2=`/bin/echo "${TXT}" | tail +2`
668 if [ -n "${TXT2}" ]; then
669 /bin/echo "${TXT2}" \
670 | sed -e 's/^/ *****: /' >> btmm
671 fi
672
673 HOST=`/bin/echo "${SRV}" | cut -d ' ' -f 4-`
a40a14f8 674 if [ -n "${HOST}" ]; then
6bb65964
A
675 V4=`BTMM_DIG ${HOST} a`
676 V6=`BTMM_DIG ${HOST} aaaa`
677 KRB=`BTMM_DIG _kerberos.${HOST} txt`
678 TUN=`BTMM_DIG _autotunnel._udp.${HOST} srv`
679 AT6=`BTMM_DIG _autotunnel6.${HOST} aaaa`
a40a14f8
A
680 else
681 V4=""
682 V6=""
683 KRB=""
684 TUN=""
547cd89f 685 AT6=""
a40a14f8 686 fi
edebe297
A
687 if [ -n "${V4}" ]; then
688 echo " v4: ${V4}" >> btmm
689 fi
edebe297
A
690 if [ -n "${V6}" ]; then
691 echo " v6: ${V6}" >> btmm
692 fi
547cd89f
A
693 if [ -n "${KRB}" ]; then
694 echo " KRB: ${KRB}" >> btmm
695 fi
a40a14f8 696 if [ -n "${TUN}" ]; then
547cd89f
A
697 echo " TUN: ${TUN}" >> btmm
698
699 HOST=`/bin/echo "${TUN}" | cut -d ' ' -f 4-`
a40a14f8 700 if [ -n "${HOST}" ]; then
6bb65964
A
701 V4=`BTMM_DIG ${HOST} a`
702 V6=`BTMM_DIG ${HOST} aaaa`
a40a14f8 703 fi
547cd89f
A
704 if [ -n "${V4}" ]; then
705 echo " v4: ${V4}" >> btmm
706 fi
707 if [ -n "${V6}" ]; then
708 echo " v6: ${V6}" >> btmm
709 fi
edebe297 710 fi
547cd89f
A
711 if [ -n "${AT6}" ]; then
712 echo " AT6: ${AT6}" >> btmm
a40a14f8 713 fi
edebe297
A
714 done
715 done
6bb65964
A
716}
717
718BTMM_SETUP
719
720scutil <<_END_OF_INPUT \
721| sed -n 's@.* : *\(.*\)$@\1@p' \
722| sort \
723| while read DOMAIN
724open
725show Setup:/Network/BackToMyMac
726quit
727_END_OF_INPUT
728do
729 BTMM_REPORTZONE "$DOMAIN"
edebe297 730done
dbf6a266 731
6bb65964
A
732BTMM_CLEANUP
733
dbf6a266
A
734#
735# collect crash reports
736#
a40a14f8
A
737for daemon in \
738 bootpd \
739 configd \
740 eapolclient \
741 mDNSResponder \
742 mDNSResponderHelper \
6bb65964 743 awacsd \
a40a14f8
A
744 pppd \
745 racoon \
746 socketfilterfw \
747 SCHelper \
748 SCMonitor \
749
dbf6a266 750do
6bb65964
A
751 /bin/ls -1 /Library/Logs/DiagnosticReports/${daemon}_*.crash \
752 /Library/Logs/CrashReporter/${daemon}_*.crash \
a40a14f8 753 2>/dev/null \
edebe297
A
754 | while read log
755 do
6bb65964
A
756 if [ -f "${log}" ]; then
757 b="`basename ${log}`"
758 ${PRIV} cat "${log}" > "${b}" 2>&1
759 fi
edebe297 760 done
dbf6a266
A
761done
762
6bb65964
A
763#
764# system usage statistics
765#
766echo "#" > system-statistics
767echo "# uptime" >> system-statistics
768echo "#" >> system-statistics
769uptime >> system-statistics 2>&1
770
771echo "#" >> system-statistics
772echo "# sysctl -a" >> system-statistics
773echo "#" >> system-statistics
774sysctl -a >> system-statistics 2>&1
775
776echo "#" >> system-statistics
777echo "# zprint" >> system-statistics
778echo "#" >> system-statistics
779zprint >> system-statistics 2>&1
780
781echo "#" >> system-statistics
782echo "# top -l5 -s2" >> system-statistics
783echo "#" >> system-statistics
784echo ""
785echo "Please wait, collecting statistics"
786echo ""
787top -s 2 -l 5 >> system-statistics 2>&1
788
dbf6a266
A
789#
790# collect everything into a single archive
791#
edebe297 792cd "${WORKDIR}/.."
6bb65964
A
793if [ -x /usr/bin/tar ]; then
794 tar -c ${GZ_OPT} -f "${ARCHIVE}" "${OUT}"
795else
796 pax -w ${GZ_OPT} -f "${ARCHIVE}" "${OUT}"
797fi
edebe297
A
798rm -rf "${WORKDIR}"
799
800if [ ${UID} -eq 0 ]; then
801 if [ -n "${SUDO_UID}" -a -n "${SUDO_GID}" ]; then
802 if [ ${UID} -ne ${SUDO_UID} ]; then
803 chown ${SUDO_UID}:${SUDO_GID} "${ARCHIVE}"
804 fi
805 fi
806fi
dbf6a266 807
edebe297 808echo "Network data collected to \"${ARCHIVE}\""
a40a14f8
A
809
810#
811# if requested, generate a crash report
812#
813if [ "${OUTDIR}" = "/Library/Logs/CrashReporter/SystemConfiguration" -a "${1}" = "CRASH" ]; then
814 kill -ABRT $$
815fi
816