forked from shakalaca/MagiskOnEmulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
initrd.patch
47 lines (44 loc) · 1.05 KB
/
initrd.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--- o/init 2020-04-02 16:19:07.000000000 +0800
+++ i/init 2020-04-02 16:15:52.000000000 +0800
@@ -239,6 +239,44 @@
export ANDROID_ROOT=/system
+MIR_ROOT=/realblk
+mkdir -p /android/${MIR_ROOT}/system
+mkdir -p /android/${MIR_ROOT}/data
+mount --bind /mnt/$SRC/data /android/${MIR_ROOT}/data
+mount --bind /android/system /android/${MIR_ROOT}/system
+
+cat >> /android/init.rc << EOF
+on fs
+ start trick
+
+service trick /sbin/trick.sh
+ oneshot
+ disabled
+EOF
+
+cat >> /android/sbin/trick.sh << EOF
+#!/system/bin/sh
+
+while true; do
+ if [ -d /sbin/.magisk ]; then
+ break
+ fi
+done
+
+mkdir -p /sbin/.magisk/block
+touch /sbin/.magisk/block/system
+touch /sbin/.magisk/block/data
+
+mkdir -p /sbin/.magisk/mirror/system
+mkdir -p /sbin/.magisk/mirror/data
+
+mount -o bind ${MIR_ROOT}/system /sbin/.magisk/mirror/system
+mount -o bind ${MIR_ROOT}/data /sbin/.magisk/mirror/data
+EOF
+
+chcon u:object_r:system_file:s0 /android/sbin/trick.sh
+chmod 755 /android/sbin/trick.sh
+
exec ${SWITCH:-switch_root} /android /init
# avoid kernel panic