#!/sbin/sh # Minimal update-binary that flashes the patched boot image # Recovery sideload runs this as root OUTFD=$2 ZIPFILE=$3 ui_print() { echo "ui_print $1" > /proc/self/fd/$OUTFD echo "ui_print" > /proc/self/fd/$OUTFD } ui_print "================================" ui_print " AeThex OS - Magisk Root Flash" ui_print "================================" ui_print "" # Extract boot image from zip ui_print "- Extracting patched boot image..." mkdir -p /tmp/aethex unzip -o "$ZIPFILE" boot.img -d /tmp/aethex if [ ! -f /tmp/aethex/boot.img ]; then ui_print "! Failed to extract boot.img" exit 1 fi IMGSIZE=$(wc -c < /tmp/aethex/boot.img) ui_print "- Image size: $IMGSIZE bytes" # Get current slot SLOT=$(getprop ro.boot.slot_suffix 2>/dev/null) if [ -z "$SLOT" ]; then SLOT="_b" fi ui_print "- Current slot: $SLOT" ui_print "- Target partition: boot${SLOT}" # Flash to current slot's boot partition BOOT_PART="/dev/block/by-name/boot${SLOT}" if [ ! -e "$BOOT_PART" ]; then ui_print "! Partition $BOOT_PART not found" ui_print "- Trying boot_b directly..." BOOT_PART="/dev/block/by-name/boot_b" fi ui_print "- Flashing to $BOOT_PART..." dd if=/tmp/aethex/boot.img of=$BOOT_PART bs=4096 RESULT=$? if [ $RESULT -eq 0 ]; then ui_print "- Boot image flashed successfully!" ui_print "" ui_print " Magisk root installed!" ui_print " Reboot to complete setup." else ui_print "! Flash failed with error $RESULT" exit 1 fi # Also flash the boot animation while we have root if unzip -o "$ZIPFILE" bootanimation.zip -d /tmp/aethex 2>/dev/null; then ui_print "" ui_print "- Flashing AeThex boot animation..." mount -o rw,remount /product 2>/dev/null cp /tmp/aethex/bootanimation.zip /product/media/bootanimation.zip 2>/dev/null if [ $? -eq 0 ]; then chmod 644 /product/media/bootanimation.zip ui_print "- Boot animation installed!" else # Try /data/local/ as fallback cp /tmp/aethex/bootanimation.zip /data/local/bootanimation.zip 2>/dev/null chmod 644 /data/local/bootanimation.zip 2>/dev/null ui_print "- Boot animation installed to fallback location" fi fi ui_print "" ui_print "================================" ui_print " All done! Reboot now." ui_print "================================" # Cleanup rm -rf /tmp/aethex exit 0