2022-02-18 08:19:04 +01:00
#!/bin/bash
HOST_DIR = " $HOME /magisk "
2022-02-24 20:54:57 +01:00
#DEVICE_DIR="/sdcard/Android/data/org.lineageos.updater/files/LineageOS\ updates/"
DEVICE_DIR = "/sdcard/Download"
LINEAGE = "lineage-*-signed.zip"
2022-02-18 08:19:04 +01:00
2022-02-24 20:54:57 +01:00
if [ ! -d $HOST_DIR ] ; then
mkdir -p $HOST_DIR ;
fi
for file in $( adb shell ls $DEVICE_DIR /$LINEAGE )
2022-02-18 08:19:04 +01:00
do
2022-02-24 20:54:57 +01:00
file = $( echo -e $file | xargs -n 1 basename) ;
2022-02-18 08:19:04 +01:00
done
2022-02-24 20:54:57 +01:00
# Get latest lineageos zip file
if adb shell ls $DEVICE_DIR /$LINEAGE ; then
adb pull $DEVICE_DIR /$file $HOST_DIR /;
2022-02-18 08:19:04 +01:00
else
2022-02-24 20:54:57 +01:00
echo " Zip file does not exist.
Did you export the rom/zip file? If not got to Settings-System-Updater and run the script again."
2022-02-18 08:19:04 +01:00
exit
fi
# Get and push boot.img
cd $HOST_DIR
2022-02-24 20:54:57 +01:00
unzip $file boot.img
2022-02-18 08:19:04 +01:00
adb push boot.img /sdcard/Download/
# Magisk boot.img patch and flash
read -p "Patch boot.img with magisk manually and press enter afterwards."
adb shell ls /sdcard/Download/magisk_patched-*.img | tr '\r' ' ' | xargs -n1 adb pull
adb reboot fastboot
fastboot flash boot magisk_patched-*.img
fastboot reboot
# Clean up
2022-02-24 20:54:57 +01:00
echo -n " Do you want to delete $file , boot.img and magisk_patched file on your computer? (y/n) "
2022-02-18 08:19:04 +01:00
read answer
if [ " $answer " != " ${ answer #[Yy] } " ] ; then
2022-02-24 20:54:57 +01:00
rm $file
2022-02-18 08:19:04 +01:00
rm boot.img
rm magisk_patched-*.img
else
2022-02-24 20:54:57 +01:00
echo "Ok, keep it. But remember to delete it before you run the script again. It may cause problems if the wrong patch is being flashed. E.g. bootloop. Just moved in a backup folder."
fi
echo -n " Do you want to delete $file , boot.img and magisk_patched file on your phone? (y/n) - Check your device is fully loaded. "
read answer
if [ " $answer " != " ${ answer #[Yy] } " ] ; then
adb shell rm $DEVICE_DIR /$file
adb shell rm $DEVICE_DIR /boot.img
adb shell rm $DEVICE_DIR /magisk_patched-*.img
else
echo "Ok, keep it. But remember to delete it before you run the script again. It may cause problems if the wrong patch is being flashed. E.g. bootloop. Just moved in a backup folder."
2022-02-18 08:19:04 +01:00
fi
2022-02-24 20:54:57 +01:00
echo -n " Do you want to delete $HOST_DIR ? (y/n)? "
2022-02-18 08:19:04 +01:00
read answer
if [ " $answer " != " ${ answer #[Yy] } " ] ; then
2022-02-24 20:54:57 +01:00
rm -r $HOST_DIR
2022-02-18 08:19:04 +01:00
else
2022-02-24 20:54:57 +01:00
echo " Kept $HOST_DIR . "
2022-02-18 08:19:04 +01:00
fi
echo "That's it"
exit