Skip to content

Commit d294649

Browse files
committed
v2.0
1 parent af5ca79 commit d294649

File tree

6 files changed

+156
-197
lines changed

6 files changed

+156
-197
lines changed
Lines changed: 110 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,173 @@
11
#!/sbin/sh
2-
##########################################################################################
3-
#
4-
# Magisk Module Template Install Script
5-
# by topjohnwu
6-
#
7-
##########################################################################################
8-
9-
# Detect whether in boot mode
10-
ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true || BOOTMODE=false
11-
$BOOTMODE || ps -A 2>/dev/null | grep zygote | grep -v grep >/dev/null && BOOTMODE=true
12-
13-
# This path should work in any cases
14-
TMPDIR=/dev/tmp
15-
INSTALLER=$TMPDIR/install
16-
MAGISKBIN=/data/adb/magisk
172

18-
# Default permissions
3+
#################
4+
# Initialization
5+
#################
6+
197
umask 022
208

21-
# Initial cleanup
9+
# Global vars
10+
TMPDIR=/dev/tmp
11+
PERSISTDIR=/sbin/.magisk/mirror/persist
12+
2213
rm -rf $TMPDIR 2>/dev/null
23-
mkdir -p $INSTALLER
14+
mkdir -p $TMPDIR
2415

2516
# echo before loading util_functions
2617
ui_print() { echo "$1"; }
2718

2819
require_new_magisk() {
2920
ui_print "*******************************"
30-
ui_print " Please install Magisk v15.0+! "
21+
ui_print " Please install Magisk v19.0+! "
3122
ui_print "*******************************"
3223
exit 1
3324
}
3425

35-
##########################################################################################
26+
is_legacy_script() {
27+
unzip -l "$ZIPFILE" install.sh | grep -q install.sh
28+
return $?
29+
}
30+
31+
print_modname() {
32+
local len
33+
len=`echo -n $MODNAME | wc -c`
34+
len=$((len + 2))
35+
local pounds=`printf "%${len}s" | tr ' ' '*'`
36+
ui_print "$pounds"
37+
ui_print " $MODNAME "
38+
ui_print "$pounds"
39+
ui_print "*******************"
40+
ui_print " Powered by Magisk "
41+
ui_print "*******************"
42+
}
43+
44+
##############
3645
# Environment
37-
##########################################################################################
46+
##############
3847

3948
OUTFD=$2
40-
ZIP=$3
49+
ZIPFILE=$3
4150

4251
mount /data 2>/dev/null
4352

44-
# Utility functions must exist
45-
[ -f $MAGISKBIN/util_functions.sh ] || require_new_magisk
46-
# Load utility fuctions
47-
. $MAGISKBIN/util_functions.sh
48-
49-
# We can't alter magisk image live, use alternative image if required
50-
$BOOTMODE && IMG=/data/adb/magisk_merge.img
51-
# Always mount under tmp
52-
MOUNTPATH=$TMPDIR/magisk_img
53+
# Load utility functions
54+
[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
55+
. /data/adb/magisk/util_functions.sh
56+
[ $MAGISK_VER_CODE -gt 18100 ] || require_new_magisk
5357

5458
# Preperation for flashable zips
55-
get_outfd
59+
setup_flashable
5660

5761
# Mount partitions
5862
mount_partitions
5963

6064
# Detect version and architecture
6165
api_level_arch_detect
6266

63-
# You can get the Android API version from $API, the CPU architecture from $ARCH
64-
# Useful if you are creating Android version / platform dependent mods
65-
6667
# Setup busybox and binaries
6768
$BOOTMODE && boot_actions || recovery_actions
6869

69-
##########################################################################################
70+
##############
7071
# Preparation
71-
##########################################################################################
72+
##############
7273

73-
# Extract common files
74-
unzip -o "$ZIP" module.prop config.sh 'common/*' -d $INSTALLER >&2
74+
# Extract prop file
75+
unzip -o "$ZIPFILE" module.prop -d $TMPDIR >&2
76+
[ ! -f $TMPDIR/module.prop ] && abort "! Unable to extract zip file!"
7577

76-
[ ! -f $INSTALLER/config.sh ] && abort "! Unable to extract zip file!"
77-
# Load configurations
78-
. $INSTALLER/config.sh
78+
$BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules
79+
MODULEROOT=$NVBASE/$MODDIRNAME
80+
MODID=`grep_prop id $TMPDIR/module.prop`
81+
MODPATH=$MODULEROOT/$MODID
82+
MODNAME=`grep_prop name $TMPDIR/module.prop`
7983

80-
# Check the installed magisk version
81-
MIN_VER=`grep_prop minMagisk $INSTALLER/module.prop`
82-
[ ! -z $MAGISK_VER_CODE -a $MAGISK_VER_CODE -ge $MIN_VER ] || require_new_magisk
83-
MODID=`grep_prop id $INSTALLER/module.prop`
84-
MODPATH=$MOUNTPATH/$MODID
84+
# Create mod paths
85+
rm -rf $MODPATH 2>/dev/null
86+
mkdir -p $MODPATH
8587

86-
# Print mod name
87-
print_modname
88+
##########
89+
# Install
90+
##########
8891

89-
# Please leave this message in your flashable zip for credits :)
90-
ui_print "******************************"
91-
ui_print "Powered by Magisk (@topjohnwu)"
92-
ui_print "******************************"
92+
if is_legacy_script; then
93+
unzip -oj "$ZIPFILE" module.prop install.sh uninstall.sh 'common/*' -d $TMPDIR >&2
9394

94-
##########################################################################################
95-
# Install
96-
##########################################################################################
95+
# Load install script
96+
. $TMPDIR/install.sh
9797

98-
# Get the variable reqSizeM. Use your own method to determine reqSizeM if needed
99-
request_zip_size_check "$ZIP"
98+
# Callbacks
99+
print_modname
100+
on_install
100101

101-
# This function will mount $IMG to $MOUNTPATH, and resize the image based on $reqSizeM
102-
mount_magisk_img
102+
# Custom uninstaller
103+
[ -f $TMPDIR/uninstall.sh ] && cp -af $TMPDIR/uninstall.sh $MODPATH/uninstall.sh
103104

104-
# Create mod paths
105-
rm -rf $MODPATH 2>/dev/null
106-
mkdir -p $MODPATH
105+
# Skip mount
106+
$SKIPMOUNT && touch $MODPATH/skip_mount
107+
108+
# prop file
109+
$PROPFILE && cp -af $TMPDIR/system.prop $MODPATH/system.prop
110+
111+
# Module info
112+
cp -af $TMPDIR/module.prop $MODPATH/module.prop
113+
114+
# post-fs-data scripts
115+
$POSTFSDATA && cp -af $TMPDIR/post-fs-data.sh $MODPATH/post-fs-data.sh
116+
117+
# service scripts
118+
$LATESTARTSERVICE && cp -af $TMPDIR/service.sh $MODPATH/service.sh
119+
120+
ui_print "- Setting permissions"
121+
set_permissions
122+
else
123+
print_modname
124+
125+
unzip -o "$ZIPFILE" customize.sh -d $MODPATH >&2
107126

108-
# Extract files to system. Use your own method if needed
109-
ui_print "- Extracting module files"
110-
unzip -o "$ZIP" 'system/*' -d $MODPATH >&2
127+
if ! grep -q '^SKIPUNZIP=1$' $MODPATH/customize.sh 2>/dev/null; then
128+
ui_print "- Extracting module files"
129+
unzip -o "$ZIPFILE" -x 'META-INF/*' -d $MODPATH >&2
111130

112-
# Remove placeholder
113-
rm -f $MODPATH/system/placeholder 2>/dev/null
131+
# Default permissions
132+
set_perm_recursive $MODPATH 0 0 0755 0644
133+
fi
134+
135+
# Load customization script
136+
[ -f $MODPATH/customize.sh ] && . $MODPATH/customize.sh
137+
fi
114138

115139
# Handle replace folders
116140
for TARGET in $REPLACE; do
141+
ui_print "- Replace target: $TARGET"
117142
mktouch $MODPATH$TARGET/.replace
118143
done
119144

120-
# Auto Mount
121-
$AUTOMOUNT && touch $MODPATH/auto_mount
122-
123-
# prop files
124-
$PROPFILE && cp -af $INSTALLER/common/system.prop $MODPATH/system.prop
125-
126-
# Module info
127-
cp -af $INSTALLER/module.prop $MODPATH/module.prop
128145
if $BOOTMODE; then
129146
# Update info for Magisk Manager
130-
mktouch /sbin/.core/img/$MODID/update
131-
cp -af $INSTALLER/module.prop /sbin/.core/img/$MODID/module.prop
147+
mktouch $NVBASE/modules/$MODID/update
148+
cp -af $MODPATH/module.prop $NVBASE/modules/$MODID/module.prop
132149
fi
133150

134-
# post-fs-data mode scripts
135-
$POSTFSDATA && cp -af $INSTALLER/common/post-fs-data.sh $MODPATH/post-fs-data.sh
136-
137-
# service mode scripts
138-
$LATESTARTSERVICE && cp -af $INSTALLER/common/service.sh $MODPATH/service.sh
151+
# Copy over custom sepolicy rules
152+
if [ -f $MODPATH/sepolicy.rule -a -e $PERSISTDIR ]; then
153+
ui_print "- Installing custom sepolicy patch"
154+
PERSISTMOD=$PERSISTDIR/magisk/$MODID
155+
mkdir -p $PERSISTMOD
156+
cp -af $MODPATH/sepolicy.rule $PERSISTMOD/sepolicy.rule
157+
fi
139158

140-
ui_print "- Setting permissions"
141-
set_permissions
159+
# Remove stuffs that don't belong to modules
160+
rm -rf \
161+
$MODPATH/system/placeholder $MODPATH/customize.sh \
162+
$MODPATH/README.md $MODPATH/.git* 2>/dev/null
142163

143-
##########################################################################################
164+
##############
144165
# Finalizing
145-
##########################################################################################
146-
147-
# Unmount magisk image and shrink if possible
148-
unmount_magisk_img
166+
##############
149167

168+
cd /
150169
$BOOTMODE || recovery_cleanup
151170
rm -rf $TMPDIR
152171

153172
ui_print "- Done"
154-
exit 0
173+
exit 0

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Unified icon disabler for MIUI (xiaomi.eu)
2+
==========================================
3+
This module disables all of the unified icons present in xiaomi.eu and other MIUI custom ROMs systemlessly.
4+
5+
Requirements
6+
------------
7+
* Magisk v19+
8+
* MIUI based Custom ROM using it's own icon pack
9+
10+
Credits
11+
-------
12+
* @topjohnwu for Magisk
13+
* Xiaomi.eu forum for the idea :D
14+
15+
Links
16+
-----
17+
* [Telegram](https://www.t.me/Sap1k)
18+
19+
Notes
20+
-----
21+
* You will need to reapply your current theme after flashing this module for the changes to apply.
22+
* Tested on Android 10, however should be fully compatible all the way to Android 5
23+
24+
Changelog
25+
---------
26+
### v1.x
27+
- Initial release, obsolete, made using old templates
28+
29+
### v2.0
30+
- Initial **public** release
31+
- Compliant with Magisk documentation

common/post-fs-data.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/system/bin/sh
2-
# Please don't hardcode /magisk/modname/... ; instead, please use $MODDIR/...
3-
# This will make your scripts compatible even if Magisk change its mount point in the future
2+
# Do NOT assume where your module will be located.
3+
# ALWAYS use $MODDIR if you need to know where this script
4+
# and module is placed.
5+
# This will make sure your module will still work
6+
# if Magisk change its mount point in the future
47
MODDIR=${0%/*}
58

69
# This script will be executed in post-fs-data mode

0 commit comments

Comments
 (0)