Skip to content

Instantly share code, notes, and snippets.

@nathantsoi
Created January 14, 2015 01:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathantsoi/e36c5a2f2e94ce5ebb85 to your computer and use it in GitHub Desktop.
Save nathantsoi/e36c5a2f2e94ce5ebb85 to your computer and use it in GitHub Desktop.
#!/bin/bash
# make a new directory to work in
cd ~/Desktop && mkdir nexus501
# get the OTA
wget http://android.clients.google.com/packages/ota/google_hammerhead/785a2f7af3718dba7e569decde8b6c4dc476a309.signed-hammerhead-LRX22C-from-LRX21O.785a2f7a.zip
mv *.zip update.zip
# get the flashable super su
wget http://download.chainfire.eu/641/SuperSU/UPDATE-SuperSU-v2.40.zip?retrieve_file=1
mv UPDATE-SuperSU-v2.40.zip?retrieve_file=1 UPDATE-SuperSU-v2.40.zip
# get twrp
wget http://techerrata.com/file/twrp2/hammerhead/openrecovery-twrp-2.8.3.0-hammerhead.img
# get the factory image
mkdir factory_img && cd factory_img
wget https://dl.google.com/dl/android/aosp/hammerhead-lrx21o-factory-01315e08.tgz
# extract recovery.img, boot.img and system.img
tar xjf *.tgz
cd hammerhead-lrx21o
unzip image-hammerhead-lrx21o.zip
mv recovery.img ../../
mv boot.img ../../
mv system.img ../../
cd ../../
rm -r factory_img
# flash it
adb devices
adb reboot bootloader
fastboot devices
fastboot flash recovery recovery.img
fastboot flash system system.img
fastboot flash boot boot.img
adb reboot recovery
echo "wait for the android and red triangle"
echo "then press power + volume up and release"
read -p "then pick apply update from ADB [Press any key when ready]"
adb sideload update.zip
read -p "pick reboot to bootloader [Press any key when ready]"
fastboot flash recovery openrecovery-twrp-2.8.3.0-hammerhead.img
read -p "pick recovery mode and press the power button [Press any key when ready]"
read -p "you should be in twrp, press advanced -> adb sideload [Press any key when ready]"
read -p "check both options (Wipe Dalvik Cache and Wipe Cache) then swipe the bar [Press any key when ready]"
adb sideload UPDATE-SuperSU-v2.40.zip
echo "reboot and you're done"
echo "rm -r ~/Desktop/nexus501 if you're done and want to clean up"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment