MagiskHidePropsConf/common/propsconf_late
Didgeridoohan cd65cd46fc
v2.3.2-v21
2018-07-19 21:47:43 +02:00

199 lines
4.7 KiB
Bash

#!/system/bin/sh
# MagiskHide Props Config
# By Didgeridoohan @ XDA Developers
# This is a script file for the Magisk module "MagiskHide Props Config" By Didgeridoohan @ XDA Developers.
# DO NOT DELETE!
# Unless: If you don't have the module installed something has gone horribly wrong and this file is an orphan.
# In that case, feel free to delete it.
# Script version
SCRIPTV=11
SETTRANSF=1
# Variables
IMGPATH=IMG_PLACEHOLDER
MODPATH=$IMGPATH/MagiskHidePropsConf
CACHELOC=CACHE_PLACEHOLDER
LATELOGFILE=$CACHELOC/propsconf_latefile.log
FINGERPRINTENB=1
PRINTEDIT=0
BUILDPROPENB=1
FILESAFE=1
BUILDEDIT=0
DEFAULTEDIT=0
PROPCOUNT=0
PROPEDIT=0
CUSTOMEDIT=0
DELEDIT=0
REBOOTCHK=0
OPTIONLATE=1
OPTIONCOLOUR=1
OPTIONWEB=1
CACHEFILES="
propsconf.log
propsconf_last.log
propsconf_install.log
propsconf_conf
reset_mhpc
"
rm -f $LATELOGFILE
# Function to clean up different files after the module has been uninstalled
cleanup() {
echo "Cleaning up files in $CACHELOC." >> $LATELOGFILE
for ITEM in $CACHEFILES; do
if [ -f "$CACHELOC/$ITEM" ]; then
echo "Deleting ${ITEM}." >> $LATELOGFILE
rm -fv $CACHELOC/$ITEM >> $LATELOGFILE
fi
done
# Suicide.
echo "Removing scripts." >> $LATELOGFILE
rm -fv $IMGPATH/.core/post-fs-data.d/propsconf_post >> $LATELOGFILE
rm -fv $0 >> $LATELOGFILE
}
# Checks if the module is installed. Deletes itself if it isn't.
if [ -d "$MODPATH" ]; then
# Checks if the module is set for removal
if [ -f "$MODPATH/remove" ]; then
echo "Module set for removal." >> $LATELOGFILE
# Cleanup
cleanup
else
# Load functions
. $MODPATH/util_functions.sh
if [ "$OPTIONLATE" == 0 ]; then
until [ ! -f "$POSTCHKFILE" ]; do
sleep 1
done
fi
log_script_chk "Running boot script."
if [ -f "$MODPATH/disable" ]; then
log_start
log_handler "Module disabled."
else
# Checks for the Universal SafetyNet Fix module and similar modules editing the device fingerprint
PRINTMODULE=false
for USNF in $USNFLIST; do
if [ -d "$IMGPATH/$USNF" ]; then
NAME=$(get_file_value $IMGPATH/$USNF/module.prop "name=")
log_handler "'$NAME' installed (modifies the device fingerprint)."
PRINTMODULE=true
fi
done
if [ "$PRINTMODULE" == "true" ]; then
replace_fn FINGERPRINTENB 1 0 $LATEFILE
log_handler "Fingerprint modification disabled."
else
replace_fn FINGERPRINTENB 0 1 $LATEFILE
fi
# Check the reboot variable
if [ "$(get_file_value $LATEFILE "REBOOTCHK\=")" == 1 ]; then
replace_fn REBOOTCHK 1 0 $LATEFILE
fi
# ---Original values---
# default.prop
ORIGDEBUGGABLE=""
ORIGSECURE=""
# build.prop
ORIGTYPE=""
ORIGTAGS=""
ORIGSELINUX=""
ORIGFINGERPRINT=""
# ---Module values---
MODULEDEBUGGABLE=""
MODULESECURE=""
MODULETYPE=""
MODULETAGS=""
MODULESELINUX=""
MODULEFINGERPRINT=""
# ---Custom prop values---
CUSTOMPROPS=""
# ---Delete prop values---
DELETEPROPS=""
# ---MagiskHide sensitive props---
REDEBUGGABLE=false
RESECURE=false
RETYPE=false
RETAGS=false
RESELINUX=false
# ---Editing default.prop---
SETDEBUGGABLE=false
SETSECURE=false
# ---Editing build.prop---
SETTYPE=false
SETTAGS=false
SETSELINUX=false
SETFINGERPRINT=false
# Edits prop values if set for late_start service
if [ "$OPTIONLATE" == 1 ]; then
# ---Setting/Changing fingerprint---
print_edit
# ---Setting custom props---
custom_edit
# ---Deleting props---
prop_del
fi
# Edit MagiskHide sensitive values
if [ "$PROPEDIT" == 1 ]; then
log_handler "Changing sensitive props."
for ITEM in $PROPSLIST; do
PROP=$(get_prop_type $ITEM)
REPROP=$(echo "RE${PROP}" | tr '[:lower:]' '[:upper:]')
MODULEPROP=$(echo "MODULE${PROP}" | tr '[:lower:]' '[:upper:]')
if [ "$(eval "echo \$$REPROP")" == "true" ]; then
log_handler "Changing/writing $ITEM."
resetprop -v $ITEM 2>> $LOGFILE
resetprop -nv $ITEM $(eval "echo \$$MODULEPROP") 2>> $LOGFILE
fi
done
fi
# ---Edits default.prop---
if [ "$DEFAULTEDIT" == 1 ] && [ "$FILESAFE" == 0 ]; then
log_handler "Editing default.prop."
mount -wo remount rootfs /
change_prop_file "default"
mount -ro remount rootfs /
else
log_handler "Default.prop editing disabled."
fi
fi
# Get currently saved values
log_handler "Checking current values."
curr_values
# Check if the late_start service log file exists.
if [ -f "$LATELOGFILE" ]; then
log_handler "Removing late_start service log ($LATELOGFILE)."
rm -fv $LATELOGFILE >> $LOGFILE
fi
log_script_chk "Boot script finished.\n\n=================="
fi
else
echo "$MODPATH not found." >> $LATELOGFILE
echo "Module no longer installed." >> $LATELOGFILE
# Cleanup
cleanup
fi