MagiskHidePropsConf/common/post-fs-data.sh

136 lines
3.8 KiB
Bash
Raw Normal View History

2017-12-25 21:21:25 +00:00
#!/system/bin/sh
2018-03-18 15:39:43 +00:00
# MagiskHide Props Config
2019-02-02 12:37:20 +00:00
# Copyright (c) 2018-2019 Didgeridoohan @ XDA Developers
# Licence: MIT
2019-11-22 19:19:18 +00:00
#anch1
MODPATH=${0%/*}
BOOTSTAGE="post"
2019-03-27 10:50:00 +00:00
2019-11-22 19:19:18 +00:00
# Variables
MODULESPATH=${MODPATH%/*}
ADBPATH=${MODULESPATH%/*}
MHPCPATH=$ADBPATH/mhpc
LOGFILE=$MHPCPATH/propsconf.log
LASTLOGFILE=$MHPCPATH/propsconf_last.log
RUNFILE=$MHPCPATH/script_check
2018-03-18 15:39:43 +00:00
2019-11-22 19:19:18 +00:00
# Placeholder variables
MODVERSIONPH=VER_PLACEHOLDER
LATEFILEPH=LATE_PLACEHOLDER
2018-03-18 15:39:43 +00:00
2019-11-22 19:19:18 +00:00
# Saves the previous log (if available) and creates a new one
if [ -f "$LOGFILE" ]; then
mv -f $LOGFILE $LASTLOGFILE
fi
echo "***************************************************" > $LOGFILE 2>&1
echo "********* MagiskHide Props Config $MODVERSION ********" >> $LOGFILE 2>&1
echo "***************** By Didgeridoohan ***************" >> $LOGFILE 2>&1
echo "***************************************************" >> $LOGFILE 2>&1
echo ""
STRST="$(date +"%m-%d-%Y %H:%M:%S:%N") - Log start (regular execution)."
echo -e $STRST >> $LOGFILE 2>&1
echo -e $STRST > $RUNFILE 2>&1
2018-03-18 15:39:43 +00:00
2019-11-22 19:19:18 +00:00
# Save default prop values
resetprop > $MHPCPATH/defaultprops
echo "" >> $LOGFILE 2>&1
echo -e "$(date +"%Y-%m-%d %H:%M:%S:%N") - Saved default values" >> $LOGFILE 2>&1
2019-02-02 12:37:20 +00:00
2019-11-22 19:19:18 +00:00
{
# Creates/updates the script control file
touch $MHPCPATH/propsconf_postchk
2019-02-02 12:37:20 +00:00
2019-11-22 19:19:18 +00:00
# Logging
log_handler() {
echo "" >> $LOGFILE 2>&1
echo -e "$(date +"%Y-%m-%d %H:%M:%S:%N") - $1" >> $LOGFILE 2>&1
}
# Reset file locations
RESETFILELST="
/data/media/0/reset_mhpc
/data/reset_mhpc
$CACHELOC/reset_mhpc
"
2018-12-22 18:41:34 +00:00
2019-11-22 19:19:18 +00:00
# Check for the boot script and restore backup if deleted, or if the resetfile is present
RESETFILE=""
for ITEM in $RESETFILELST; do
if [ -f "$ITEM" ]; then
RESETFILE="$ITEM"
break
2019-05-04 18:57:59 +00:00
fi
2019-11-22 19:19:18 +00:00
done
if [ ! -s "$LATEFILE" ] || [ -f "$RESETFILE" ]; then
if [ -f "$RESETFILE" ]; then
RSTTXT="Resetting"
for ITEM in $RESETFILELST; do
rm -f $ITEM
done
else
RSTTXT="Restoring"
if [ -f "$LATEFILE" ]; then
log_handler "The module settings file was empty."
else
log_handler "The module settings file could not be found."
fi
fi
log_handler "$RSTTXT module settings file (${LATEFILE})."
cp -af $MODPATH/propsconf_late $LATEFILE >> $LOGFILE 2>&1
rm -f $MODPATH/system.prop >> $LOGFILE 2>&1
2019-02-02 12:37:20 +00:00
fi
2019-11-22 19:19:18 +00:00
# Loading module settings
. $LATEFILE
2019-02-02 12:37:20 +00:00
2019-11-22 19:19:18 +00:00
# Edits prop values if set for post-fs-data
if [ "$OPTIONBOOT" == 1 ] || [ "$OPTIONBOOT" != 1 -a "$PRINTSTAGE" == 1 ] || [ "$OPTIONBOOT" != 1 -a "$PATCHSTAGE" == 1 ] || [ "$OPTIONBOOT" != 1 -a "$SIMSTAGE" == 1 ] || [ "$CUSTOMPROPSPOST" ] || [ "$DELETEPROPS" ]; then
# Load functions
. $MODPATH/util_functions.sh
echo -e "\n----------------------------------------" >> $LOGFILE 2>&1
log_handler "Editing prop values in post-fs-data mode."
if [ "$OPTIONBOOT" == 1 ]; then
# Setting/Changing fingerprint
if [ "$PRINTSTAGE" == 0 ]; then
print_edit
fi
# Setting/Changing security patch date
if [ "$PATCHSTAGE" == 0 ]; then
patch_edit
fi
# Setting device simulation props
if [ "$SIMSTAGE" == 0 ]; then
dev_sim_edit
fi
# Setting custom props
custom_edit "CUSTOMPROPS"
fi
# Edit fingerprint if set for post-fs-data
if [ "$OPTIONBOOT" != 1 ] && [ "$PRINTSTAGE" == 1 ]; then
print_edit
fi
# Edit security patch date if set for post-fs-data
if [ "$OPTIONBOOT" != 1 ] && [ "$PATCHSTAGE" == 1 ]; then
patch_edit
fi
# Edit simulation props if set for post-fs-data
if [ "$OPTIONBOOT" != 1 ] && [ "$SIMSTAGE" == 1 ]; then
dev_sim_edit
fi
# Edit custom props set for post-fs-data
custom_edit "CUSTOMPROPSPOST"
# Deleting props
prop_del
echo -e "\n----------------------------------------" >> $LOGFILE 2>&1
2019-03-27 10:50:00 +00:00
fi
2019-02-02 12:37:20 +00:00
2019-11-22 19:19:18 +00:00
FNSH="\n$(date +"%Y-%m-%d %H:%M:%S:%N") - post-fs-data.sh module script finished."
echo -e $FNSH >> $LOGFILE 2>&1
echo -e $FNSH >> $RUNFILE 2>&1
2018-03-18 15:39:43 +00:00
2019-11-22 19:19:18 +00:00
# Deletes the post-fs-data control file
rm -f $MHPCPATH/propsconf_postchk
} &