]> git.saurik.com Git - apple/configd.git/blob - get-mobility-info
adc3d6a3805d6194b9f41ed1207364fba9d43080
[apple/configd.git] / get-mobility-info
1 #!/bin/sh
2 # Copyright (c) 2004-2011 Apple Inc.
3 #
4 # get-mobility-info
5 #
6 # Collect system & network configuration information.
7 #
8
9 PATH=/bin:/usr/bin:/sbin:/usr/sbin
10
11 PRIV=""
12 if [ ${EUID} -ne 0 ]; then
13 PRIV="sudo"
14 fi
15
16 OUT="mobility-info-`date +'%m.%d.%Y.%H%M%S'`"
17 OUTDIR="/var/tmp"
18 if [ -d ~/Desktop ]; then
19 OUTDIR=~/Desktop
20 elif [ "`readlink /tmp`" = "private/var/tmp" ]; then
21 OUTDIR=/Library/Logs/CrashReporter/SystemConfiguration
22 mkdir -p ${OUTDIR}
23 fi
24
25 umask 077
26
27 WORKDIR=`mktemp -d -q "/tmp/${OUT}"`
28 if [ $? -ne 0 ]; then
29 echo "Could not create snapshot directory"
30 exit 1
31 fi
32
33 GZ_EXT=""
34 GZ_OPT=""
35 if [ -x /usr/bin/gzip ]; then
36 GZ_EXT=".gz"
37 GZ_OPT="-z"
38 fi
39
40 ARCHIVE=`mktemp -q "${OUTDIR}/${OUT}.tar${GZ_EXT}"`
41 if [ $? -ne 0 ]; then
42 echo "Could not create snapshot archive"
43 rm -rf "${WORKDIR}"
44 exit 1
45 fi
46
47 cd "${WORKDIR}"
48
49 #
50 # processes
51 #
52 ps axlww > ps 2>&1
53
54 #
55 # network interface configuration
56 #
57 ifconfig -a -L -b -m -r -v > ifconfig 2>&1
58 if [ $? -ne 0 ]; then
59 ifconfig -a > ifconfig 2>&1
60 fi
61
62 #
63 # network route configuration
64 #
65 netstat -n -r -a -l > netstat 2>&1
66
67 #
68 # DHCP configuration
69 #
70 for if in `ifconfig -l`
71 do
72 case ${if} in
73 lo* ) ;;
74 en* ) ipconfig getpacket ${if} > ipconfig-${if} 2>&1
75 ;;
76 esac
77 done
78
79 #
80 # AirPort info
81 #
82 if [ -x /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport ]; then
83 /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport --getinfo \
84 > airport 2>&1
85 fi
86
87 #
88 # OS info
89 #
90 if [ -e /System/Library/CoreServices/SystemVersion.plist ]; then
91 cat /System/Library/CoreServices/SystemVersion.plist \
92 > SystemVersion.plist 2>&1
93 fi
94 if [ -e /System/Library/CoreServices/ServerVersion.plist ]; then
95 cat /System/Library/CoreServices/ServerVersion.plist \
96 > ServerVersion.plist 2>&1
97 fi
98
99 #
100 # IOKit info
101 #
102 ioreg -i -l -w 0 > ioreg 2>&1
103 ioreg -i -l -p IODeviceTree -w 0 >> ioreg 2>&1
104
105 #
106 # Host name
107 #
108 hostname > hostname 2>&1
109
110 #
111 # Host configuration
112 #
113 hostinfo > hostinfo 2>&1
114 if [ -e /etc/hostconfig ]; then
115 cat /etc/hostconfig > etc.hostconfig 2>&1
116 fi
117
118 #
119 # DNS configuration
120 #
121 scutil --dns > dns-configuration 2>&1
122 if [ -e /etc/resolv.conf ]; then
123 cat /etc/resolv.conf > etc.resolv.conf 2>&1
124 fi
125 if [ -e /var/run/resolv.conf ]; then
126 cat /var/run/resolv.conf > var.run.resolv.conf 2>&1
127 fi
128
129 #
130 # Proxy configuration
131 #
132 scutil --proxy > proxy-configuration 2>&1
133
134 #
135 # System / network preferences
136 #
137 for 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 \
142 /Library/Preferences/SystemConfiguration/com.apple.network.identification.plist \
143 /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist \
144 /Library/Preferences/SystemConfiguration/com.apple.wifi.plist \
145 /Library/Preferences/SystemConfiguration/preferences.plist \
146 /Library/Preferences/com.apple.alf.plist \
147 /Library/Preferences/com.apple.sharing.firewall.plist \
148 /Library/Preferences/com.apple.wwand.plist \
149
150 do
151 if [ -e "${f}" ]; then
152 b="`basename ${f}`"
153 cat "${f}" > "${b}" 2>&1
154 fi
155 done
156
157 #
158 # InternetSharing
159 #
160 if [ -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
163 elif [ -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
166 fi
167
168 #
169 # configd's cache
170 #
171 ${PRIV} scutil -p <<_END_OF_INPUT
172 open
173 snapshot
174 quit
175 _END_OF_INPUT
176 if [ -f /var/tmp/configd-store.plist ]; then
177 cat /var/tmp/configd-store.plist > configd-store.plist 2>&1
178 fi
179 if [ -f /var/tmp/configd-pattern.plist ]; then
180 cat /var/tmp/configd-pattern.plist > configd-pattern.plist 2>&1
181 fi
182 if [ -f /var/tmp/configd-session.plist ]; then
183 cat /var/tmp/configd-session.plist > configd-session.plist 2>&1
184 fi
185 if [ -f /var/tmp/configd-state ]; then
186 cat /var/tmp/configd-state > configd-state 2>&1
187 fi
188
189 #
190 # check configd's executable
191 #
192 if [ -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
202 fi
203
204 #
205 # network reachability
206 #
207 scutil -d -v -r www.apple.com > reachability-info 2>&1
208 if [ -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
210 fi
211
212 #
213 # mounted filesystems
214 #
215 mount > mounted-filesystems 2>&1
216
217 #
218 # mDNSResponder info
219 #
220 if [ -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
226 fi
227
228 #
229 # awacsd info
230 #
231 if [ -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
237 fi
238
239 #
240 # system log, kernel.log, early boot log messages
241 #
242 if [ -x /usr/bin/syslog ]; then
243 # save the recent activity
244 ${PRIV} syslog | tail -n 25000 > syslog
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
251 if [ -d /var/log/DiagnosticMessages ]; then
252 # save any MessageTracer activity
253 ${PRIV} syslog -d /var/log/DiagnosticMessages \
254 -F raw \
255 -T local \
256 | tail -n 25000 > DiagnosticMessages
257 fi
258 else
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
265 fi
266 ${PRIV} dmesg > dmesg
267
268 #
269 # IPConfiguration log
270 #
271 if [ -f /var/log/com.apple.IPConfiguration.bootp ]; then
272 ${PRIV} tail -n 2000 /var/log/com.apple.IPConfiguration.bootp \
273 > com.apple.IPConfiguration.bootp
274 fi
275
276 #
277 # ppp log file(s)
278 #
279 scutil <<_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
292 open
293 show Setup:/Network/Service/[^/]+/PPP pattern
294 quit
295 _END_OF_INPUT
296 do
297 if [ -f "${logFile}" ]; then
298 b="`basename ${logFile}`"
299 cat "${logFile}" > "${b}" 2>&1
300 fi
301 done
302
303 #
304 # application firewall log
305 #
306 if [ -f /var/log/appfirewall.log ]; then
307 ${PRIV} tail -n 2000 /var/log/appfirewall.log > appfirewall.log
308 fi
309
310 #
311 # kernel extensions statistic
312 #
313 if [ -x /usr/sbin/kextstat ]; then
314 kextstat > kextstat 2>&1
315 elif [ -x /usr/sbin/kmodstat ]; then
316 kmodstat > kmodstat 2>&1
317 fi
318
319 #
320 # network statistics
321 #
322 echo "#" > network-statistics
323 echo "# arp -n -a" >> network-statistics
324 echo "#" >> network-statistics
325 arp -n -a >> network-statistics 2>&1
326
327 echo "#" >> network-statistics
328 echo "# netstat -n -a -A" >> network-statistics
329 echo "#" >> network-statistics
330 netstat -n -a -A >> network-statistics 2>&1
331
332 echo "#" >> network-statistics
333 echo "# netstat -s" >> network-statistics
334 echo "#" >> network-statistics
335 netstat -s >> network-statistics 2>&1
336
337 echo "#" >> network-statistics
338 echo "# netstat -mmm" >> network-statistics
339 echo "#" >> network-statistics
340 netstat -mmm >> network-statistics 2>&1
341
342 echo "#" >> network-statistics
343 echo "# netstat -i -n -d" >> network-statistics
344 echo "#" >> network-statistics
345 netstat -i -n -d >> network-statistics 2>&1
346
347 if [ -x /usr/sbin/ndp ]; then
348 echo "#" >> network-statistics
349 echo "# ndp -n -a" >> network-statistics
350 echo "#" >> network-statistics
351 ndp -n -a >> network-statistics 2>&1
352
353 echo "#" >> network-statistics
354 echo "# ndp -n -p" >> network-statistics
355 echo "#" >> network-statistics
356 ndp -n -p >> network-statistics 2>&1
357
358 echo "#" >> network-statistics
359 echo "# ndp -n -r" >> network-statistics
360 echo "#" >> network-statistics
361 ndp -n -r >> network-statistics 2>&1
362 fi
363
364 if [ -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
369 fi
370
371 if [ -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
389 fi
390
391 if [ -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
396 fi
397
398 #
399 # DirectoryService info
400 #
401 if [ -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
406 elif [ -x /usr/bin/dscacheutil ]; then
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
421 fi
422
423 #
424 # IPsec configuration
425 #
426 echo "#" > ipsec
427 echo "# setkey -D" >> ipsec
428 echo "#" >> 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
439 echo "" >> ipsec
440 echo "#" >> ipsec
441 echo "# setkey -Pp -D" >> ipsec
442 echo "#" >> ipsec
443 ${PRIV} setkey -Pp -D >> ipsec
444
445 for CF in /var/run/racoon/*.conf
446 do
447 if [ ! -r "${CF}" ]; then
448 continue
449 fi
450
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
464 done
465
466 #
467 # Kerberos configuration
468 #
469 if [ -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
474
475 echo "#" >> kerberos
476 echo "# klist -e -k -t -K" >> kerberos
477 echo "#" >> kerberos
478 ${PRIV} klist -e -k -t -K >> kerberos 2>&1
479 fi
480
481 #
482 # BTMM configuration
483 #
484
485 BTMM_CLEANUP()
486 {
487 rm -f .btmmfifo .btmminfo .digsync
488 }
489
490 BTMM_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
502 BTMM_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
514 BTMM_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
539 BTMM_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
551 BTMM_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
564 BTMM_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
574 BTMM_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
601 BTMM_REPORTZONE()
602 {
603 DOMAIN="${1}"
604
605 echo >> btmm
606 echo "${DOMAIN}" >> btmm
607
608 DNSID=`BTMM_UNIQUEIDFROMZONE "${DOMAIN}"`
609 SECRET=`BTMM_GETINFO "${DNSID}"`
610
611 if [ -z "${SECRET}" ]; then
612 echo " No DNS keychain item." >> btmm
613 return
614 fi
615
616 if [ `echo "${SECRET}" | wc -l` -ne 1 ]; then
617 echo " More than one DNS keychain item." >> btmm
618 return
619 fi
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}"
625
626 KEYHASH="[SHA-1:`echo ${SECRET} | openssl sha1`]"
627 echo "" >> btmm
628 echo " DHP: ${URLISH}" >> btmm
629 echo " DAC: ${ACCOUNT}" >> btmm
630 echo " DKY: ${KEYHASH}" >> btmm
631
632 BTMM_RELAYINFO "${DOMAIN}"
633
634 for TYPE in \
635 _afpovertcp._tcp \
636 _airport._tcp \
637 _adisk._tcp \
638 _http._tcp \
639 _rfb._tcp \
640 _smb._tcp \
641 _ssh._tcp
642 do
643 BTMM_DIG "${TYPE}.${DOMAIN}" ptr \
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/"`
651 INF=`BTMM_DIG "${INF_Q}" txt`
652 echo " INF: ${INF}" >> btmm
653
654 SRV=`BTMM_DIG ${REG} srv`
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
664 TXT=`BTMM_DIG ${REG} txt`
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-`
674 if [ -n "${HOST}" ]; then
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`
680 else
681 V4=""
682 V6=""
683 KRB=""
684 TUN=""
685 AT6=""
686 fi
687 if [ -n "${V4}" ]; then
688 echo " v4: ${V4}" >> btmm
689 fi
690 if [ -n "${V6}" ]; then
691 echo " v6: ${V6}" >> btmm
692 fi
693 if [ -n "${KRB}" ]; then
694 echo " KRB: ${KRB}" >> btmm
695 fi
696 if [ -n "${TUN}" ]; then
697 echo " TUN: ${TUN}" >> btmm
698
699 HOST=`/bin/echo "${TUN}" | cut -d ' ' -f 4-`
700 if [ -n "${HOST}" ]; then
701 V4=`BTMM_DIG ${HOST} a`
702 V6=`BTMM_DIG ${HOST} aaaa`
703 fi
704 if [ -n "${V4}" ]; then
705 echo " v4: ${V4}" >> btmm
706 fi
707 if [ -n "${V6}" ]; then
708 echo " v6: ${V6}" >> btmm
709 fi
710 fi
711 if [ -n "${AT6}" ]; then
712 echo " AT6: ${AT6}" >> btmm
713 fi
714 done
715 done
716 }
717
718 BTMM_SETUP
719
720 scutil <<_END_OF_INPUT \
721 | sed -n 's@.* : *\(.*\)$@\1@p' \
722 | sort \
723 | while read DOMAIN
724 open
725 show Setup:/Network/BackToMyMac
726 quit
727 _END_OF_INPUT
728 do
729 BTMM_REPORTZONE "$DOMAIN"
730 done
731
732 BTMM_CLEANUP
733
734 #
735 # collect crash reports
736 #
737 for daemon in \
738 bootpd \
739 configd \
740 eapolclient \
741 mDNSResponder \
742 mDNSResponderHelper \
743 awacsd \
744 pppd \
745 racoon \
746 socketfilterfw \
747 SCHelper \
748 SCMonitor \
749
750 do
751 /bin/ls -1 /Library/Logs/DiagnosticReports/${daemon}_*.crash \
752 /Library/Logs/CrashReporter/${daemon}_*.crash \
753 2>/dev/null \
754 | while read log
755 do
756 if [ -f "${log}" ]; then
757 b="`basename ${log}`"
758 ${PRIV} cat "${log}" > "${b}" 2>&1
759 fi
760 done
761 done
762
763 #
764 # system usage statistics
765 #
766 echo "#" > system-statistics
767 echo "# uptime" >> system-statistics
768 echo "#" >> system-statistics
769 uptime >> system-statistics 2>&1
770
771 echo "#" >> system-statistics
772 echo "# sysctl -a" >> system-statistics
773 echo "#" >> system-statistics
774 sysctl -a >> system-statistics 2>&1
775
776 echo "#" >> system-statistics
777 echo "# zprint" >> system-statistics
778 echo "#" >> system-statistics
779 zprint >> system-statistics 2>&1
780
781 echo "#" >> system-statistics
782 echo "# top -l5 -s2" >> system-statistics
783 echo "#" >> system-statistics
784 echo ""
785 echo "Please wait, collecting statistics"
786 echo ""
787 top -s 2 -l 5 >> system-statistics 2>&1
788
789 #
790 # collect everything into a single archive
791 #
792 cd "${WORKDIR}/.."
793 if [ -x /usr/bin/tar ]; then
794 tar -c ${GZ_OPT} -f "${ARCHIVE}" "${OUT}"
795 else
796 pax -w ${GZ_OPT} -f "${ARCHIVE}" "${OUT}"
797 fi
798 rm -rf "${WORKDIR}"
799
800 if [ ${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
806 fi
807
808 echo "Network data collected to \"${ARCHIVE}\""
809
810 #
811 # if requested, generate a crash report
812 #
813 if [ "${OUTDIR}" = "/Library/Logs/CrashReporter/SystemConfiguration" -a "${1}" = "CRASH" ]; then
814 kill -ABRT $$
815 fi
816