Skip to content

Instantly share code, notes, and snippets.

@tyhallcsu
Created August 23, 2023 22:02
Show Gist options
  • Save tyhallcsu/52a8d058149d395351749d8282314e72 to your computer and use it in GitHub Desktop.
Save tyhallcsu/52a8d058149d395351749d8282314e72 to your computer and use it in GitHub Desktop.
Fix OpenHayStackMail.mailbundle after MacOS updates (Specifically Tested on Mail v16.0 + OpenHayStack v0.5.2)
#!/bin/sh
# Check if running as root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
token=`cat /System/Applications/Mail.app/Contents/Info.plist | grep -A1 "PluginCompatibilityUUID" | grep string | sed 's/<string>//' | sed 's/<\/string>//'`
path="/Library/Mail/Bundles/OpenHayStackMail.mailbundle/Contents/Info.plist"
osver=`sw_vers -productVersion`
# make sure it doesn't contain the $token
if [ `/usr/libexec/Plistbuddy -c "Print Supported${osver}PluginCompatibilityUUIDs" $path | grep -c $token` -ne 0 ]; then
# add the token to the array
echo "Token already exists, quitting..."
exit 1
fi
# Killing Mail.app
killall -9 Mail
# Add the token to the key values of "Supportedd${osver}PluginCompatibilityUUIDs"
echo "Adding token: $token"
/usr/libexec/PlistBuddy -c "Add :Supported${osver}PluginCompatibilityUUIDs: string $token" $path
if (( $? == 0 )); then
echo "Successfully added token to Info.plist"
else
echo "Failed to add token to Info.plist, quitting..."
exit 1
fi
echo "Running codesign"
codesign -f -s - /Library/Mail/Bundles/OpenHayStackMail.mailbundle
if (( $? == 0 )); then
echo "codesign done!"
else
echo "codesign failed!"
fi
echo "Running spctl"
sudo spctl --add --label "Allow OpenHayStackMail to load" /Library/Mail/Bundles/OpenHayStackMail.mailbundle
if (( $? == 0 )); then
echo "spctl done!"
exit 0
else
echo "spctl failed!"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment