-
-
Save noahwilliamsson/08500bb6417015b7d6023e0b42cac34e to your computer and use it in GitHub Desktop.
OpenHaystack Mailbundle compat, codesign and whitelisting fix
This file contains 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
#!/usr/bin/env bash | |
# | |
# Inspired by https://gist.github.com/avarayr/2490e4f83f1781ebef440c2dc5089235 | |
# as found via https://github.com/rileytestut/AltStore/issues/905#issuecomment-1025092704 | |
# | |
# Also interesting is "force mail to re-initialize the plugin" from: | |
# - https://old.reddit.com/r/AltStore/comments/om3z64/solution_to_incompatible_mail_plugin_for_macos/ | |
# (for me, this wasn't necessary to get things working) | |
# | |
# NOTE: If you get "Operation not permitted" while attempting to access files below ~/Library/Mail | |
# then go to System preferences > Security & Privacy > Privacy, scroll down and select | |
# "Full disk access". Click "+" and add /Applications/Utilities/Terminal.app. | |
# After restarting Terminal.app, this script should be able to access files below ~/Library/Mail. | |
# | |
set -euo pipefail | |
OS_PVER=$(sw_vers -productVersion|cut -d. -f1-2) | |
MAIL_PLUGIN_COMPAT_UUID=$(cat /System/Applications/Mail.app/Contents/Info.plist | grep -A1 "PluginCompatibilityUUID" | grep string | sed -e 's/[[:space:]]<string>//' -e 's/<\/string>//') | |
MB_PATH=~/Library/Mail/Bundles/OpenHaystackMail.mailbundle | |
MB_PLIST=$MB_PATH/Contents/Info.plist | |
TMPFILE=$(mktemp /tmp/openhaystack.XXXXXX) | |
if [ ! -x /usr/bin/codesign ]; then | |
echo ">>> ERROR: The codesign utility is missing" | |
echo ">>> Paste the following command into your Terminal.app session to install the Xcode command line tools" | |
echo | |
echo "xcode-select install" | |
echo | |
echo ">>> Once the tools have been installed, re-run this script." | |
exit 0 | |
fi | |
echo "macOS version (major, minor): $OS_PVER" | |
echo "Mail.app plugin compatibility UUID: $MAIL_PLUGIN_COMPAT_UUID" | |
echo | |
echo "Mai bundle claims to support the following plugin compatibility UUIDs:" | |
/usr/libexec/Plistbuddy -c "Print Supported${OS_PVER}PluginCompatibilityUUIDs" $MB_PLIST | tee "$TMPFILE" | |
echo | |
if ! grep -q "${MAIL_PLUGIN_COMPAT_UUID}" "${TMPFILE}"; then | |
echo ">>> Problem: ${MB_PLIST} does not claim to be compatible with ${MAIL_PLUGIN_COMPAT_UUID}" | |
echo ">>> Using PlistBuddy to update compatibility list in ${MB_PLIST}" | |
/usr/libexec/PlistBuddy -c "Add :Supported${OS_PVER}PluginCompatibilityUUIDs: string ${MAIL_PLUGIN_COMPAT_UUID}" "${MB_PLIST}" | |
echo ">>> Using codesign to update code-signature on ${MB_PATH}" | |
codesign -f -s - "${MB_PATH}" | |
else | |
echo ">>> OK, ${MB_PLIST} already claims to be compatible with ${MAIL_PLUGIN_COMPAT_UUID}" | |
fi | |
rm "${TMPFILE}" | |
echo | |
echo ">>> Using sudo spctl to whitelist the mailbundle in GateKeeper (you might be asked to enter your login password)..." | |
echo | |
set -x | |
sudo spctl --add --label 'Allow OpenHaystack Mail.app plugin to load' ${MB_PATH} | |
set +x | |
echo | |
echo ">>> Finally, open Mail.app and goto Preferences > General > Manage plugins and check the OpenHaystackMail.mailbundle plugin." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment