Skip to content

Instantly share code, notes, and snippets.

@macmule
Last active November 28, 2021 21:24
Show Gist options
  • Save macmule/0c7eeeabbca4737af6d3831e49341709 to your computer and use it in GitHub Desktop.
Save macmule/0c7eeeabbca4737af6d3831e49341709 to your computer and use it in GitHub Desktop.
## Get the Macs UUID
set macUUID to do shell script "system_profiler SPHardwareDataType | grep 'Hardware UUID' | awk '{print $3}'"
log "Retreived this Macs UUID..."
## Try to delete the local items Keychain db's
try
do shell script "rm -rf ~/Library/Keychains/" & macUUID & "/*"
end try
## Delete the login Keychain
try
do shell script "security delete-keychain ~/Library/Keychains/login.keychain"
log "Deleted old keychain..."
on error ## If cannot find the login keychain, then prompt to create a new one.
log "Couldn't find old Login Keychain..."
cannotFindKeychain_(me)
end try
log "Deleted local items keychain..."
## Close the password prompt window
closePasswordPromptWindow_(me)
## 10.9.x needs the mac client to restart as securityd or another daemon process owned by the system is used to update the local items keychain
log "Prompting to restart"
display dialog "Your Mac needs to restart to finish updating your Keychain. Please dismiss any Local Items keychain prompts, close any open Applications & click Restart Now." with icon 0 buttons ("Restart Now")
## Restart the Mac
log "Restarting..."
tell application "System Events"
restart
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment