Script Management Guide
About 1031 wordsAbout 3 min
2026-01-30
Overview
Script management includes viewing script status, enabling/disabling scripts, deleting scripts, etc. You can manage them through the FolkPatch Manager interface or command line.
Manage via Manager Interface
View Module Scripts
- Open FolkPatch Manager
- Click "Modules" tab at the bottom
- Find and click the module to view
- In module details page, you can:
- View all scripts included in the module
- View script execution status
- View module logs (if any)
Enable/Disable Module
Disabling a module automatically stops execution of all its scripts:
- Find target module in module list
- Click the switch button on the module card
- Confirm disable/enable operation
- Reboot device to apply changes
Quick Disable
You can also click "Disable" button in module details page, the effect is the same.
Execute Action Script
If the module contains action.sh, you can execute it via:
- Open module details page
- Click "Execute Action" button (if available)
- Wait for script execution to complete
- View execution result or log
Note
Not all modules have Action scripts, it depends on whether the module developer provides one.
Manage via File Manager
Use MT Manager (Recommended)
MT Manager is a powerful file manager on Android with Root support.
View Script Content
- Open MT Manager and grant Root permission
- Navigate to
/data/adb/modules/MODULE_ID/ - Click script file to view content
- Can edit script and save
Modify Script Permission
- Long press script file
- Select "Properties"
- Check "Execute" in permission settings
- Save changes
Delete Script
- Long press script file
- Select "Delete"
- Confirm deletion
- Reboot device to apply changes
Use System File Manager
Some system file managers (like Xiaomi's File Manager) can access /data directory after getting Root:
- Enable Root access in file manager
- Navigate to
/data/adb/modules/ - View, edit or delete scripts
Manage via ADB Command
View Module Directory Structure
# View all modules
adb shell ls -la /data/adb/modules/
# View content of specific module
adb shell ls -la /data/adb/modules/MODULE_ID/View Script Content
# Read script file
adb shell cat /data/adb/modules/MODULE_ID/service.sh
# View script log in real-time (if outputting to log file)
adb shell tail -f /data/local/tmp/script.logEnable/Disable Script
Disable Module (Stop all scripts):
adb shell
su
touch /data/adb/modules/MODULE_ID/disable
rebootEnable Module:
adb shell
su
rm /data/adb/modules/MODULE_ID/disable
rebootDelete Script
# Delete specific script
adb shell rm /data/adb/modules/MODULE_ID/service.sh
# Delete entire module (including all scripts)
adb shell rm -rf /data/adb/modules/MODULE_ID/Dangerous Operation
Deleting a module will permanently remove all related files, please ensure important data is backed up.
Script Status Check
Check if Script Executed
Check system log:
adb logcat -d | grep -i "post-fs-data\|service\|boot-completed"Check Script Output
If script writes output to file:
# View script log
adb shell cat /data/local/tmp/script_output.log
# View log in module directory
adb shell cat /data/adb/modules/MODULE_ID/script.logCheck if Process is Running
For long-running scripts:
# View all processes
adb shell ps | grep -i "Module Name or Keyword"
# View specific script process
adb shell pgrep -f "service.sh"Script Debugging Tips
Add Detailed Logs
Add debug info in script:
#!/system/bin/sh
MODDIR=${0%/*}
LOGFILE=/data/local/tmp/module_debug.log
log_msg() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> $LOGFILE
}
log_msg "=== Script started ==="
log_msg "MODDIR: $MODDIR"
log_msg "Current user: $(id)"
log_msg "Current directory: $(pwd)"
# Your script logic
if [ -f /system/build.prop ]; then
log_msg "Found build.prop"
else
log_msg "ERROR: build.prop not found!"
fi
log_msg "=== Script completed ==="Check Script Execution Environment
#!/system/bin/sh
# Dump environment info to log
env > /data/local/tmp/env_dump.txtTest Script Logic
Ensure syntax is correct before manual test run:
# Check script syntax
adb shell sh -n /data/adb/modules/MODULE_ID/service.sh
# Manually run script (Only when necessary)
adb shell sh /data/adb/modules/MODULE_ID/service.shTroubleshooting
Issue 1: Module shown as disabled but script still running
Cause: Wrong module might be disabled, or script is not in module directory.
Solution:
# Check module status
adb shell ls -la /data/adb/modules/MODULE_ID/
# Confirm if disable flag file exists
adb shell ls /data/adb/modules/MODULE_ID/disable
# Force delete flag and reboot
adb shell rm /data/adb/modules/MODULE_ID/disable
adb rebootIssue 2: Script causes slow system boot
Possible Causes:
post-fs-data.shexecution time too long (Forced termination after 10 seconds)- Dead loop or long wait in script
- Resource competition or lock waiting
Troubleshooting:
# View boot time stats
adb logcat -d | grep -i "post-fs-data"
# Check script logic, move non-essential operations to service.shIssue 3: Script modification not taking effect
Checklist:
- Is device rebooted?
- Is script in correct location?
- Does script have execution permission? (Check with
ls -l) - Is module enabled? (No disable file)
- Is script syntax correct?
Issue 4: Cannot delete script file
Cause: Insufficient permission or file system mount issue.
Solution:
# Force delete with Root permission
adb shell
su
rm -f /data/adb/modules/MODULE_ID/script.sh
# If still fails, check file system
mount | grep /dataSecurity Tips
Backup Important Scripts
- Copy scripts to safe location before modification
- Use version control to manage script changes
Test Environment
- Test new scripts on spare device
- Test with
service.shfirst, usepost-fs-data.shonly after confirmation
Logging
- All scripts should include log output
- Periodically check log file size to avoid taking up too much space
Permission Management
- Do not modify system critical files casually
- Use
resetpropinstead of directly modifying/system/build.prop
Advanced Management
Conditional Execution Script
Create script that executes based on conditions:
#!/system/bin/sh
MODDIR=${0%/*}
# Execute only on specific condition
if [ "$(getprop ro.product.device)" = "your_device_codename" ]; then
# Execute operation
echo "Device matched, executing..." >> /data/local/tmp/conditional.log
else
echo "Device not matched, skipping..." >> /data/local/tmp/conditional.log
fiDelayed Execution
Delay script execution for a period:
#!/system/bin/sh
# Delay 30 seconds
sleep 30
# Your script logic
echo "Delayed execution started" >> /data/local/tmp/delayed.logPeriodic Tasks
Create periodic check in service.sh:
#!/system/bin/sh
MODDIR=${0%/*}
# Background loop
(
while true; do
# Check a condition
if [ ! -f /data/local/tmp/some_flag ]; then
# Execute operation
touch /data/local/tmp/some_flag
fi
# Check every 60 seconds
sleep 60
done
) &Note
Long-running background scripts consume battery, please use with caution.
Related Documents
- Script Import Guide - Learn how to import scripts
- Script Examples - View common script examples
Copyright
Copyright Ownership:FolkPatch Team
License under:Attribution 4.0 International (CC-BY-4.0)
