Skip to content

Commit

Permalink
Merge pull request #522 from backslashxx/action
Browse files Browse the repository at this point in the history
scripts/action: alert user properly on failure
  • Loading branch information
chiteroman authored Jan 26, 2025
2 parents f0ce683 + 50c129e commit 4eeddec
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions module/action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,26 @@ echo "[+] PlayIntegrityFix $version"
echo "[+] $(basename "$0")"
printf "\n\n"

download() { busybox wget -T 10 --no-check-certificate -qO - "$1"; }
download_fail() {
dl_domain=$(echo "$1" | awk -F[/:] '{print $4}')
ping -c 1 -W 5 "$dl_domain" > /dev/null 2>&1 || {
echo "[!] Unable to connect to $dl_domain, please check your internet connection and try again"
sleep_pause
exit 1
}
conflict_module=$(ls /data/adb/modules | grep busybox)
for i in $conflict_module; do
echo "[!] Please remove $conflict_module and try again."
done
echo "[!] download failed!"
echo "[x] bailing out!"
sleep_pause
exit 1
}

download() { busybox wget -T 10 --no-check-certificate -qO - "$1" > "$2" || download_fail "$1"; }
if command -v curl > /dev/null 2>&1; then
download() { curl --connect-timeout 10 -s "$1"; }
download() { curl --connect-timeout 10 -s "$1" > "$2" || download_fail "$1"; }
fi

sleep_pause() {
Expand All @@ -32,21 +49,14 @@ set_random_beta() {
DEVICE=$(echo "$PRODUCT" | sed 's/_beta//')
}

download_fail() {
echo "[!] download failed!"
echo "[x] bailing out!"
sleep_pause
exit 1
}

# lets try to use tmpfs for processing
TEMPDIR="$MODDIR/temp" #fallback
[ -w /sbin ] && TEMPDIR="/sbin/playintegrityfix"
[ -w /debug_ramdisk ] && TEMPDIR="/debug_ramdisk/playintegrityfix"
mkdir -p "$TEMPDIR"
cd "$TEMPDIR"

download https://developer.android.com/topic/generic-system-image/releases > PIXEL_GSI_HTML || download_fail
download https://developer.android.com/topic/generic-system-image/releases PIXEL_GSI_HTML
grep -m1 -o 'li>.*(Beta)' PIXEL_GSI_HTML | cut -d\> -f2
grep -m1 -o 'Date:.*' PIXEL_GSI_HTML

Expand All @@ -60,13 +70,13 @@ fi
ID="$(grep -m1 -o 'Build:.*' PIXEL_GSI_HTML | cut -d' ' -f2)"
INCREMENTAL="$(grep -m1 -o "$ID-.*-" PIXEL_GSI_HTML | cut -d- -f2)"

download "https://developer.android.com$(grep -m1 'corresponding Google Pixel builds' PIXEL_GSI_HTML | grep -o 'href.*' | cut -d\" -f2)" > PIXEL_GET_HTML || download_fail
download "https://developer.android.com$(grep -m1 'Pixel downloads page' PIXEL_GET_HTML | grep -o 'href.*' | cut -d\" -f2)" > PIXEL_BETA_HTML || download_fail
download "https://developer.android.com$(grep -m1 'corresponding Google Pixel builds' PIXEL_GSI_HTML | grep -o 'href.*' | cut -d\" -f2)" PIXEL_GET_HTML
download "https://developer.android.com$(grep -m1 'Pixel downloads page' PIXEL_GET_HTML | grep -o 'href.*' | cut -d\" -f2)" PIXEL_BETA_HTML

MODEL_LIST="$(grep -A1 'tr id=' PIXEL_BETA_HTML | grep 'td' | sed 's;.*<td>\(.*\)</td>;\1;')"
PRODUCT_LIST="$(grep -o 'factory/.*_beta' PIXEL_BETA_HTML | cut -d/ -f2)"

download https://source.android.com/docs/security/bulletin/pixel > PIXEL_SECBULL_HTML || download_fail
download https://source.android.com/docs/security/bulletin/pixel PIXEL_SECBULL_HTML

SECURITY_PATCH="$(grep -A15 "$(grep -m1 -o 'Security patch level:.*' PIXEL_GSI_HTML | cut -d' ' -f4-)" PIXEL_SECBULL_HTML | grep -m1 -B1 '</tr>' | grep 'td' | sed 's;.*<td>\(.*\)</td>;\1;')"

Expand Down

0 comments on commit 4eeddec

Please sign in to comment.