@@ -53,15 +53,15 @@ settings() {
5353 fi
5454}
5555
56- if [ $MAGISK_VER_CODE -ge 20400 ]; then
56+ if [ $MAGISK_VER_CODE -ge 20400 ] && [ -z " $MMM_MMT_REBORN " ] ; then
5757 # New Magisk have complete installation logic within util_functions.sh
5858 install_module
5959 exit 0
6060fi
6161
62- # ################
63- # Legacy Support
64- # ################
62+ # ######################################################
63+ # Legacy Support + compat mode for MMT Reborn template
64+ # ######################################################
6565
6666TMPDIR=/dev/tmp
6767PERSISTDIR=/sbin/.magisk/mirror/persist
@@ -98,6 +98,7 @@ abort() {
9898
9999rm -rf $TMPDIR 2> /dev/null
100100mkdir -p $TMPDIR
101+ chcon u:object_r:system_file:s0 $TMPDIR || true
101102cd $TMPDIR
102103
103104# Preperation for flashable zips
@@ -121,7 +122,9 @@ $BOOTMODE && boot_actions || recovery_actions
121122unzip -o " $ZIPFILE " module.prop -d $TMPDIR >&2
122123[ ! -f $TMPDIR /module.prop ] && abort " ! Unable to extract zip file!"
123124
124- $BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules
125+ [ -z " $NVBASE " ] && NVBASE=" /data/adb"
126+ MODDIRNAME=modules
127+ $BOOTMODE && MODDIRNAME=modules_update
125128MODULEROOT=$NVBASE /$MODDIRNAME
126129MODID=` grep_prop id $TMPDIR /module.prop`
127130MODNAME=` grep_prop name $TMPDIR /module.prop`
@@ -166,6 +169,50 @@ if is_legacy_script; then
166169
167170 ui_print " - Setting permissions"
168171 set_permissions
172+ elif [ -n " $MMM_MMT_REBORN " ]; then
173+ # https://github.com/iamlooper/MMT-Reborn
174+ ui_print " [*] Using FoxMMM MMT-Reborn compatibility mode"
175+
176+ load_vksel () { source " $MODPATH /addon/Volume-Key-Selector/install.sh" ; }
177+
178+ rmtouch () { [[ -e " $1 " ]] && rm -rf " $1 " 2> /dev/null; }
179+
180+ unzip -o " $ZIPFILE " -d " $MODPATH " >&2
181+
182+ # Load install script
183+ source " $MODPATH /setup.sh"
184+
185+ # Remove all old files before doing installation if want to
186+ " $CLEANSERVICE " && rm -rf " /data/adb/modules/$MODID "
187+
188+ # Enable debugging if true
189+ " $DEBUG " && set -x || set +x
190+
191+ # Print mod info
192+ info_print
193+
194+ # Auto vskel load
195+ " $AUTOVKSEL " && load_vksel
196+
197+ # Main
198+ init_main
199+
200+ # Skip mount
201+ " $SKIPMOUNT " && touch " $MODPATH /skip_mount"
202+
203+ # Set permissions
204+ set_permissions
205+
206+ # Remove stuffs that don't belong to modules
207+ rmtouch " $MODPATH /META-INF"
208+ rmtouch " $MODPATH /addon"
209+ rmtouch " $MODPATH /setup.sh"
210+ rmtouch " $MODPATH /LICENSE"
211+ rmtouch " $MODPATH /README.md"
212+ rmtouch " $MODPATH /system/bin/placeholder"
213+ rmtouch " $MODPATH /zygisk/placeholder"
214+ ui_print " [*] Exiting FoxMMM MMT-Reborn compatibility mode"
215+ sleep 0.5
169216else
170217 print_modname
171218
@@ -198,13 +245,20 @@ if $BOOTMODE; then
198245fi
199246
200247# Copy over custom sepolicy rules
201- if [ -f $MODPATH /sepolicy.rule -a -e $PERSISTDIR ]; then
202- ui_print " - Installing custom sepolicy patch"
203- # Remove old recovery logs (which may be filling partition) to make room
204- rm -f $PERSISTDIR /cache/recovery/*
205- PERSISTMOD=$PERSISTDIR /magisk/$MODID
206- mkdir -p $PERSISTMOD
207- cp -af $MODPATH /sepolicy.rule $PERSISTMOD /sepolicy.rule || abort " ! Insufficient partition size"
248+ if ! type copy_sepolicy_rules & > /dev/null; then
249+ if [ -f $MODPATH /sepolicy.rule -a -e $PERSISTDIR ]; then
250+ ui_print " - Installing custom sepolicy patch"
251+ # Remove old recovery logs (which may be filling partition) to make room
252+ rm -f $PERSISTDIR /cache/recovery/*
253+ PERSISTMOD=$PERSISTDIR /magisk/$MODID
254+ mkdir -p $PERSISTMOD
255+ cp -af $MODPATH /sepolicy.rule $PERSISTMOD /sepolicy.rule || abort " ! Insufficient partition size"
256+ fi
257+ else
258+ if [ -f $MODPATH /sepolicy.rule ]; then
259+ ui_print " - Installing custom sepolicy rules"
260+ copy_sepolicy_rules
261+ fi
208262fi
209263
210264# Remove stuff that doesn't belong to modules and clean up any empty directories
0 commit comments