Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts/action: alert user properly on failure #522

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading