Skip to content

Commit d972310

Browse files
committed
Add module files
1 parent 89759ef commit d972310

File tree

5 files changed

+292
-0
lines changed

5 files changed

+292
-0
lines changed
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
#!/sbin/sh
2+
3+
#################
4+
# Initialization
5+
#################
6+
7+
umask 022
8+
9+
# Global vars
10+
TMPDIR=/dev/tmp
11+
PERSISTDIR=/sbin/.magisk/mirror/persist
12+
13+
rm -rf $TMPDIR 2>/dev/null
14+
mkdir -p $TMPDIR
15+
16+
# echo before loading util_functions
17+
ui_print() { echo "$1"; }
18+
19+
require_new_magisk() {
20+
ui_print "*******************************"
21+
ui_print " Please install Magisk v19.0+! "
22+
ui_print "*******************************"
23+
exit 1
24+
}
25+
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+
##############
45+
# Environment
46+
##############
47+
48+
OUTFD=$2
49+
ZIPFILE=$3
50+
51+
mount /data 2>/dev/null
52+
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
57+
58+
# Preperation for flashable zips
59+
setup_flashable
60+
61+
# Mount partitions
62+
mount_partitions
63+
64+
# Detect version and architecture
65+
api_level_arch_detect
66+
67+
# Setup busybox and binaries
68+
$BOOTMODE && boot_actions || recovery_actions
69+
70+
##############
71+
# Preparation
72+
##############
73+
74+
# Extract prop file
75+
unzip -o "$ZIPFILE" module.prop -d $TMPDIR >&2
76+
[ ! -f $TMPDIR/module.prop ] && abort "! Unable to extract zip file!"
77+
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`
83+
84+
# Create mod paths
85+
rm -rf $MODPATH 2>/dev/null
86+
mkdir -p $MODPATH
87+
88+
##########
89+
# Install
90+
##########
91+
92+
if is_legacy_script; then
93+
unzip -oj "$ZIPFILE" module.prop install.sh uninstall.sh 'common/*' -d $TMPDIR >&2
94+
95+
# Load install script
96+
. $TMPDIR/install.sh
97+
98+
# Callbacks
99+
print_modname
100+
on_install
101+
102+
# Custom uninstaller
103+
[ -f $TMPDIR/uninstall.sh ] && cp -af $TMPDIR/uninstall.sh $MODPATH/uninstall.sh
104+
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
126+
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
130+
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
138+
139+
# Handle replace folders
140+
for TARGET in $REPLACE; do
141+
ui_print "- Replace target: $TARGET"
142+
mktouch $MODPATH$TARGET/.replace
143+
done
144+
145+
if $BOOTMODE; then
146+
# Update info for Magisk Manager
147+
mktouch $NVBASE/modules/$MODID/update
148+
cp -af $MODPATH/module.prop $NVBASE/modules/$MODID/module.prop
149+
fi
150+
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
158+
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
163+
164+
##############
165+
# Finalizing
166+
##############
167+
168+
cd /
169+
$BOOTMODE || recovery_cleanup
170+
rm -rf $TMPDIR
171+
172+
ui_print "- Done"
173+
exit 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#MAGISK

config.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
##########################################################################################
2+
#
3+
# Magisk Module Template Config Script
4+
# by topjohnwu
5+
#
6+
##########################################################################################
7+
##########################################################################################
8+
#
9+
# Instructions:
10+
#
11+
# 1. Place your files into system folder (delete the placeholder file)
12+
# 2. Fill in your module's info into module.prop
13+
# 3. Configure the settings in this file (config.sh)
14+
# 4. If you need boot scripts, add them into common/post-fs-data.sh or common/service.sh
15+
# 5. Add your additional or modified system properties into common/system.prop
16+
#
17+
##########################################################################################
18+
19+
##########################################################################################
20+
# Configs
21+
##########################################################################################
22+
23+
# Set to true if you need to enable Magic Mount
24+
# Most mods would like it to be enabled
25+
AUTOMOUNT=true
26+
27+
# Set to true if you need to load system.prop
28+
PROPFILE=false
29+
30+
# Set to true if you need post-fs-data script
31+
POSTFSDATA=false
32+
33+
# Set to true if you need late_start service script
34+
LATESTARTSERVICE=false
35+
36+
##########################################################################################
37+
# Installation Message
38+
##########################################################################################
39+
40+
# Set what you want to show when installing your mod
41+
42+
print_modname() {
43+
ui_print "=============================="
44+
ui_print " FeliCa time "
45+
ui_print "=============================="
46+
}
47+
48+
##########################################################################################
49+
# Replace list
50+
##########################################################################################
51+
52+
# List all directories you want to directly replace in the system
53+
# Check the documentations for more info about how Magic Mount works, and why you need this
54+
55+
# This is an example
56+
REPLACE="
57+
/product/etc/felica
58+
"
59+
60+
# Construct your own list here, it will override the example above
61+
# !DO NOT! remove this if you don't need to replace anything, leave it empty as it is now
62+
REPLACE="
63+
"
64+
65+
##########################################################################################
66+
# Permissions
67+
##########################################################################################
68+
69+
set_permissions() {
70+
# Only some special files require specific permissions
71+
# The default permissions should be good enough for most cases
72+
73+
# Here are some examples for the set_perm functions:
74+
75+
# set_perm_recursive <dirname> <owner> <group> <dirpermission> <filepermission> <contexts> (default: u:object_r:system_file:s0)
76+
# set_perm_recursive $MODPATH/system/lib 0 0 0755 0644
77+
78+
# set_perm <filename> <owner> <group> <permission> <contexts> (default: u:object_r:system_file:s0)
79+
# set_perm $MODPATH/system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0
80+
# set_perm $MODPATH/system/bin/dex2oat 0 2000 0755 u:object_r:dex2oat_exec:s0
81+
# set_perm $MODPATH/system/lib/libart.so 0 0 0644
82+
83+
# The following is default permissions, DO NOT remove
84+
set_perm_recursive $MODPATH 0 0 0755 0644
85+
}
86+
87+
##########################################################################################
88+
# Custom Functions
89+
##########################################################################################
90+
91+
# This file (config.sh) will be sourced by the main flash script after util_functions.sh
92+
# If you need custom logic, please add them here as functions, and call these functions in
93+
# update-binary. Refrain from adding code directly into update-binary, as it will make it
94+
# difficult for you to migrate your modules to newer template versions.
95+
# Make update-binary as clean as possible, try to only do function calls in it.
96+

module.prop

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
id=felica
2+
name=Starks' FeliCa mod
3+
version=v0
4+
versionCode=1
5+
author=Starks
6+
description=felica
7+
minMagisk=19000
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
00000001,100008
2+
00000002,000068
3+
00000003,com.android.chrome
4+
00000004,com.android.vending
5+
00000005,1
6+
00000010,1
7+
00000011,eSE1
8+
00000012,1
9+
00000013,1
10+
02020001,3030373031350000000000
11+
02030001,0
12+
02030002,0
13+
02030003,intent:#Intent;action=android.settings.NFC_SETTINGS;end
14+
00000016,0001
15+
00000018,1

0 commit comments

Comments
 (0)