NicolasWebDev / reinstall-magisk-on-lineageos

Small bash script to reinstall magisk after each LineageOS update
80 stars 16 forks source link

Check version of installed LineageOS and download correct boot.img #42

Open adam-kulagowski opened 10 months ago

adam-kulagowski commented 10 months ago

Currently the script downloads the latest boot.img from LineageOS servers. However this assumes that LinageOS updater is in sync. This not always the case:

LOS updater detected and installed version 20-I-2024. Scripts downloaded version from 27-I-2024. After patching and fastboot - phone became unbootable.

Solution was to boot to recovery and flash LinageOS and Gapps again - however this should be handled by script. At least an error should be printed.

bfg01 commented 6 months ago

I proposed a starting point for this and other things long ago in #35

Continuing directly from there, I think the rest could be something like this:

[...]

IMG=

if [ -n "$IMG_DNL_URL" ]; then
  echo "Downloading boot.img corresponding to current LineageOS version..."
  wget -c "$IMG_DNL_URL"
  if echo "$IMG_SHA256  boot.img" | sha256sum --status -c; then
    IMG=true
  else
    echo "Error: checksum does not match current download; probably a corrupted download. Trying with next option..."
  fi
else
  echo "No downloads available at LineageOS website; consider updating current LineageOS version. Trying with next option..."
fi

# Look for exported update if first option fails
# Former location of downloaded/exported updates: /sdcard/Android/data/org.lineageos.updater/[...]
if [ -z "$IMG" ] && ./adb shell [ -f /sdcard/Download/"$ZIP_NAME" ]; then
  echo "Found exported update in device"
  ./adb pull /sdcard/Download/"$ZIP_NAME"
  if echo "$ZIP_SHA256  $ZIP_NAME" | sha256sum --status -c; then
    unzip "$ZIP_NAME" payload.bin
    ./payload-dumper-go -p boot payload.bin
    IMG=true
  else
    echo "Error: checksum does not match exported update"
  fi
fi

[ -n "$IMG" ] || { echo "No boot images available. Please update LineageOS version and try again."; exit 1; }

But author hasn't shown up for a big while already... Feel free to check or correct if I did some mistake.

bfg01 commented 6 months ago

Adding to this, and talking about unbootable devices after patching, in #36 I mentioned this potential danger by not setting the actual correct patch flags for the specific device.

Regarding this, I think the PixelFlasher project (also here in Github) already takes care of this not just for Pixel but general devices IIRC, also in the form of Bash scripting.

helpdeskdan commented 1 month ago

It would be awesome if bfg01 would fork the project. I've tweaked mine to work again, but my edits are just cobbles.