...
 
Commits (1)
File added
#!/bin/bash
# Cheesy wrapper script to help n00bs till I can finish lglaf
clear
echo "This will install TWRP."
echo
echo "You do NOT need to do ANYTHING!"
echo
echo "If it fails, you will have lost recovery. You can get recovery back by flashing a KDZ."
echo
echo "If the hash check fails, it will make five attempts."
echo
echo "If after five attempts, it does not get a hash match, it will abort."
echo
echo "You can re-run this script as many times as you want, however,"
echo "if you are not getting a hash match, you should try a different PC,"
echo "or a different cable, or a different USB port."
read -n1 -r -p "Press any key to continue..." key
if [ "$KEY" = '' ]; then
echo "Flashing... this will take a while."
else
echo "Exiting"
exit
fi
TWRP="h901-twrp.img"
TWRPTMP="h901-twrp-tmp.img"
TWRPTEST="test.img"
TRIES=0
rm ${TWRPTMP} > /dev/null 2>&1
rm ${TWRPTEST} > /dev/null 2>&1
function flash () {
echo "Flashing TWRP to recovery. Please wait..."
./partitions.py --restoremisc ${TWRP} recovery
echo "Dumping recovery for hash check..."
./partitions.py --dump ${TWRPTMP} recovery
echo "Trimming trailing zeros"
dd if=${TWRPTMP} of=${TWRPTEST} bs=1024 count=29100 > /dev/null 2>&1 # This strips the trailing whitespace so the dump is the same size as TWRP
SHA1=`sha256sum ${TWRP} | awk '{print $1}'`
SHA2=`sha256sum ${TWRPTEST} | awk '{print $1}'`
STRHASH1="S${SHA1}"
STRHASH2="S${SHA2}"
echo "Checking hash..."
echo "TWRP hash:" $STRHASH1
echo "Test dump hash: " $STRHASH2
if [[ "$STRHASH1" != "$STRHASH2" ]] ; then
echo
echo "Hash check failed! Retrying for 5 times."
echo
rm ${TWRPTMP}
rm ${TWRPTEST}
until [ $TRIES -ge 5 ]
do
TRIES=$[$TRIES+1] && sleep 2 && echo "Attempt ${TRIES} - Press ctrl C to break" && flash
done && echo "Hash check failed after 5 attempts - exiting" && exit
fi
echo "Hash check passed. You now have TWRP on recovery!"
rm ${TWRPTMP} > /dev/null 2>&1
rm ${TWRPTEST} > /dev/null 2>&1
./lglaf.py -c '!CTRL POFF'
echo "Flash sucessful! Unplug your USB cable and your phone will power off."
}
flash
#!/bin/bash
# another n00b script that roots the phone...
echo "Make sure your phone has full booted into TWRP."
echo
read -n1 -r -p "Press any key to continue..." key
if [ "$KEY" = '' ]; then
echo "Rooting your phone. It will reboot back into TWRP."
echo "Don't do anything until your phone has booted back to the OS."
else
echo "Exiting"
exit
fi
echo "Unmounting data"
adb shell umount /data
adb shell umount /sdcard
echo
echo "Formatting data"
adb shell mkfs.ext2 /dev/block/bootdevice/by-name/userdata
echo
echo "Mounting data"
adb shell mount /data
echo
echo "Mounting system r/w"
adb shell mount -o rw /system
echo
echo "Making sure recovery sticks"
adb shell rm /system/recovery-from-boot.p
echo
echo "Rooting your phone!"
echo "Your phone will reboot back into the OS once rooted."
adb push Magisk-v16.0.zip /cache/recovery
adb shell echo ""--update_package=/cache/recovery/Magisk-v16.0.zip" > /cache/recovery/command"
echo "Rebooting. Do NOT shut off your phone until it is back in the OS."
echo "Enjoy your rooted phone!"
adb reboot recovery