What This Script Does
The auto-update-brew-hybrid.sh script is the most fully-featured auto-update option in the Brew Scripts toolkit. It performs the same core Homebrew maintenance operations as the basic auto-update script — updating the package index, upgrading installed packages, and cleaning up old versions — but adds a comprehensive dual-notification system that keeps you informed through both email and text message.
The hybrid approach to notifications addresses a common trade-off. Text messages are great for quick, at-a-glance status updates that you can read in seconds, but they are not ideal for detailed information. Email, on the other hand, can accommodate a full report with all the technical details you might want to review, but emails are easy to miss or ignore if you are not checking your inbox regularly. By sending both, this script ensures you get the quick notification via text and the detailed report via email, covering both use cases.
The email report is the more substantial of the two notifications. It is an HTML message with a success or warning heading, counts of successful operations, errors, packages updated and applications updated, a line for each step (update, package upgrade, cask upgrade, cleanup), and the last 20 lines of the log.
The text message is deliberately brief: one line with a success or issues marker and the operation, package and app counts. You can read it on your lock screen and open the email or log only if something went wrong.
Email is sent with the command-line mail -s command, which hands the message to macOS's built-in postfix mail system. It does not use the Mail app. macOS ships postfix switched off, so email only works once you have configured postfix with an SMTP relay. Before sending, the script checks that the mail system is running; if it is not, it logs "Email NOT sent" and carries on, so without a relay no email reports are delivered. Text messages are sent by AppleScript telling the Messages app to send an iMessage to PHONE_NUMBER. That needs Messages signed in to iMessage and your terminal allowed to control Messages in System Settings > Privacy & Security > Automation. If the send fails, the script logs the error and continues.
Before updating, the script checks two conditions. It must be connected to the Wi-Fi network named in WIFI_NETWORK; it retries that check up to 3 times, 5 minutes apart. And the Mac must be on AC power. If either check fails, the script sends a "Skipped" text and email and exits without updating.
Everything is logged to ~/Library/Logs/AutoUpdateBrewHybrid.log, so the record survives even if both notification channels fail.