Files
AXP-Resurection/scripts/009-wait-flash-cve-hi-batch1.sh
T
sunfish-admin deaaf42caa 009: Magisk ship pack through US-S5-1 + US-S4 OpenSSH/Jelly/Gallery2.
Release-keys/AVB, CVE clean+hi batches, Yama/slabrand, Pro branding,
bundled apps, and AXP-class product surface docs/scripts.
2026-10-05 10:42:00 +02:00

78 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Wait for hi-batch1 bacon on rom-dev01, then one-shot fastboot flash boot + reboot.
# Serial-pinned. No recovery loops. Exit if not booted in ~4 min.
set -euo pipefail
SSHCFG="${SSHCFG:-/home/aventura/Workspaces/AXP_Resurection/docs/ssh/config}"
SERIAL="${SERIAL:-11231JEC207477}"
LOCAL="${LOCAL:-/home/aventura/Workspaces/AXP_Resurection/.local-artifacts/009-flash-cve-hi-batch1}"
STATUS=detach-009-bacon-cve-hi-batch1.status
LOG="${LOG:-/tmp/009-wait-flash-cve-hi-batch1.log}"
mkdir -p "$LOCAL"
exec > >(tee -a "$LOG") 2>&1
echo "WAIT hi-batch1 start $(date -Is)"
st=""
for i in $(seq 1 180); do
st=$(ssh -F "$SSHCFG" -o BatchMode=yes -o ConnectTimeout=20 rom-dev01 \
"cat /srv/rom/artifacts/$STATUS" 2>/dev/null || echo status_unreadable)
echo "poll $i: $st"
# exit=141 = SIGPIPE from tee after successful bacon (false fail)
if echo "$st" | grep -qE '^exit=0|^exit=141'; then
break
fi
if echo "$st" | grep -qE '^exit=[1-9]|^exit=killed'; then
if echo "$st" | grep -q '^exit=141'; then
break
fi
echo BACON_FAILED
exit 1
fi
sleep 60
done
echo "$st" | grep -qE '^exit=0|^exit=141' || { echo TIMEOUT; exit 1; }
ART=$(ssh -F "$SSHCFG" -o BatchMode=yes rom-dev01 \
'ls -dt /srv/rom/artifacts/009-axp-los23-port/*-axp-stage1-combo4-cve-hi-batch1 2>/dev/null | head -1')
echo "ART=$ART"
test -n "$ART"
rsync -avP -e "ssh -F $SSHCFG -o BatchMode=yes" \
"rom-dev01:$ART/boot.img" "rom-dev01:$ART/README.txt" "rom-dev01:$ART/SHA256SUMS" "$LOCAL/"
cd "$LOCAL"
grep ' boot.img$' SHA256SUMS | sha256sum -c -
adb start-server >/dev/null 2>&1 || true
cur=$(adb -s "$SERIAL" get-state 2>/dev/null || true)
if [[ "$cur" == "device" ]]; then
echo "adb reboot bootloader once"
adb -s "$SERIAL" reboot bootloader
fi
for j in $(seq 1 40); do
fastboot devices 2>/dev/null | grep -q "$SERIAL" && break
sleep 2
done
fastboot devices | grep -q "$SERIAL" || { echo NO_FASTBOOT; exit 1; }
echo "fastboot flash boot (hi-batch1) once"
fastboot -s "$SERIAL" flash boot "$LOCAL/boot.img"
echo "fastboot reboot once"
fastboot -s "$SERIAL" reboot
for j in $(seq 1 60); do
sleep 5
cur=$(adb devices | awk -v s="$SERIAL" '$1==s{print $2}')
boot=$(adb -s "$SERIAL" shell getprop sys.boot_completed 2>/dev/null | tr -d '\r' || true)
echo "t=$((j*5))s adb=$cur boot=$boot"
if [[ "$cur" == "device" && "$boot" == "1" ]]; then
adb -s "$SERIAL" shell 'uname -a; getprop ro.boot.slot_suffix; pidof magiskd || true'
echo HI_BATCH1_BOOT_OK
exit 0
fi
if [[ "$j" -eq 48 ]]; then
echo NOT_BOOTED_4min leave_alone
exit 2
fi
done
echo BOOT_TIMEOUT
exit 2