Created
January 30, 2022 08:08
-
-
Save avarayr/2490e4f83f1781ebef440c2dc5089235 to your computer and use it in GitHub Desktop.
Fix AltPlugin.mailbundle after MacOS updates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/AltPlugin.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/AltPlugin.mailbundle | |
if (( $? == 0 )); then | |
echo "codesign done!" | |
else | |
echo "codesign failed!" | |
fi | |
echo "Running spctl" | |
sudo spctl --add --label "Allow AltPlugin to load" /Library/Mail/Bundles/AltPlugin.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
Thanks!
Works like a charm