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