Script Import Guide
About 909 wordsAbout 3 min
2026-01-30
What is a Module Script?
Module scripts are executable script files placed in the module directory, used to automatically perform specific tasks at system boot. FolkPatch supports the following types of module scripts:
- post-fs-data.sh - Executed after file system mount (Blocking)
- post-mount.sh - Executed after module mount
- service.sh - Executed late in boot process (Non-blocking)
- boot-completed.sh - Executed after system boot completed
- uninstall.sh - Executed when module is uninstalled
- action.sh - Executed when "Action" button is clicked in manager
Tip
In most cases, using service.sh is sufficient.
Preparation
Before importing scripts, please ensure:
- FolkPatch is installed and Root access is granted successfully
- Required module is installed (If adding script to existing module)
- Script file is ready (Prepared
.shfile)
Method 1: Direct Editing Module Folder
Step 1: Locate Module Directory
Module scripts need to be placed in the module directory. The standard path for modules is:
/data/adb/modules/MODULE_ID/Note
If you want to add scripts to a system module, you need to download the module installation package from the module repository first.
Step 2: Put Script into Module Directory
Use a file manager (MT Manager recommended) or ADB command:
# Example: Push service.sh to specific module
adb push service.sh /data/adb/modules/your_module_id/Or use the manager feature directly:
- Open FolkPatch Manager
- Go to "Modules" page
- Find target module and click to enter details
- Select "Browse Module Files"
- Copy script file to module root directory
Step 3: Set Execution Permission
Scripts must be set as executable to run:
# Set permission via ADB
adb shell
su
chmod +x /data/adb/modules/MODULE_ID/service.shOr in MT Manager:
- Long press script file
- Select "Properties"
- Check "Execute" permission (All users)
Step 4: Reboot to Apply
The script will run automatically on next system boot.
Method 2: Via Module Installer
If you are creating a new module or modifying an existing module's installation package, you can package the script inside.
Step 1: Prepare Module Package
A module installation package is a ZIP file with the following structure:
module.zip
├── module.prop # Module info configuration file
├── customize.sh # Optional: Script executed during installation
├── system.prop # Optional: System property modification
├── sepolicy.rule # Optional: SELinux policy
├── post-fs-data.sh # Optional: Startup script
├── post-mount.sh # Optional: Startup script
├── service.sh # Optional: Startup script
├── boot-completed.sh # Optional: Startup script
├── uninstall.sh # Optional: Uninstall script
├── action.sh # Optional: Action button script
└── system/ # Optional: Files to mount to system
└── ...Step 2: Create module.prop
module.prop is the module's configuration file and must contain the following fields:
id=your_module_id
name=Module Name
version=v1.0
versionCode=1
author=Your Name
description=Short description of the moduleID Format Requirement
Module ID must match the regular expression ^[a-zA-Z][a-zA-Z0-9._-]+$, that is:
- Must start with a letter
- Can only contain letters, numbers, dots, underscores, and hyphens
- Examples: ✓
my_module, ✓module.101, ✗123module
Step 3: Write Startup Script
Create your script file (e.g., service.sh):
#!/system/bin/sh
# This is an example service script
# Get module directory path
MODDIR=${0%/*}
# Write your script logic here
echo "Hello from FolkPatch!" > /data/local/tmp/test.log
# Example: Modify system property
resetprop ro.build.display.id "My Custom ROM"Important
- Use
MODDIR=${0%/*}to get module directory, do not hardcode path - Do not modify
/systempartition directly, useresetpropto modify properties - All commands should use full paths or be called via environment variables
Step 4: Pack and Install
- Compress all files into ZIP format
- Select "Install Module" in FolkPatch Manager
- Select your module package
- Wait for installation to complete and reboot
Verify Script Execution
Method 1: Check Log Files
Many scripts output logs during execution, you can check in the following locations:
/data/local/tmp/
/data/adb/modules/MODULE_ID/
/sdcard/Method 2: Use ADB to Check System Log
adb logcat -s Magisk:*Or check FolkPatch related logs:
adb logcat | grep -i "folkpatch\|apatch"Method 3: Check File Modification
If the script modified files or properties, you can check if the modification took effect directly:
# Check property
adb shell getprop ro.build.display.id
# Check file
adb shell ls -la /data/local/tmp/FAQ
Q1: What if the script doesn't execute?
Checklist:
- Is execution permission set? (
chmod +x) - Is the script in the correct location?
- Is the script filename correct? (Must be
service.sh,post-fs-data.shetc. standard names) - Is the module enabled?
- Is the device rebooted?
Q2: How to debug scripts?
Add log output at the beginning of the script:
#!/system/bin/sh
MODDIR=${0%/*}
# Log script start
echo "[$(date)] Script started" >> /data/local/tmp/script_debug.log
# Your script logic
echo "[$(date)] Executing step 1..." >> /data/local/tmp/script_debug.log
# More debug info
echo "[$(date)] Script completed" >> /data/local/tmp/script_debug.logQ3: Can I install modules with scripts in Recovery?
No. FolkPatch modules do not support installation in Recovery, they must be installed via Manager APP.
Q4: Will script failure affect system boot?
post-fs-data.shfailure may cause boot delay (Max wait 10 seconds)service.shandboot-completed.share non-blocking and won't get stuck at boot- It is recommended to put non-critical scripts in
service.sh
Q5: How to stop script execution?
- Disable the entire module: Toggle off module switch in manager
- Delete script file
- Reboot device
Next Steps
After importing scripts, you may need to:
- Manage Module Scripts - Learn how to enable, disable and delete scripts
- Script Examples - View common script examples
Copyright
Copyright Ownership:FolkPatch Team
License under:Attribution 4.0 International (CC-BY-4.0)
