Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Jaharmi/03333834b7e1665748a5 to your computer and use it in GitHub Desktop.
Save Jaharmi/03333834b7e1665748a5 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# This shell snippet will pre-set CrashReporter's setting for diagnostics submissions
# to Apple and app developers. This seems to also have the side effect of not showing
# the additional "Diagnostics & Usage" dialog at the end of the Setup Assistant,
# because the settings have already been configured in the
# DiagnosticMessagesHistory.plist file.
#
# Modify the SUBMIT_TO_* variables below to either YES or NO to configure the setting.
# They are currently set to the defaults suggested by Apple when the dialog is shown
# in Setup Assistant.
#
# Finally, this code is only suitable for a script running _on the booted system_,
# not as part of an installer package postinstall script.
SUBMIT_TO_APPLE=YES
SUBMIT_TO_APP_DEVELOPERS=NO
PlistBuddy="/usr/libexec/PlistBuddy"
os_rev_major=`/usr/bin/sw_vers -productVersion | awk -F "." '{ print $2 }'`
if [ $os_rev_major -ge 10 ]; then
CRASHREPORTER_SUPPORT="/Library/Application Support/CrashReporter"
CRASHREPORTER_DIAG_PLIST="${CRASHREPORTER_SUPPORT}/DiagnosticMessagesHistory.plist"
if [ ! -d "${CRASHREPORTER_SUPPORT}" ]; then
mkdir "${CRASHREPORTER_SUPPORT}"
chmod 775 "${CRASHREPORTER_SUPPORT}"
chown root:admin "${CRASHREPORTER_SUPPORT}"
fi
for key in AutoSubmit AutoSubmitVersion ThirdPartyDataSubmit ThirdPartyDataSubmitVersion; do
$PlistBuddy -c "Delete :$key" "${CRASHREPORTER_DIAG_PLIST}" 2> /dev/null
done
$PlistBuddy -c "Add :AutoSubmit bool ${SUBMIT_TO_APPLE}" "${CRASHREPORTER_DIAG_PLIST}"
$PlistBuddy -c "Add :AutoSubmitVersion integer 4" "${CRASHREPORTER_DIAG_PLIST}"
$PlistBuddy -c "Add :ThirdPartyDataSubmit bool ${SUBMIT_TO_APP_DEVELOPERS}" "${CRASHREPORTER_DIAG_PLIST}"
$PlistBuddy -c "Add :ThirdPartyDataSubmitVersion integer 4" "${CRASHREPORTER_DIAG_PLIST}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment