Commit 21c537d1 authored by William Swango's avatar William Swango

Opps -- let's add the scripts...

parent fe7947c8
#!/bin/bash
# Cheesy wrapper script to help n00bs till I can finish lglaf
clear
echo "This will install TWRP onto the laf partition of your phone."
echo
echo "If it fails, NO damage is done to your phone."
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 "NO damage has been done to your phone."
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 space to continue..." key
if [ "$KEY" = '' ]; then
echo "Flashing... this will take a while."
else
echo "Exiting"
exit
fi
TWRP="h918-twrp.img"
TWRPTMP="h918-twrp-tmp.img"
TWRPTEST="test.img"
SRC_OFFSET=91270
DST_OFFSET=6
SIZE=29798400
TRIES=0
rm ${TWRPTMP} > /dev/null 2>&1
rm ${TWRPTEST} > /dev/null 2>&1
function flash () {
echo "Flashing TWRP to lafbak. Please wait..."
./partitions.py --restoremisc ${TWRP} lafbak
echo "Dumping lafbak for hash check..."
./partitions.py --dump ${TWRPTMP} lafbak
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
# dd if=${TWRPTMP} of=${TWRPTEST} bs=1 count=5 # 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. Copying TWRP to laf"
./lglaf.py -c '!OPEN'
FD_NUM=`./lglaf.py -c '!EXEC lsof\0' | grep sda | grep lsof | awk '{print $4}' | cut -f1 -d"u"`
./lglaf.py -c '!COPY '$FD_NUM,$SRC_OFFSET,$SIZE,$DST_OFFSET
./lglaf.py -c '!CLSE '$FD_NUM
rm ${TWRPTMP} > /dev/null 2>&1
rm ${TWRPTEST} > /dev/null 2>&1
echo "Flash sucessful! Unplug your USB cable and your phone will power off."
echo "Once your phone is off, go back into download mode - hold vol up and plug the USB cable back in."
echo "You will be in TWRP -- follow the instructions before proceeding to step2.sh"
./lglaf.py -c '!CTRL POFF'
exit
}
flash
#!/bin/bash
# another n00b script that roots the phone...
echo "Unmounting data"
adb shell umount /data
echo
echo "Formatting data"
adb shell mkfs.ext2 /dev/sda20
echo
echo "Mounting data"
adb shell mount /data
echo
echo "Mounting system r/w"
adb shell mount /system
echo
echo "Installing TWRP onto recovery"
adb push h918-twrp.img /sdcard/
adb shell dd if=/sdcard/h918-twrp.img of=/dev/block/bootdevice/by-name/recovery
echo
echo "Making sure recovery sticks"
adb shell rm /system/recovery-from-boot.p
adb shell rm /system/recovery-from-boot.p.bak
echo
echo "Rooting your phone!"
echo "Your phone will reboot back into the OS once rooted."
adb push Magisk-v16.0.zip /sdcard/
adb shell echo ""--update_package=/sdcard/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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment