-
Notifications
You must be signed in to change notification settings - Fork 5
/
prop_mHideGP.sh
executable file
·217 lines (184 loc) · 4.79 KB
/
prop_mHideGP.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/bin/bash
# Pull prop settings from factory prop files
# ipdev @ xda-developers
# Originally (and still) written to grab needed/useful props for use with MagiskHide Props Config module
# by Didgeridoohan @ xda-developers
# https://forum.xda-developers.com/apps/magisk/module-magiskhide-props-config-t3789228
# This script will run the mHideGP script on all prop files in the same directory
# It will look for file(s) named or ending in: build.prop default.prop prop.default or getprop.props
# Merge the generated mhp files into mHide-printslist-DATE.sh.
# Remove all the generated mph files.
# To use.
# Copy prop_mHideGP.sh and mHideGP.sh into a directory
# Copy device prop files into the same directory
# Run prop_mHideGP.sh
#
# Set variables
TDIR=$(pwd)
DATE=$(date '+%Y%m%d')
# DATE=$(date '+%Y%m%d_%H%M')
OUT=mHide-printslist-"$DATE".sh
SCRIPT=prop_mHideGP.sh
# Set functions
add_notes() {
echo "\"" >> $OUT
echo "######" >> $OUT
echo "## The above \" was added to close custom printslist list early." >> $OUT
echo "## Just to clean it up a little. Lines below will not display on screen." >> $OUT
echo "## Due to updates in Magisk and/or mHide module." >> $OUT
echo "## The rest of the file is now block commented to hide/clean it up further." >> $OUT
echo "######" >> $OUT
}
backup() {
if [ -f "$OUT" ]; then
FLTM=$(date -r "$OUT" '+%H%M')
BACKUPFILE=$(printf "$OUT" | sed 's/.sh/.'"$FLTM"'/g')
mv "$OUT" "$BACKUPFILE"
fi
}
check_files() {
echo ""
if [ ! -f mHideGP.sh ]; then
echo " Missing mHideGP script."
echo ""
exit 1;
fi
}
exit_0() {
if [ $ANDROID = "TRUE" ]; then
return 0; exit 0;
else
exit 0;
fi
}
exit_1() {
if [ $ANDROID = "TRUE" ]; then
return 1; exit 1;
else
exit 1;
fi
}
rename_prop_files() {
if [ -f build.prop ]; then
FLDT=$(date -r build.prop '+%Y%m%d')
mv build.prop "$FLDT"_build.prop
fi
if [ -f prop.default ]; then
FLDT=$(date -r prop.default '+%Y%m%d')
mv prop.default "$FLDT"_prop.default
fi
if [ -f default.prop ]; then
FLDT=$(date -r default.prop '+%Y%m%d')
mv default.prop "$FLDT"_default.prop
fi
if [ -f getprop.props ]; then
FLDT=$(date -r getprop.props '+%Y%m%d')
mv getprop.props "$FLDT"_getprop.props
fi
}
set_target_directory() {
if [ ! -f "$SCRIPT" ]; then
TDIR=$(lsof 2>/dev/null | grep -o '[^ ]*$' | grep -m1 "$SCRIPT" | sed 's/\/'"$SCRIPT"'//g');
cd $TDIR;
fi
}
# Determine if running on an Android device or MacOS/Linux.
if [ -f /system/bin/sh ] || [ -f /system/bin/toybox ] || [ -f /system/bin/toolbox ]; then
# Android device
ANDROID=TRUE
else
# MacOS/Linux
ANDROID=FALSE
fi
# Reset and move to the target directory if needed.
set_target_directory
# Check for required files.
check_files
# Rename additional prop files if needed.
rename_prop_files
# Run mHideGP on additional prop files in the current directory.
AdditionalPropFile=('build.prop' 'default.prop' 'prop.default' 'getprop.props')
if [ $ANDROID = "TRUE" ]; then
echo ""
for pfile in "${AdditionalPropFile[@]}"; do
{
for propfile in *"$pfile"; do
{
if [ -f "$propfile" ]; then
echo "$propfile"
mv "$propfile" "$pfile"
sh "$TDIR"/mHideGP.sh > /dev/null
if [ -f "$pfile" ]; then
mv "$pfile" "$propfile"
fi;
fi;
}
done;
}
done;
fi;
if [ $ANDROID = "FALSE" ]; then
echo ""
for pfile in "${AdditionalPropFile[@]}"; do
{
for propfile in *"$pfile"; do
{
if [ -f "$propfile" ]; then
echo "$propfile"
mv "$propfile" "$pfile"
"$TDIR"/mHideGP.sh > /dev/null
if [ -f "$pfile" ]; then
mv "$pfile" "$propfile"
fi;
fi;
}
done;
}
done;
fi;
# Backup if needed
backup
# Concatenate (Merge multiple files into a new file.)
## The output file is written in order of the mhp file name(s).
## The mHideGP script will hopefully name them in the correct order.
# Add mHide fingerprint from the mhp files(s) to $OUT file.
for mPrint in mhp_*.sh; do
cat $mPrint | sed '1!d' >> "$OUT"
done
# Add a few notes to $OUT file.
add_notes
# Add all the rest of the device props from the mhp file(s) to the $OUT file.
for dProps in mhp_*.sh; do
cat $dProps | sed '/#/!d' | sed '/##/d' >> "$OUT"
done
# Cleanup
# (Not sure if I like the echo clutter. Removed for now.)
## echo ""; echo "Removing the separate mhp file(s).";
for file in mhp_*.sh; do
{
## echo $file
rm $file
}
done
# Note backup
if [ -f "$BACKUPFILE" ]; then
echo ""; echo "Your previous "$OUT" file was renamed to "$BACKUPFILE"";
fi
# Correct permissions if needed
for file in mhc_*; do
chmod 0664 $file 2>/dev/null
done;
for file in mhp_*; do
chmod 0664 $file 2>/dev/null
done;
for file in mHide-*; do
chmod 0664 $file 2>/dev/null
done;
for file in *.img; do
chmod 0664 $file 2>/dev/null
done;
# Finish script
echo ""; echo "New mHide-printslist file saved as "$OUT""
echo ""; echo "Done."; echo "";
#
exit_0;