diff --git a/module/action.sh b/module/action.sh index e78373ff..b773b85f 100644 --- a/module/action.sh +++ b/module/action.sh @@ -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 $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() { @@ -32,13 +49,6 @@ 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" @@ -46,7 +56,7 @@ TEMPDIR="$MODDIR/temp" #fallback 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 @@ -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;.*\(.*\);\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 '' | grep 'td' | sed 's;.*\(.*\);\1;')"