Separate common installation and boot-time scripts and source it

This commit is contained in:
osm0sis
2024-03-02 21:59:34 -04:00
parent 4ab07b71f8
commit 79052ff455
5 changed files with 47 additions and 69 deletions

View File

@@ -48,3 +48,6 @@ resetprop_if_match() {
[[ "$(resetprop "$NAME")" = *"$CONTAINS"* ]] && resetprop_hexpatch "$NAME" "$VALUE" [[ "$(resetprop "$NAME")" = *"$CONTAINS"* ]] && resetprop_hexpatch "$NAME" "$VALUE"
} }
# stub for boot-time
ui_print() { return; }

35
module/common_setup.sh Normal file
View File

@@ -0,0 +1,35 @@
# Remove any definitely conflicting modules that are installed
if [ -d /data/adb/modules/safetynet-fix ]; then
touch /data/adb/modules/safetynet-fix/remove
ui_print "! Universal SafetyNet Fix (USNF) module will be removed on next reboot"
fi
# Replace/hide conflicting custom ROM injection app folders/files to disable them
LIST=$MODPATH/example.app_replace.list
[ -f "$MODPATH/custom.app_replace.list" ] && LIST=$MODPATH/custom.app_replace.list
for APP in $(grep -v '^#' $LIST); do
if [ -e "$APP" ]; then
case $APP in
/system/*) HIDEPATH=$MODPATH/$APP;;
*) HIDEPATH=$MODPATH/system/$APP;;
esac
if [ -d "$APP" ]; then
mkdir -p $HIDEPATH
if [ "$KSU" = "true" -o "$APATCH" = "true" ]; then
setfattr -n trusted.overlay.opaque -v y $HIDEPATH
else
touch $HIDEPATH/.replace
fi
else
mkdir -p $(dirname $HIDEPATH)
if [ "$KSU" = "true" -o "$APATCH" = "true" ]; then
mknod $HIDEPATH c 0 0
else
touch $HIDEPATH
fi
fi
if [[ -d "$APP" -o "$APP" = *".apk" ]]; then
ui_print "! $(basename $APP .apk) ROM app disabled, please uninstall any user app versions/updates after next reboot"
fi
fi
done

View File

@@ -11,44 +11,13 @@ for FILE in custom.app_replace.list custom.pif.json; do
fi fi
done done
# Remove/warn if conflicting modules are installed # Warn if potentially conflicting modules are installed
if [ -d /data/adb/modules/safetynet-fix ]; then
touch /data/adb/modules/safetynet-fix/remove
ui_print "! Universal SafetyNet Fix (USNF) module will be removed on next reboot"
fi
if [ -d /data/adb/modules/MagiskHidePropsConf ]; then if [ -d /data/adb/modules/MagiskHidePropsConf ]; then
ui_print "! MagiskHidePropsConfig (MHPC) module may cause issues with PIF" ui_print "! MagiskHidePropsConfig (MHPC) module may cause issues with PIF"
fi fi
# Replace/hide conflicting custom ROM injection app folders/files to disable them # Run common tasks for installation and boot-time
LIST=$MODPATH/example.app_replace.list . $MODPATH/common_setup.sh
[ -f "$MODPATH/custom.app_replace.list" ] && LIST=$MODPATH/custom.app_replace.list
for APP in $(grep -v '^#' $LIST); do
if [ -e "$APP" ]; then
case $APP in
/system/*) HIDEPATH=$MODPATH/$APP;;
*) HIDEPATH=$MODPATH/system/$APP;;
esac
if [ -d "$APP" ]; then
mkdir -p $HIDEPATH
if [ "$KSU" = "true" -o "$APATCH" = "true" ]; then
setfattr -n trusted.overlay.opaque -v y $HIDEPATH
else
touch $HIDEPATH/.replace
fi
else
mkdir -p $(dirname $HIDEPATH)
if [ "$KSU" = "true" -o "$APATCH" = "true" ]; then
mknod $HIDEPATH c 0 0
else
touch $HIDEPATH
fi
fi
if [[ -d "$APP" -o "$APP" = *".apk" ]]; then
ui_print "! $(basename $APP .apk) ROM app disabled, please uninstall any user app versions/updates after next reboot"
fi
fi
done
# Migrate custom.pif.json to latest defaults if needed # Migrate custom.pif.json to latest defaults if needed
if [ -f "$MODPATH/custom.pif.json" ] && ! grep -q "api_level" $MODPATH/custom.pif.json; then if [ -f "$MODPATH/custom.pif.json" ] && ! grep -q "api_level" $MODPATH/custom.pif.json; then

View File

@@ -1,42 +1,13 @@
MODDIR="${0%/*}" MODPATH="${0%/*}"
. "$MODDIR/common.sh" . $MODPATH/common_func.sh
# Remove Play Services from Magisk Denylist when set to enforcing # Remove Play Services from Magisk Denylist when set to enforcing
if magisk --denylist status; then if magisk --denylist status; then
magisk --denylist rm com.google.android.gms magisk --denylist rm com.google.android.gms
fi fi
# Remove conflicting modules if installed # Run common tasks for installation and boot-time
if [ -d /data/adb/modules/safetynet-fix ]; then . $MODPATH/common_setup.sh
touch /data/adb/modules/safetynet-fix/remove
fi
# Replace/hide conflicting custom ROM injection app folders/files to disable them
LIST=$MODDIR/example.app_replace.list
[ -f "$MODDIR/custom.app_replace.list" ] && LIST=$MODDIR/custom.app_replace.list
for APP in $(grep -v '^#' $LIST); do
if [ -e "$APP" ]; then
case $APP in
/system/*) HIDEPATH=$MODDIR/$APP;;
*) HIDEPATH=$MODDIR/system/$APP;;
esac
if [ -d "$APP" ]; then
mkdir -p $HIDEPATH
if [ "$KSU" = "true" -o "$APATCH" = "true" ]; then
setfattr -n trusted.overlay.opaque -v y $HIDEPATH
else
touch $HIDEPATH/.replace
fi
else
mkdir -p $(dirname $HIDEPATH)
if [ "$KSU" = "true" -o "$APATCH" = "true" ]; then
mknod $HIDEPATH c 0 0
else
touch $HIDEPATH
fi
fi
fi
done
# Conditional early sensitive properties # Conditional early sensitive properties

View File

@@ -1,5 +1,5 @@
MODDIR="${0%/*}" MODPATH="${0%/*}"
. "$MODDIR/common.sh" . $MODPATH/common_func.sh
# Conditional sensitive properties # Conditional sensitive properties