Here is a template (9.6 KB) for a basic magisk module
Inside there are a few things to focus on
- /common/ and its contents
- /system/
- install.sh
- module.prop
Most of these files have the following instructions in them
Common
In /common/ there are 2 files that will run scripts (post-fs-data.sh and service.sh) and 1 file that will set properties (system.prop)
For the scripts use MODDIR=${0%/*}
to set the directory (in case magisk changes directories)
For system.prop simply put the property you want (for example, in /vendor/build.prop on the Cat there is a proprety ro.config.low_ram=true so in system.prop i added a line ro.config.low_ram=false
)
System
If you want to place a file in any of the super partitions you place them in /system/. For directories other than system, you make it a sub-directory of system (e.g. /system/vendor/ or system/system_ext/), and magisk figures it out. For example, In my Android Auto module for the Cat I put 2 files in, /system/app/gappstub/gappstub.apk and /system/product/priv-app/AndroidAutoPrebuiltSub/AndroidAutoPrebuiltStub.apk).
Install.sh
In install.sh there are a few options
- Flags: If you want any of the files in /common/ to make changes you need to set its flag to true, all flags are already there and set to false by default (e.g. to allow system.prop to make changes set
PROPFILE=true
) - Replace list: If you want to remove something or replace all the files in the directory you’re adding something to (instead of merging it with an existing directory) you add it to the replace list, it is already in the install.sh but it is empty by default. For example, if you want to remove youtube and youtube music it would look like this:
REPLACE="
/system/app/Youtube
/system/app/YTMusic
"
- Display when installing: toward the end of install.sh there is an option to display something while installing the module
print_modname() {
ui_print "************************************"
ui_print " Module Name and Message "
ui_print "************************************"
}
replace the text with whatever you want. if you add lines make sure to add ui_print " yourtext "
to the line
Module.prop
the module.prop should have this layout
id=your_custom_module_id
name=Your Custom Module Name
version=v1 or whatever version
versionCode=1 or whatever version code
author=You
description=A short description of your module
Making the Zip File
I suggest using 7-zip
select all the files (common, META-INF, system, etc) and right click on them, hover over 7-zip and select “add to archive” then under Archive Format select “zip”, under Compression Level select “0-store” and press ok