Skip to content

Commit e15d6be

Browse files
authored
Add files via upload
1 parent 3e02bc3 commit e15d6be

File tree

11 files changed

+479045
-0
lines changed

11 files changed

+479045
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/sbin/sh
2+
3+
#################
4+
# Initialization
5+
#################
6+
7+
umask 022
8+
9+
# echo before loading util_functions
10+
ui_print() { echo "$1"; }
11+
12+
require_new_magisk() {
13+
ui_print "*******************************"
14+
ui_print " Please install Magisk v20.4+! "
15+
ui_print "*******************************"
16+
exit 1
17+
}
18+
19+
#########################
20+
# Load util_functions.sh
21+
#########################
22+
23+
OUTFD=$2
24+
ZIPFILE=$3
25+
26+
mount /data 2>/dev/null
27+
28+
[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
29+
. /data/adb/magisk/util_functions.sh
30+
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk
31+
32+
install_module
33+
exit 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#MAGISK

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
If you encounter any issues or believe something is not working as expected, please do not hesitate to reach out to me via Telegram!

common/functions.sh

Lines changed: 326 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,326 @@
1+
##########################################################################################
2+
#
3+
# MMT Extended Utility Functions
4+
#
5+
##########################################################################################
6+
7+
require_new_ksu() {
8+
ui_print "**********************************"
9+
ui_print " Please install KernelSU v0.6.6+! "
10+
ui_print "**********************************"
11+
exit 1
12+
}
13+
14+
umount_mirrors() {
15+
[ -d $ORIGDIR ] || return 0
16+
for i in $ORIGDIR/*; do
17+
umount -l $i 2>/dev/null
18+
done
19+
rm -rf $ORIGDIR 2>/dev/null
20+
$KSU && mount -o ro,remount $MAGISKTMP
21+
}
22+
23+
cleanup() {
24+
if $KSU || [ $MAGISK_VER_CODE -ge 27000 ]; then umount_mirrors; fi
25+
rm -rf $MODPATH/common $MODPATH/install.zip 2>/dev/null
26+
}
27+
28+
abort() {
29+
ui_print "$1"
30+
rm -rf $MODPATH 2>/dev/null
31+
cleanup
32+
rm -rf $TMPDIR 2>/dev/null
33+
exit 1
34+
}
35+
36+
device_check() {
37+
local opt=`getopt -o dm -- "$@"` type=device
38+
eval set -- "$opt"
39+
while true; do
40+
case "$1" in
41+
-d) local type=device; shift;;
42+
-m) local type=manufacturer; shift;;
43+
--) shift; break;;
44+
*) abort "Invalid device_check argument $1! Aborting!";;
45+
esac
46+
done
47+
local prop=$(echo "$1" | tr '[:upper:]' '[:lower:]')
48+
for i in /system /vendor /odm /product; do
49+
if [ -f $i/build.prop ]; then
50+
for j in "ro.product.$type" "ro.build.$type" "ro.product.vendor.$type" "ro.vendor.product.$type"; do
51+
[ "$(sed -n "s/^$j=//p" $i/build.prop 2>/dev/null | head -n 1 | tr '[:upper:]' '[:lower:]')" == "$prop" ] && return 0
52+
done
53+
[ "$type" == "device" ] && [ "$(sed -n "s/^"ro.build.product"=//p" $i/build.prop 2>/dev/null | head -n 1 | tr '[:upper:]' '[:lower:]')" == "$prop" ] && return 0
54+
fi
55+
done
56+
return 1
57+
}
58+
59+
cp_ch() {
60+
local opt=`getopt -o nr -- "$@"` BAK=true UBAK=true FOL=false
61+
eval set -- "$opt"
62+
while true; do
63+
case "$1" in
64+
-n) UBAK=false; shift;;
65+
-r) FOL=true; shift;;
66+
--) shift; break;;
67+
*) abort "Invalid cp_ch argument $1! Aborting!";;
68+
esac
69+
done
70+
local SRC="$1" DEST="$2" OFILES="$1"
71+
$FOL && local OFILES=$(find $SRC -type f 2>/dev/null)
72+
[ -z $3 ] && PERM=0644 || PERM=$3
73+
case "$DEST" in
74+
$TMPDIR/*|$MODULEROOT/*|$NVBASE/modules/$MODID/*) BAK=false;;
75+
esac
76+
for OFILE in ${OFILES}; do
77+
if $FOL; then
78+
if [ "$(basename $SRC)" == "$(basename $DEST)" ]; then
79+
local FILE=$(echo $OFILE | sed "s|$SRC|$DEST|")
80+
else
81+
local FILE=$(echo $OFILE | sed "s|$SRC|$DEST/$(basename $SRC)|")
82+
fi
83+
else
84+
[ -d "$DEST" ] && local FILE="$DEST/$(basename $SRC)" || local FILE="$DEST"
85+
fi
86+
if $BAK && $UBAK; then
87+
[ ! "$(grep "$FILE$" $INFO 2>/dev/null)" ] && echo "$FILE" >> $INFO
88+
[ -f "$FILE" -a ! -f "$FILE~" ] && { mv -f $FILE $FILE~; echo "$FILE~" >> $INFO; }
89+
elif $BAK; then
90+
[ ! "$(grep "$FILE$" $INFO 2>/dev/null)" ] && echo "$FILE" >> $INFO
91+
fi
92+
install -D -m $PERM "$OFILE" "$FILE"
93+
done
94+
}
95+
96+
install_script() {
97+
case "$1" in
98+
-b) shift;
99+
if $KSU; then
100+
local INPATH=$NVBASE/boot-completed.d
101+
else
102+
local INPATH=$SERVICED
103+
sed -i -e '1i (\nwhile [ "$(getprop sys.boot_completed)" != "1" ]; do\n sleep 1\ndone\nsleep 3\n' -e '$a)&' $1
104+
fi;;
105+
-l) shift; local INPATH=$SERVICED;;
106+
-p) shift; local INPATH=$POSTFSDATAD;;
107+
*) local INPATH=$SERVICED;;
108+
esac
109+
[ "$(grep "#!/system/bin/sh" $1)" ] || sed -i "1i #!/system/bin/sh" $1
110+
local i; for i in "MODPATH" "LIBDIR" "MODID" "INFO" "MODDIR"; do
111+
case $i in
112+
"MODPATH") sed -i "1a $i=$NVBASE/modules/$MODID" $1;;
113+
"MODDIR") sed -i "1a $i=\${0%/*}" $1;;
114+
*) sed -i "1a $i=$(eval echo \$$i)" $1;;
115+
esac
116+
done
117+
case $1 in
118+
"$MODPATH/post-fs-data.sh"|"$MODPATH/service.sh"|"$MODPATH/uninstall.sh") sed -i "s|^MODPATH=.*|MODPATH=\$MODDIR|" $1;; # MODPATH=MODDIR for these scripts (located in module directory)
119+
"$MODPATH/boot-completed.sh") $KSU && sed -i "s|^MODPATH=.*|MODPATH=\$MODDIR|" $1 || { cp_ch -n $1 $INPATH/$MODID-$(basename $1) 0755; rm -f $MODPATH/boot-completed.sh; };;
120+
*) cp_ch -n $1 $INPATH/$(basename $1) 0755;;
121+
esac
122+
}
123+
124+
prop_process() {
125+
sed -i -e "/^#/d" -e "/^ *$/d" $1
126+
[ -f $MODPATH/system.prop ] || mktouch $MODPATH/system.prop
127+
while read LINE; do
128+
echo "$LINE" >> $MODPATH/system.prop
129+
done < $1
130+
}
131+
132+
mount_mirrors() {
133+
$KSU && mount -o rw,remount $MAGISKTMP
134+
mkdir -p $ORIGDIR/system
135+
if $SYSTEM_ROOT; then
136+
mkdir -p $ORIGDIR/system_root
137+
mount -o ro / $ORIGDIR/system_root
138+
mount -o bind $ORIGDIR/system_root/system $ORIGDIR/system
139+
else
140+
mount -o ro /system $ORIGDIR/system
141+
fi
142+
for i in /vendor $PARTITIONS; do
143+
[ ! -d $i -o -d $ORIGDIR$i ] && continue
144+
mkdir -p $ORIGDIR$i
145+
mount -o ro $i $ORIGDIR$i
146+
done
147+
}
148+
149+
# Credits
150+
ui_print "
151+
_______________ _______ _____ __ ____ _______ __
152+
/ __/_ __/ __/ | / / __/ |/ / _ )/ / / __ \/ ___/ //_/
153+
_\ \ / / / _/ | |/ / _// / _ / /__/ /_/ / /__/ ,<
154+
/___/ /_/ /___/ |___/___/_/|_/____/____/\____/\___/_/|_|
155+
156+
- Welcome to the StevenBlock family! We're thrilled to have you.
157+
- Let’s make the digital world cleaner and safer together!
158+
- Avoid using this module with AdAway or systemless hosts. Need help? Message me on Telegram.
159+
"
160+
161+
# Check for min/max api version
162+
[ -z $MINAPI ] || { [ $API -lt $MINAPI ] && abort "! Your system API of $API is less than the minimum api of $MINAPI! Aborting!"; }
163+
[ -z $MAXAPI ] || { [ $API -gt $MAXAPI ] && abort "! Your system API of $API is greater than the maximum api of $MAXAPI! Aborting!"; }
164+
165+
# Min KSU v0.6.6
166+
[ -z $KSU ] && KSU=false
167+
$KSU && { [ $KSU_VER_CODE -lt 11184 ] && require_new_ksu; }
168+
# APatch is fork of KSU, treat same
169+
[ -z $APATCH ] && APATCH=false
170+
[ "$APATCH" == "true" ] && KSU=true
171+
172+
# Start debug
173+
set -x
174+
175+
# Set variables
176+
[ -z $ARCH32 ] && ARCH32="$(echo $ABI32 | cut -c-3)"
177+
[ $API -lt 26 ] && DYNLIB=false
178+
[ -z $DYNLIB ] && DYNLIB=false
179+
[ -z $PARTOVER ] && PARTOVER=false
180+
[ -z $SYSTEM_ROOT ] && SYSTEM_ROOT=$SYSTEM_AS_ROOT # renamed in magisk v26.3
181+
[ -z $SERVICED ] && SERVICED=$NVBASE/service.d # removed in magisk v26.2
182+
[ -z $POSTFSDATAD ] && POSTFSDATAD=$NVBASE/post-fs-data.d # removed in magisk v26.2
183+
INFO=$NVBASE/modules/.$MODID-files
184+
if $KSU; then
185+
MAGISKTMP="/mnt"
186+
ORIGDIR="$MAGISKTMP/mirror"
187+
mount_mirrors
188+
elif [ "$(magisk --path 2>/dev/null)" ]; then
189+
if [ $MAGISK_VER_CODE -ge 27000 ]; then # Atomic Mount
190+
if [ -z $MAGISKTMP ]; then
191+
[ -d /sbin ] && MAGISKTMP=/sbin || MAGISKTMP=/debug_ramdisk
192+
fi
193+
ORIGDIR="$MAGISKTMP/mirror"
194+
mount_mirrors
195+
else
196+
ORIGDIR="$(magisk --path 2>/dev/null)/.magisk/mirror"
197+
fi
198+
elif [ "$(echo $MAGISKTMP | awk -F/ '{ print $NF}')" == ".magisk" ]; then
199+
ORIGDIR="$MAGISKTMP/mirror"
200+
else
201+
ORIGDIR="$MAGISKTMP/.magisk/mirror"
202+
fi
203+
if $DYNLIB; then
204+
LIBPATCH="\/vendor"
205+
LIBDIR=/system/vendor
206+
else
207+
LIBPATCH="\/system"
208+
LIBDIR=/system
209+
fi
210+
# Detect extra partition compatibility (KernelSU or Magisk Delta/Kitsune)
211+
EXTRAPART=false
212+
if $KSU || [ "$(echo $MAGISK_VER | awk -F- '{ print $NF}')" == "delta" ] || [ "$(echo $MAGISK_VER | awk -F- '{ print $NF}')" == "kitsune" ]; then
213+
EXTRAPART=true
214+
elif ! $PARTOVER; then
215+
unset PARTITIONS
216+
fi
217+
218+
if ! $BOOTMODE; then
219+
ui_print "- Only uninstall is supported in recovery"
220+
ui_print " Uninstalling!"
221+
touch $MODPATH/remove
222+
[ -s $INFO ] && install_script $MODPATH/uninstall.sh || rm -f $INFO $MODPATH/uninstall.sh
223+
recovery_cleanup
224+
cleanup
225+
rm -rf $NVBASE/modules_update/$MODID $TMPDIR 2>/dev/null
226+
exit 0
227+
fi
228+
229+
# Extract files
230+
ui_print "- Extracting module files"
231+
unzip -o "$ZIPFILE" -x 'META-INF/*' 'common/functions.sh' -d $MODPATH >&2
232+
[ -f "$MODPATH/common/addon.tar.xz" ] && tar -xf $MODPATH/common/addon.tar.xz -C $MODPATH/common 2>/dev/null
233+
234+
# Run addons
235+
if [ "$(ls -A $MODPATH/common/addon/*/install.sh 2>/dev/null)" ]; then
236+
ui_print " "; ui_print "- Running Addons -"
237+
for i in $MODPATH/common/addon/*/install.sh; do
238+
ui_print " Running $(echo $i | sed -r "s|$MODPATH/common/addon/(.*)/install.sh|\1|")..."
239+
. $i
240+
done
241+
fi
242+
243+
# Remove files outside of module directory
244+
ui_print "- Removing old files"
245+
246+
if [ -f $INFO ]; then
247+
while read LINE; do
248+
if [ "$(echo -n $LINE | tail -c 1)" == "~" ]; then
249+
continue
250+
elif [ -f "$LINE~" ]; then
251+
mv -f $LINE~ $LINE
252+
else
253+
rm -f $LINE
254+
while true; do
255+
LINE=$(dirname $LINE)
256+
[ "$(ls -A $LINE 2>/dev/null)" ] && break 1 || rm -rf $LINE
257+
done
258+
fi
259+
done < $INFO
260+
rm -f $INFO
261+
fi
262+
263+
### Install
264+
ui_print "- Installing"
265+
266+
[ -f "$MODPATH/common/install.sh" ] && . $MODPATH/common/install.sh
267+
268+
ui_print "🚀 Installing for $ARCH SDK $API device..."
269+
# Remove comments from files and place them, add blank line to end if not already present
270+
for i in $(find $MODPATH -type f -name "*.sh" -o -name "*.prop" -o -name "*.rule"); do
271+
[ -f $i ] && { sed -i -e "/^#/d" -e "/^ *$/d" $i; [ "$(tail -1 $i)" ] && echo "" >> $i; } || continue
272+
case $i in
273+
"$MODPATH/boot-completed.sh") install_script -b $i;;
274+
"$MODPATH/service.sh") install_script -l $i;;
275+
"$MODPATH/post-fs-data.sh") install_script -p $i;;
276+
"$MODPATH/uninstall.sh") if [ -s $INFO ] || [ "$(head -n1 $MODPATH/uninstall.sh)" != "# Don't modify anything after this" ]; then
277+
cp -f $MODPATH/uninstall.sh $MODPATH/$MODID-uninstall.sh # Fallback script in case module manually deleted
278+
sed -i "1i[ -d \"\$MODPATH\" ] && exit 0" $MODPATH/$MODID-uninstall.sh
279+
echo 'rm -f $0' >> $MODPATH/$MODID-uninstall.sh
280+
install_script -l $MODPATH/$MODID-uninstall.sh
281+
rm -f $MODPATH/$MODID-uninstall.sh
282+
install_script $MODPATH/uninstall.sh
283+
else
284+
rm -f $INFO $MODPATH/uninstall.sh
285+
fi;;
286+
esac
287+
done
288+
289+
$IS64BIT || for i in $(find $MODPATH/system -type d -name "lib64"); do rm -rf $i 2>/dev/null; done
290+
[ -d "/system/priv-app" ] || mv -f $MODPATH/system/priv-app $MODPATH/system/app 2>/dev/null
291+
[ -d "/system/xbin" ] || mv -f $MODPATH/system/xbin $MODPATH/system/bin 2>/dev/null
292+
if $DYNLIB; then
293+
for FILE in $(find $MODPATH/system/lib* -type f 2>/dev/null | sed "s|$MODPATH/system/||"); do
294+
[ -s $MODPATH/system/$FILE ] || continue
295+
case $FILE in
296+
lib*/modules/*) continue;;
297+
esac
298+
mkdir -p $(dirname $MODPATH/system/vendor/$FILE)
299+
mv -f $MODPATH/system/$FILE $MODPATH/system/vendor/$FILE
300+
[ "$(ls -A `dirname $MODPATH/system/$FILE`)" ] || rm -rf `dirname $MODPATH/system/$FILE`
301+
done
302+
# Delete empty lib folders (busybox find doesn't have this capability)
303+
toybox find $MODPATH/system/lib* -type d -empty -delete >/dev/null 2>&1
304+
fi
305+
306+
# Set permissions
307+
ui_print " "
308+
ui_print "- Setting Permissions"
309+
set_perm_recursive $MODPATH 0 0 0755 0644
310+
for i in /system/vendor /vendor /system/vendor/app /vendor/app /system/vendor/etc /vendor/etc /system/odm/etc /odm/etc /system/vendor/odm/etc /vendor/odm/etc /system/vendor/overlay /vendor/overlay; do
311+
if [ -d "$MODPATH$i" ] && [ ! -L "$MODPATH$i" ]; then
312+
case $i in
313+
*"/vendor") set_perm_recursive $MODPATH$i 0 0 0755 0644 u:object_r:vendor_file:s0;;
314+
*"/app") set_perm_recursive $MODPATH$i 0 0 0755 0644 u:object_r:vendor_app_file:s0;;
315+
*"/overlay") set_perm_recursive $MODPATH$i 0 0 0755 0644 u:object_r:vendor_overlay_file:s0;;
316+
*"/etc") set_perm_recursive $MODPATH$i 0 2000 0755 0644 u:object_r:vendor_configs_file:s0;;
317+
esac
318+
fi
319+
done
320+
for i in $(find $MODPATH/system/vendor $MODPATH/vendor -type f -name *".apk" 2>/dev/null); do
321+
chcon u:object_r:vendor_app_file:s0 $i
322+
done
323+
set_permissions
324+
325+
# Complete install
326+
cleanup

common/install.sh

Whitespace-only changes.

0 commit comments

Comments
 (0)