Skip to content

Instantly share code, notes, and snippets.

@0xallie
Forked from avarayr/altermail.sh
Created March 15, 2023 23:11
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 0xallie/ab8bcd1cbd1333afb9b4b2cdef18af4a to your computer and use it in GitHub Desktop.
Save 0xallie/ab8bcd1cbd1333afb9b4b2cdef18af4a to your computer and use it in GitHub Desktop.
Fix SideloadlyPlugin.mailbundle after MacOS updates
#!/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/SideloadlyPlugin.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/SideloadlyPlugin.mailbundle
if (( $? == 0 )); then
echo "codesign done!"
else
echo "codesign failed!"
fi
echo "Running spctl"
sudo spctl --add --label "Allow SideloadlyPlugin to load" /Library/Mail/Bundles/SideloadlyPlugin.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