Created
September 4, 2019 17:39
-
-
Save macsimom/0a9dca3e212975d2cd94a4b8e3fa0310 to your computer and use it in GitHub Desktop.
Call it with sudo bash Disable_macOS_upgrade.sh disable Catalina
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
#!/bin/bash | |
# Call it with eg. sudo bash Disable_macOS_upgrade.sh disable Catalina | |
disable_osxnotification() { | |
if [ -d /Library/Bundles/OSXNotification.bundle ]; then | |
hdiutil create -format UDZO -fs hfs+ -srcfolder /Library/Bundles/OSXNotification.bundle /Library/Bundles/OSXNotification | |
rm -rf /Library/Bundles/OSXNotification.bundle | |
fi | |
if [[ ! -e /Library/Bundles/OSXNotification.bundle ]]; then | |
touch /Library/Bundles/OSXNotification.bundle | |
chflags schg /Library/Bundles/OSXNotification.bundle | |
fi | |
} | |
disable_release() { | |
NAMEOFRELEASE=$1 | |
if [ -d "/Applications/Install macOS ${NAMEOFRELEASE}.app" ]; then | |
rm -rf "/Applications/Install macOS ${NAMEOFRELEASE}.app" | |
fi | |
if [[ ! -e "/Applications/Install macOS ${NAMEOFRELEASE}.app" ]]; then | |
touch "/Applications/Install macOS ${NAMEOFRELEASE}.app" | |
chflags hidden "/Applications/Install macOS ${NAMEOFRELEASE}.app" | |
chflags schg "/Applications/Install macOS ${NAMEOFRELEASE}.app" | |
touch "/Applications/macOS ${NAMEOFRELEASE}.appdownload" | |
chflags hidden "/Applications/macOS ${NAMEOFRELEASE}.appdownload" | |
chflags schg "/Applications/macOS ${NAMEOFRELEASE}.appdownload" | |
fi | |
} | |
re-enable_osxnotification() { | |
if [[ -f /Library/Bundles/OSXNotification.bundle && -f /Library/Bundles/OSXNotification.dmg ]]; then | |
chflags noschg /Library/Bundles/OSXNotification.bundle | |
rm /Library/Bundles/OSXNotification.bundle | |
MP=$(diskutil info $(hdiutil attach -private /Library/Bundles/OSXNotification.dmg | tail -n1 |awk '{print $1}')|grep Mount\ Point|sed -E 's/Mount Point://'|sed -E 's/^[^/]+//') | |
ditto "$MP/OSXNotification.bundle/" /Library/Bundles/OSXNotification.bundle | |
hdiutil detach "$MP" | |
rm /Library/Bundles/OSXNotification.dmg | |
elif [ -f /Library/Bundles/OSXNotification.bundle ]; then | |
chflags noschg /Library/Bundles/OSXNotification.bundle | |
rm /Library/Bundles/OSXNotification.bundle | |
fi | |
} | |
remove_release_block() { | |
NAMEOFRELEASE=$1 | |
if [ -f "/Applications/Install macOS ${NAMEOFRELEASE}.app" ]; then | |
chflags noschg "/Applications/Install macOS ${NAMEOFRELEASE}.app" | |
rm "/Applications/Install macOS ${NAMEOFRELEASE}.app" | |
fi | |
if [ -f "/Applications/macOS ${NAMEOFRELEASE}.appdownload" ]; then | |
chflags noschg "/Applications/macOS ${NAMEOFRELEASE}.appdownload" | |
rm "/Applications/macOS ${NAMEOFRELEASE}.appdownload" | |
fi | |
} | |
OP=$1 | |
RELEASE=$2 | |
if [ "$OP" = "disable" ]; then | |
disable_osxnotification | |
disable_release "$RELEASE" | |
elif [ "$OP" = "reenable" ]; then | |
remove_release_block "$RELEASE" | |
re-enable_osxnotification | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment