Skip to content

Commit 0ea44b1

Browse files
updated to newest module installer template
1 parent 67d553d commit 0ea44b1

File tree

7 files changed

+174
-260
lines changed

7 files changed

+174
-260
lines changed

META-INF/com/google/android/update-binary

100755100644
Lines changed: 7 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,10 @@
11
#!/sbin/sh
2-
##########################################################################################
3-
#
4-
# Magisk Module Template Install Script
5-
# by topjohnwu
6-
#
7-
##########################################################################################
2+
# This is a dummy file that should be replaced with a proper installer script
83

9-
TMPDIR=/dev/tmp
10-
INSTALLER=$TMPDIR/install
11-
# Always mount under tmp
12-
MOUNTPATH=$TMPDIR/magisk_img
4+
# If you are creating a module locally for personal usage or testing,
5+
# download the script in the following URL:
6+
# https://github.com/topjohnwu/Magisk/blob/master/scripts/module_installer.sh
7+
# And replace this script with the downloaded script
138

14-
# Default permissions
15-
umask 022
16-
17-
# Initial cleanup
18-
rm -rf $TMPDIR 2>/dev/null
19-
mkdir -p $INSTALLER
20-
21-
# echo before loading util_functions
22-
ui_print() { echo "$1"; }
23-
24-
require_new_magisk() {
25-
ui_print "*******************************"
26-
ui_print " Please install Magisk v17.0+! "
27-
ui_print "*******************************"
28-
exit 1
29-
}
30-
31-
##########################################################################################
32-
# Environment
33-
##########################################################################################
34-
35-
OUTFD=$2
36-
ZIP=$3
37-
38-
mount /data 2>/dev/null
39-
40-
# Load utility functions
41-
if [ -f /data/adb/magisk/util_functions.sh ]; then
42-
. /data/adb/magisk/util_functions.sh
43-
elif [ -f /data/magisk/util_functions.sh ]; then
44-
NVBASE=/data
45-
. /data/magisk/util_functions.sh
46-
else
47-
require_new_magisk
48-
fi
49-
50-
# Use alternative image if in BOOTMODE
51-
$BOOTMODE && IMG=$NVBASE/magisk_merge.img
52-
53-
# Preperation for flashable zips
54-
setup_flashable
55-
56-
# Mount partitions
57-
mount_partitions
58-
59-
# Detect version and architecture
60-
api_level_arch_detect
61-
62-
# You can get the Android API version from $API, the CPU architecture from $ARCH
63-
# Useful if you are creating Android version / platform dependent mods
64-
65-
# Setup busybox and binaries
66-
$BOOTMODE && boot_actions || recovery_actions
67-
68-
##########################################################################################
69-
# Preparation
70-
##########################################################################################
71-
72-
# Extract common files
73-
unzip -o "$ZIP" module.prop config.sh 'common/*' -d $INSTALLER >&2
74-
75-
[ ! -f $INSTALLER/config.sh ] && abort "! Unable to extract zip file!"
76-
# Load configurations
77-
. $INSTALLER/config.sh
78-
79-
# Check the installed magisk version
80-
MIN_VER=`grep_prop minMagisk $INSTALLER/module.prop`
81-
[ ! -z $MAGISK_VER_CODE -a $MAGISK_VER_CODE -ge $MIN_VER ] || require_new_magisk
82-
MODID=`grep_prop id $INSTALLER/module.prop`
83-
MODPATH=$MOUNTPATH/$MODID
84-
85-
# Print mod name
86-
print_modname
87-
88-
# Please leave this message in your flashable zip for credits :)
89-
ui_print "******************************"
90-
ui_print "Powered by Magisk (@topjohnwu)"
91-
ui_print "******************************"
92-
93-
##########################################################################################
94-
# Install
95-
##########################################################################################
96-
97-
# Get the variable reqSizeM. Use your own method to determine reqSizeM if needed
98-
request_zip_size_check "$ZIP"
99-
100-
# This function will mount $IMG to $MOUNTPATH, and resize the image based on $reqSizeM
101-
mount_magisk_img
102-
103-
# Create mod paths
104-
rm -rf $MODPATH 2>/dev/null
105-
mkdir -p $MODPATH
106-
107-
# Extract files to system. Use your own method if needed
108-
ui_print "- Extracting module files"
109-
unzip -o "$ZIP" 'system/*' -d $MODPATH >&2
110-
111-
# Remove placeholder
112-
rm -f $MODPATH/system/placeholder 2>/dev/null
113-
114-
# Handle replace folders
115-
for TARGET in $REPLACE; do
116-
mktouch $MODPATH$TARGET/.replace
117-
done
118-
119-
# Auto Mount
120-
$AUTOMOUNT && touch $MODPATH/auto_mount
121-
122-
# prop files
123-
$PROPFILE && cp -af $INSTALLER/common/system.prop $MODPATH/system.prop
124-
125-
# Module info
126-
cp -af $INSTALLER/module.prop $MODPATH/module.prop
127-
if $BOOTMODE; then
128-
# Update info for Magisk Manager
129-
mktouch /sbin/.core/img/$MODID/update
130-
cp -af $INSTALLER/module.prop /sbin/.core/img/$MODID/module.prop
131-
fi
132-
133-
# post-fs-data mode scripts
134-
$POSTFSDATA && cp -af $INSTALLER/common/post-fs-data.sh $MODPATH/post-fs-data.sh
135-
136-
# service mode scripts
137-
$LATESTARTSERVICE && cp -af $INSTALLER/common/service.sh $MODPATH/service.sh
138-
139-
ui_print "- Setting permissions"
140-
set_permissions
141-
142-
##########################################################################################
143-
# Finalizing
144-
##########################################################################################
145-
146-
# Unmount magisk image and shrink if possible
147-
unmount_magisk_img
148-
149-
$BOOTMODE || recovery_cleanup
150-
rm -rf $TMPDIR
151-
152-
ui_print "- Done"
153-
exit 0
9+
# Error, this script should always be replaced
10+
exit 1

common/post-fs-data.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
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
7-
# More info in the main Magisk thread
810

911
# If you for some reason do not want all your certificates moved from the user store to the system store, you can specify which certificates to move by replacing the * with the name of the certificate; i.e.,
1012

common/service.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +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 late_start service mode
7-
# More info in the main Magisk thread

config.sh

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)