Created
February 13, 2021 06:05
-
-
Save dakanji/1204437a127c1f154d95f91b8a6d69af to your computer and use it in GitHub Desktop.
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 | |
### | |
# FixMacUpdates.sh | |
# A Script to Modify Updates for Installation on Unsupported Macs | |
# | |
# Copyright (c) 2020-2021 Dayo Akanji | |
# MIT License | |
### | |
### | |
# USAGE: | |
# 1. Make the script executable in Terminal by typing: chmod +x '/path/to/FixMacUpdates.sh' | |
# - To get the path, drag the 'FixMacUpdates.sh' file into Terminal after typing: chmod +x | |
# 2. Download and mount the Apple Update dmg file | |
# 3. Drag the pkg file to your desktop from the dmg | |
# 4. Drag the 'FixMacUpdates.sh' file into Terminal | |
# 5. Leave a space after the command that appears and drag the pkg file into Terminal and press 'Enter' | |
# - You can press 'Enter' directly after 'FixMacUpdates.sh' if you first rename the pkg file as 'SecUpd.pkg' | |
### | |
# Provide custom colours in Terminal | |
msg_other() { | |
echo -e "\033[0;36m$1\033[0m" | |
} | |
msg_info() { | |
echo -e "\033[0;33m$1\033[0m" | |
} | |
msg_status() { | |
echo -e "\033[0;32m$1\033[0m" | |
} | |
msg_error() { | |
echo -e "\033[0;31m$1\033[0m" | |
} | |
## ERROR HANDLER ## | |
runErr() { # $1: message | |
# Declare Local Variables | |
local errMessage | |
errMessage="${1:-Runtime Error ... Exiting}" | |
echo '' | |
msg_error "${errMessage}" | |
echo '' | |
echo '' | |
exit 1 | |
} | |
trap runErr ERR | |
DESKTOP_DIR="${HOME}/Desktop" | |
EXPANDED_DIR="${DESKTOP_DIR}/ExpandedUpdate" | |
DISTIBUTION_FILE="${EXPANDED_DIR}/Distribution" | |
OLD_UPDATE_PKG="${1:-${DESKTOP_DIR}/SecUpd.pkg}" | |
NEW_UPDATE_PKG="${DESKTOP_DIR}/ModifiedUpdate.pkg" | |
# Clear Prompt | |
clear | |
# Commence Procedure | |
msg_info '###--------------------->>' | |
msg_info ' ### Mac Update Modifier >>' | |
msg_info ' ###--------------------->>' | |
if [ ! -f "${OLD_UPDATE_PKG}" ] ; then | |
# Terminate Procedure | |
echo '' | |
msg_error ' Could not find update pkg ... Exiting' | |
echo '' | |
else | |
# Progress Procedure | |
msg_other ' Preambles' | |
echo -ne 'Please Wait...\r' | |
rm -fr "${EXPANDED_DIR}" | |
rm -fr "${NEW_UPDATE_PKG}" | |
sleep 2 | |
echo -ne ' \r' | |
msg_status ' ...OK ' | |
msg_other ' Expand Package' | |
echo -ne 'Please Wait...\r' | |
sleep 2 | |
echo -ne ' \r' | |
echo -ne 'This may take a while...\r' | |
pkgutil --expand "${OLD_UPDATE_PKG}" "${EXPANDED_DIR}" | |
echo -ne ' \r' | |
echo -ne 'Please Wait... \r' | |
sleep 4 | |
echo -ne ' \r' | |
msg_status ' ...OK ' | |
msg_other ' Disable Volume Check' | |
echo -ne 'Please Wait...\r' | |
perl -i -p -e 's#VolumeCheck\(prefix\) \{#VolumeCheck(prefix) {return true;#g' "${DISTIBUTION_FILE}" | |
sleep 2 | |
echo -ne ' \r' | |
msg_status ' ...OK ' | |
msg_other ' Disable Installation Check' | |
echo -ne 'Please Wait...\r' | |
perl -i -p -e 's#InstallationCheck\(prefix\) \{#InstallationCheck(prefix) {return true;#g' "${DISTIBUTION_FILE}" | |
sleep 2 | |
echo -ne ' \r' | |
msg_status ' ...OK ' | |
msg_other ' Create Modified Update Package' | |
echo -ne 'Please Wait...\r' | |
sleep 4 | |
echo -ne ' \r' | |
echo -ne 'This takes some time...\r' | |
pkgutil --flatten "${EXPANDED_DIR}" "${NEW_UPDATE_PKG}" | |
echo -ne ' \r' | |
echo -ne 'Please Wait... \r' | |
sleep 2 | |
echo -ne ' \r' | |
msg_status ' ...OK ' | |
msg_other ' Cleaning Up' | |
echo -ne 'Please Wait...\r' | |
rm -fr "${EXPANDED_DIR}" | |
rm -fr "${OLD_UPDATE_PKG}" | |
sleep 2 | |
echo -ne ' \r' | |
msg_status ' ...OK ' | |
msg_other ' Notify' | |
msg_status " ${NEW_UPDATE_PKG} is ready for installation" | |
fi | |
# Conclude Procedure | |
msg_info ' ###--------------------->>' | |
msg_info ' ### Mac Update Modifier >>' | |
msg_info '###--------------------->>' | |
echo '' | |
echo '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment