Skip to content

Instantly share code, notes, and snippets.

@rickmark
Last active March 15, 2024 20:18
Show Gist options
  • Save rickmark/9245ed3ef7f36d5a0421557f68c4681b to your computer and use it in GitHub Desktop.
Save rickmark/9245ed3ef7f36d5a0421557f68c4681b to your computer and use it in GitHub Desktop.
Perform a FOSS restore of an Apple T2 processor
#!/bin/bash
WORKING_DIRECTORY=`pwd`
repo_list=(libimobiledevice idevicerestore libplist libusbmuxd usbmuxd libirecovery)
for repo in ${repo_list[@]}; do
directory="$WORKING_DIRECTORY/$repo"
if [ -d "$directory" ]; then
rm -rf "$directory"
fi
done
CONFIG_FILE=/boot/config.txt
# Disable WiFi at Device Tree level
if ! grep -q "pi3-disable-wifi" "$CONFIG_FILE"; then
sed -i '/\/boot\/overlays\/README/a dtoverlay=pi3-disable-wifi' $CONFIG_FILE
fi
# Disable BlueTooth at Device Tree level
if ! grep -q "pi3-disable-bt" "$CONFIG_FILE"; then
sed -i '/\/boot\/overlays\/README/a dtoverlay=pi3-disable-bt' $CONFIG_FILE
fi
# Disable listening services
systemctl disable avahi-daemon.socket
systemctl disable avahi-daemon.service
# Reboot
reboot
#!/bin/bash
RECOVERY_DATA_URL="https://mesu.apple.com/assets/bridgeos/com_apple_bridgeOSIPSW/com_apple_bridgeOSIPSW.xml"
# TODO: Read XML to find current version
# TODO: Verify SHA of downloaded file (Really Apple? SHA1?)
wget http://updates-http.cdn-apple.com/2020/macos/061-41296-20200124-14D2074C-3EFF-11EA-9B7E-811124EF36D6/iBridge2,1,iBridge2,10,iBridge2,12,iBridge2,14,iBridge2,3,iBridge2,4,iBridge2,5,iBridge2,6,iBridge2,7,iBridge2,8_4.2_17P3050_Restore.ipsw
sudo usbmuxd --foreground --verbose &
idevice --debug --erase --no-input iBridge2,1,iBridge2,10,iBridge2,12,iBridge2,14,iBridge2,3,iBridge2,4,iBridge2,5,iBridge2,6,iBridge2,7,iBridge2,8_4.2_17P3050_Restore.ipsw
#!/bin/bash
WORKING_DIRECTORY=`pwd`
REPO_LIST=(libplist libusbmuxd libimobiledevice libirecovery usbmuxd idevicerestore)
# Perform full update before work
if [ -z "$(find /var/cache/apt/pkgcache.bin -mmin -1440)" ]; then
sudo pt update -y
fi
sudo apt upgrade -y
# Install pre-requsites
sudo apt install -y git autoconf automake libtool pkg-config clang libssl-dev python3-dev python-dev llvm gcc libreadline-dev libusb-1.0-0-dev libzip-dev libcurl4-gnutls-dev
# Clone the libimobiledevice world
for repo in ${REPO_LIST[@]}; do
directory="$WORKING_DIRECTORY/$repo"
if [ -d "$directory" ]; then
cd "$directory"
git pull
else
cd $WORKING_DIRECTORY
git clone "https://github.com/libimobiledevice/$repo.git"
fi
done
# Build and install each repository in order
for repo in ${REPO_LIST[@]}; do
cd "$WORKING_DIRECTORY/$repo"
./autogen.sh
make
sudo make install
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment