action: validate before generate new pif.json

prevent empty value pif.json
This commit is contained in:
KOWX712 2025-04-19 22:20:43 +08:00
parent 150f115f43
commit 17f8606e7e

View File

@ -5,6 +5,14 @@ MODDIR=/data/adb/modules/playintegrityfix
version=$(grep "^version=" $MODDIR/module.prop | sed 's/version=//g') version=$(grep "^version=" $MODDIR/module.prop | sed 's/version=//g')
FORCE_PREVIEW=1 FORCE_PREVIEW=1
# lets try to use tmpfs for processing
TEMPDIR="$MODDIR/temp" #fallback
[ -w /sbin ] && TEMPDIR="/sbin/playintegrityfix"
[ -w /debug_ramdisk ] && TEMPDIR="/debug_ramdisk/playintegrityfix"
[ -w /dev ] && TEMPDIR="/dev/playintegrityfix"
mkdir -p "$TEMPDIR"
cd "$TEMPDIR"
echo "[+] PlayIntegrityFix $version" echo "[+] PlayIntegrityFix $version"
echo "[+] $(basename "$0")" echo "[+] $(basename "$0")"
printf "\n\n" printf "\n\n"
@ -20,6 +28,8 @@ sleep_pause() {
download_fail() { download_fail() {
dl_domain=$(echo "$1" | awk -F[/:] '{print $4}') dl_domain=$(echo "$1" | awk -F[/:] '{print $4}')
echo "$1" | grep -q "\.zip$" && return echo "$1" | grep -q "\.zip$" && return
# Clean up on download fail
rm -rf "$TEMPDIR"
ping -c 1 -W 5 "$dl_domain" > /dev/null 2>&1 || { 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" echo "[!] Unable to connect to $dl_domain, please check your internet connection and try again"
sleep_pause sleep_pause
@ -52,14 +62,6 @@ set_random_beta() {
PRODUCT=$(echo "$PRODUCT_LIST" | sed -n "$((rand_index + 1))p") PRODUCT=$(echo "$PRODUCT_LIST" | sed -n "$((rand_index + 1))p")
} }
# lets try to use tmpfs for processing
TEMPDIR="$MODDIR/temp" #fallback
[ -w /sbin ] && TEMPDIR="/sbin/playintegrityfix"
[ -w /debug_ramdisk ] && TEMPDIR="/debug_ramdisk/playintegrityfix"
[ -w /dev ] && TEMPDIR="/dev/playintegrityfix"
mkdir -p "$TEMPDIR"
cd "$TEMPDIR"
# Get latest Pixel Beta information # Get latest Pixel Beta information
download https://developer.android.com/about/versions PIXEL_VERSIONS_HTML download https://developer.android.com/about/versions PIXEL_VERSIONS_HTML
BETA_URL=$(grep -o 'https://developer.android.com/about/versions/.*[0-9]"' PIXEL_VERSIONS_HTML | sort -ru | cut -d\" -f1 | head -n1) BETA_URL=$(grep -o 'https://developer.android.com/about/versions/.*[0-9]"' PIXEL_VERSIONS_HTML | sort -ru | cut -d\" -f1 | head -n1)
@ -93,6 +95,12 @@ echo "$MODEL ($PRODUCT)"
FINGERPRINT="$(strings PIXEL_ZIP_METADATA | grep -am1 'post-build=' | cut -d= -f2)" FINGERPRINT="$(strings PIXEL_ZIP_METADATA | grep -am1 'post-build=' | cut -d= -f2)"
SECURITY_PATCH="$(strings PIXEL_ZIP_METADATA | grep -am1 'security-patch-level=' | cut -d= -f2)" SECURITY_PATCH="$(strings PIXEL_ZIP_METADATA | grep -am1 'security-patch-level=' | cut -d= -f2)"
# Validate required field to prevent empty pif.json
if [ -z "$FINGERPRINT" ] || [ -z "$SECURITY_PATCH" ]; then
# link to download pixel rom metadata that skipped connection check due to ulimit
download_fail "https://dl.google.com"
fi
echo "- Dumping values to pif.json ..." echo "- Dumping values to pif.json ..."
cat <<EOF | tee pif.json cat <<EOF | tee pif.json
{ {