Skip to content

Instantly share code, notes, and snippets.

@tperfitt
Created December 22, 2023 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tperfitt/7bcf0e282dd3772bacaa10a09a23481a to your computer and use it in GitHub Desktop.
Save tperfitt/7bcf0e282dd3772bacaa10a09a23481a to your computer and use it in GitHub Desktop.
#!/bin/sh
write_prefs(){
local folder=$1
if [ -z "${folder}" ]; then
echo "you must specify a path to write prefs"
exit -1
fi
darwin_major_version="$(uname -r | cut -d '.' -f 1)" # 17 = 10.13, 18 = 10.14, 19 = 10.15, 20 = 11.0, etc.
# The following keys can be retrieved/verified with the command: strings '/System/Library/CoreServices/Setup Assistant.app/Contents/MacOS/Setup Assistant' | grep '^DidSee' | sort
# These are the keys that are common to all macOS version 10.13 and newer. Other OS version specific keys will be added below.
setupassistant_did_see_pref_keys=( 'DidSeeApplePaySetup' 'DidSeeAvatarSetup' 'DidSeeCloudSetup' 'DidSeeiCloudLoginForStorageServices' 'DidSeePrivacy' 'DidSeeSiriSetup' 'DidSeeSyncSetup' 'DidSeeSyncSetup2' 'DidSeeTouchIDSetup' )
if (( darwin_major_version == 17 )); then
setupassistant_did_see_pref_keys+=( 'DidSeeTrueTonePrivacy' ) # Only exists in macOS 10.13, I believe it was a typo and replaced with "DidSeeTrueTone" in macOS 10.14.
elif (( darwin_major_version >= 18 )); then
setupassistant_did_see_pref_keys+=( 'DidSeeAppearanceSetup' 'DidSeeTrueTone' ) # Added in macOS 10.14.
if (( darwin_major_version >= 19 )); then
setupassistant_did_see_pref_keys+=( 'DidSeeActivationLock' 'DidSeeScreenTime' ) # Added in macOS 10.15.
if (( darwin_major_version >= 20 )); then
setupassistant_did_see_pref_keys+=( 'DidSeeAccessibility' 'DidSeeAppStore' ) # Added in macOS 11.
fi
fi
fi
for this_setupassistant_did_see_pref_key in "${setupassistant_did_see_pref_keys[@]}"; do
defaults write "${folder}/Library/Preferences/com.apple.SetupAssistant" "${this_setupassistant_did_see_pref_key}" -bool true
done
# The following keys can be retrieved/verified with the command: strings '/System/Library/CoreServices/Setup Assistant.app/Contents/MacOS/Setup Assistant' | grep '^LastSeen' | sort
defaults write "${folder}/Library/Preferences/com.apple.SetupAssistant" LastSeenBuddyBuildVersion -string "$(sw_vers -buildVersion)"
# These are the keys that are common to all macOS version 10.13 and newer. Other OS version specific keys will be added below.
setupassistant_last_seen_pref_keys=( 'LastSeenCloudProductVersion' 'LastSeeniCloudStorageServicesProductVersion' 'LastSeenSyncProductVersion' )
if (( darwin_major_version >= 19 )); then
setupassistant_last_seen_pref_keys+=( 'LastSeenDiagnosticsProductVersion' 'LastSeenSiriProductVersion' ) # Added in macOS 10.15.
fi
os_version="$(sw_vers -productVersion)"
for this_setupassistant_last_seen_pref_key in "${setupassistant_last_seen_pref_keys[@]}"; do
defaults write "${folder}/Library/Preferences/com.apple.SetupAssistant" "${this_setupassistant_last_seen_pref_key}" -string "${os_version}"
done
}
darwin_major_version="$(uname -r | cut -d '.' -f 1)" # 17 = 10.13, 18 = 10.14, 19 = 10.15, 20 = 11.0, etc.
# The following keys can be retrieved/verified with the command: strings '/System/Library/CoreServices/Setup Assistant.app/Contents/MacOS/Setup Assistant' | grep '^DidSee' | sort
# These are the keys that are common to all macOS version 10.13 and newer. Other OS version specific keys will be added below.
setupassistant_did_see_pref_keys=( 'DidSeeApplePaySetup' 'DidSeeAvatarSetup' 'DidSeeCloudSetup' 'DidSeeiCloudLoginForStorageServices' 'DidSeePrivacy' 'DidSeeSiriSetup' 'DidSeeSyncSetup' 'DidSeeSyncSetup2' 'DidSeeTouchIDSetup' )
if (( darwin_major_version == 17 )); then
setupassistant_did_see_pref_keys+=( 'DidSeeTrueTonePrivacy' ) # Only exists in macOS 10.13, I believe it was a typo and replaced with "DidSeeTrueTone" in macOS 10.14.
elif (( darwin_major_version >= 18 )); then
setupassistant_did_see_pref_keys+=( 'DidSeeAppearanceSetup' 'DidSeeTrueTone' ) # Added in macOS 10.14.
if (( darwin_major_version >= 19 )); then
setupassistant_did_see_pref_keys+=( 'DidSeeActivationLock' 'DidSeeScreenTime' ) # Added in macOS 10.15.
if (( darwin_major_version >= 20 )); then
setupassistant_did_see_pref_keys+=( 'DidSeeAccessibility' 'DidSeeAppStore' ) # Added in macOS 11.
fi
fi
fi
user_template_dir="$3/Library/User Template"
if [ ! -d "${user_template_dir}" ] ; then
user_template_dir="$3/System/Library/User Template"
fi
for USER_TEMPLATE in "${user_template_dir}"/*
do
write_prefs "${USER_TEMPLATE}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment