MagiskHidePropsConf/common/post-fs-data.sh

105 lines
3.3 KiB
Bash
Raw Normal View History

2017-12-25 21:21:25 +00:00
#!/system/bin/sh
2018-04-15 22:05:33 +00:00
# Please don't hardcode /magisk/modname/... ; instead, please use $MODPATH/...
2017-12-25 21:21:25 +00:00
# This will make your scripts compatible even if Magisk change its mount point in the future
2018-04-15 22:05:33 +00:00
MODPATH=${0%/*}
2017-12-25 21:21:25 +00:00
# This script will be executed in post-fs-data mode
# More info in the main Magisk thread
2018-03-18 15:39:43 +00:00
# MagiskHide Props Config
2018-04-15 22:05:33 +00:00
# By Didgeridoohan @ XDA Developers
2018-03-18 15:39:43 +00:00
# Variables
2018-04-15 22:05:33 +00:00
IMGPATH=$(dirname "$MODPATH")
2018-03-18 15:39:43 +00:00
# Load functions
2018-04-15 22:05:33 +00:00
. $MODPATH/util_functions.sh
2018-03-18 15:39:43 +00:00
2018-04-19 03:13:40 +00:00
# Clears out the script check file
rm -f $RUNFILE
touch $RUNFILE
2018-04-29 09:14:35 +00:00
# Start logging
log_start
2018-03-18 15:39:43 +00:00
2018-04-15 22:05:33 +00:00
# Check for boot scripts and restore backup if deleted, or if the resetfile is present
if [ ! -f "$LATEFILE" ] || [ -f "$RESETFILE" ]; then
cp -af $MODPATH/propsconf_late $LATEFILE
2018-03-18 15:39:43 +00:00
chmod 755 $LATEFILE
2018-04-25 22:17:32 +00:00
if [ -f "$RESETFILE" ]; then
RSTTXT="reset"
else
RSTTXT="restored"
fi
log_handler "Boot script $RSTTXT (${LATEFILE})."
2018-03-18 15:39:43 +00:00
fi
# Get the current values saved in propsconf_late
2018-04-15 22:05:33 +00:00
latefile_values
2018-04-25 22:17:32 +00:00
# Get default values
2018-04-15 22:05:33 +00:00
file_values
2018-03-18 15:39:43 +00:00
# Save default file values in propsconf_late
2018-04-25 22:17:32 +00:00
replace_fn FILEDEBUGGABLE "\"$LATEFILEDEBUGGABLE\"" "\"$FILEDEBUGGABLE\"" $LATEFILE
replace_fn FILESECURE "\"$LATEFILESECURE\"" "\"$FILESECURE\"" $LATEFILE
replace_fn FILETYPE "\"$LATEFILETYPE\"" "\"$FILETYPE\"" $LATEFILE
replace_fn FILETAGS "\"$LATEFILETAGS\"" "\"$FILETAGS\"" $LATEFILE
replace_fn FILESELINUX "\"$LATEFILESELINUX\"" "\"$FILESELINUX\"" $LATEFILE
replace_fn FILEFINGERPRINT "\"$LATEFILEFINGERPRINT\"" "\"$FILEFINGERPRINT\"" $LATEFILE
log_handler "Default values saved to $LATEFILE."
2018-04-15 22:05:33 +00:00
2018-03-18 15:39:43 +00:00
# Check if original file values are safe
2018-04-15 22:05:33 +00:00
orig_safe
2018-04-29 09:14:35 +00:00
# Checks for configuration file
config_file
2018-04-15 22:05:33 +00:00
# Edits build.prop
2018-03-18 15:39:43 +00:00
if [ "$(get_file_value $LATEFILE "FILESAFE=")" == 0 ]; then
2018-04-25 22:17:32 +00:00
log_handler "Checking for conflicting build.prop modules."
2018-03-18 15:39:43 +00:00
# Checks if any other modules are using a local copy of build.prop
BUILDMODULE=false
2018-04-15 22:05:33 +00:00
MODID=$(get_file_value $MODPATH/module.prop "id=")
2018-03-18 15:39:43 +00:00
for D in $(ls $IMGPATH); do
if [ $D != "$MODID" ]; then
if [ -f "$IMGPATH/$D/system/build.prop" ]; then
NAME=$(get_file_value $IMGPATH/$D/module.prop "name=")
log_handler "Conflicting build.prop editing in module '$NAME'."
BUILDMODULE=true
fi
fi
done
if [ "$BUILDMODULE" == "true" ]; then
2018-04-25 22:17:32 +00:00
replace_fn BUILDPROPENB 1 0 $LATEFILE
2018-03-18 15:39:43 +00:00
else
2018-04-25 22:17:32 +00:00
replace_fn BUILDPROPENB 0 1 $LATEFILE
2018-03-18 15:39:43 +00:00
fi
# Copies the stock build.prop to the module. Only if set in propsconf_late.
if [ "$(get_file_value $LATEFILE "BUILDPROPENB=")" == 1 ] && [ "$(get_file_value $LATEFILE "BUILDEDIT=")" == 1 ]; then
2018-04-26 20:40:46 +00:00
cp -f /system/build.prop $MODPATH/system/build.prop
2018-03-18 15:39:43 +00:00
log_handler "Stock build.prop copied from /system."
# Edits the module copy of build.prop
2018-04-19 03:13:40 +00:00
module_values
2018-04-29 09:14:35 +00:00
log_handler "Editing build.prop."
# ro.build props
change_prop_file "build"
2018-04-26 20:40:46 +00:00
# Fingerprint
2018-04-25 22:17:32 +00:00
if [ "$MODULEFINGERPRINT" ] && [ "$(get_file_value $LATEFILE "SETFINGERPRINT=")" == "true" ]; then
PRINTSTMP="$(cat /system/build.prop | grep "$FILEFINGERPRINT")"
2018-04-19 03:13:40 +00:00
for ITEM in $PRINTSTMP; do
2018-05-06 09:57:49 +00:00
replace_fn $(get_eq_left "$ITEM") $(get_eq_right "$ITEM") $MODULEFINGERPRINT $MODPATH/system/build.prop && log_handler "$(get_eq_left "$ITEM")=$MODULEFINGERPRINT"
2018-04-19 03:13:40 +00:00
done
2018-03-18 15:39:43 +00:00
fi
else
2018-04-15 22:05:33 +00:00
rm -f $MODPATH/system/build.prop
2018-03-18 15:39:43 +00:00
log_handler "Build.prop editing disabled."
fi
else
2018-04-15 22:05:33 +00:00
rm -f $MODPATH/system/build.prop
2018-03-18 15:39:43 +00:00
log_handler "Prop file editing disabled. All values ok."
fi
2018-04-19 03:13:40 +00:00
log_script_chk "post-fs-data.sh finished.\n\n===================="