blob: 5c13ef74bc3212be8b2f2dd17bba57044ab7d84a [file] [log] [blame]
Captain Throwback1f127752016-01-19 17:30:20 -05001import /init.recovery.logd.rc
Captain Throwback170964d2019-10-21 19:42:50 -04002import /init.recovery.ldconfig.rc
Captain Throwback5ab59642019-02-07 17:22:49 -05003import /init.recovery.mksh.rc
Matt Mowerec009e82015-01-30 13:00:49 -06004import /init.recovery.usb.rc
Ethan Yonkerf1179622016-08-25 15:32:21 -05005import /init.recovery.service.rc
Matt Mower556411f2013-02-17 16:52:44 -06006import /init.recovery.${ro.hardware}.rc
7
Colin Crossdd6a0412010-05-14 13:42:20 -07008on early-init
Alex Deymo080f5222016-03-02 14:21:02 -08009 # Set the security context of /postinstall if present.
10 restorecon /postinstall
11
Andreas Schneidera4e510e2020-03-11 19:19:12 +010012 # ueventd wants to write to /acct
13 mount cgroup none /acct cpuacct
14 mkdir /acct/uid
Kiyoung Kimea2b6832019-12-17 15:05:54 +090015 # Copy prebuilt ld.config.txt into linkerconfig directory
16 copy /system/etc/ld.config.txt /linkerconfig/ld.config.txt
Kiyoung Kim3a88a172019-12-09 19:27:57 +090017 chmod 444 /linkerconfig/ld.config.txt
18
Colin Crossdd6a0412010-05-14 13:42:20 -070019 start ueventd
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080020
bigbiff91bd7a72021-01-03 17:33:01 -050021 setprop sys.usb.configfs 0
22
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080023on init
Doug Zongker55d65422014-01-14 09:50:35 -080024 export PATH /sbin:/system/bin
bigbiffa957f072021-03-07 18:20:29 -050025 export LD_LIBRARY_PATH /system/lib64:/vendor/lib64/hw
Ethan Yonker34ae4832016-08-24 15:32:18 -050026
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080027 export ANDROID_ROOT /system
28 export ANDROID_DATA /data
29 export EXTERNAL_STORAGE /sdcard
30
Elliott Hughesa4495b52018-08-23 08:31:59 -070031 symlink /proc/self/fd/0 /dev/stdin
32 symlink /proc/self/fd/1 /dev/stdout
33 symlink /proc/self/fd/2 /dev/stderr
34
Elliott Hughes4dca6f12017-12-06 08:41:50 -080035 symlink /system/bin /bin
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080036 symlink /system/etc /etc
37
Elliott Hughes48ebb072016-06-15 15:15:15 -070038 mount cgroup none /acct cpuacct
39 mkdir /acct/uid
40
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080041 mkdir /sdcard
42 mkdir /system
43 mkdir /data
bigbiffaed1bdf2021-08-03 18:21:39 -040044 symlink /data/cache /cache
Doug Zongker075ad802014-06-26 15:35:51 -070045 mkdir /sideload
Jiyong Park8b7af4c2018-06-01 11:58:54 +090046 mkdir /mnt/system
Doug Zongker55d65422014-01-14 09:50:35 -080047 mount tmpfs tmpfs /tmp
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080048
Matt Mower556411f2013-02-17 16:52:44 -060049 chown root shell /tmp
50 chmod 0775 /tmp
bigbiffdf53b6c2022-01-17 19:31:52 -050051 mkdir /tmp/misc
52 mkdir /tmp/misc/keystore/
Matt Mower556411f2013-02-17 16:52:44 -060053
Colin Cross22bcf972014-06-24 13:43:39 -070054 write /proc/sys/kernel/panic_on_oops 1
Jesse Zhao5bf74b22015-01-08 15:59:23 -080055 write /proc/sys/vm/max_map_count 1000000
Colin Cross22bcf972014-06-24 13:43:39 -070056
nebrassycd79c902021-01-19 09:55:04 +010057 mkdir /dev/binderfs
58 mount binder binder /dev/binderfs stats=global
59 chmod 0755 /dev/binderfs
60 chmod 0666 /dev/binderfs/hwbinder
61 chmod 0666 /dev/binderfs/binder
62 chmod 0666 /dev/binderfs/vndbinder
63 symlink /dev/binderfs/binder /dev/binder
64 symlink /dev/binderfs/hwbinder /dev/hwbinder
65 symlink /dev/binderfs/vndbinder /dev/vndbinder
66
Captain Throwback692a9e12021-10-14 13:20:06 -040067 # Create location for fs_mgr to store abbreviated output from filesystem
68 # checker programs.
69 mkdir /dev/fscklogs 0770 root system
70
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080071on boot
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080072 ifup lo
73 hostname localhost
74 domainname localdomain
75
76 class_start default
77
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070078on firmware_mounts_complete
Matt Mower4251a9b2015-11-13 14:01:49 -060079 rm /dev/.booting
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070080
Riley Andrewse739d7e2014-06-24 16:29:16 -070081# Mount filesystems and start core system services.
82on late-init
83 trigger early-fs
84 trigger fs
85 trigger post-fs
86 trigger post-fs-data
87
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070088 # Remove a file to wake up anything waiting for firmware
89 trigger firmware_mounts_complete
90
Riley Andrewse739d7e2014-06-24 16:29:16 -070091 trigger early-boot
92 trigger boot
93
Captain Throwback692a9e12021-10-14 13:20:06 -040094on post-fs-data
95 # Set fscklog permission
96 chown root system /dev/fscklogs/log
97 chmod 0770 /dev/fscklogs/log
98
bigbiffad58e1b2020-07-06 20:24:34 -040099service ueventd /system/bin/ueventd
Colin Crossdd6a0412010-05-14 13:42:20 -0700100 critical
Stephen Smalley2c9d5b22014-01-13 09:44:42 -0500101 seclabel u:r:ueventd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800102
bigbiffad58e1b2020-07-06 20:24:34 -0400103service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
Kenny Rootecc76ba2010-06-28 09:01:22 -0700104 disabled
Doug Zongkercc2958f2013-09-11 13:24:32 -0700105 socket adbd stream 660 system system
Stephen Smalley2c9d5b22014-01-13 09:44:42 -0500106 seclabel u:r:adbd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800107
Mike Lockwood718a2f72011-06-29 10:22:04 -0400108# Always start adbd on userdebug and eng builds
109on property:ro.debuggable=1
Dees_Troy0cd4cc22013-06-09 20:56:38 +0000110 #write /sys/class/android_usb/android0/enable 1
111 #start adbd
Dees_Troy51a0e822012-09-05 15:24:24 -0400112 setprop service.adb.root 1
bigbiffd58ba182020-03-23 10:02:29 -0400113
bigbiff91bd7a72021-01-03 17:33:01 -0500114# Always start adbd on userdebug and eng builds
115on fs && property:ro.debuggable=1
116 setprop sys.usb.config adb
117
bigbiffad58e1b2020-07-06 20:24:34 -0400118service fastbootd /system/bin/fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700119 disabled
120 group system
121 seclabel u:r:fastbootd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800122
Mike Lockwood718a2f72011-06-29 10:22:04 -0400123# Restart adbd so it can run as root
Doug Zongkerfb04b872011-06-23 15:30:34 -0700124on property:service.adb.root=1
Doug Zongkerfb04b872011-06-23 15:30:34 -0700125 restart adbd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700126
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700127on fs && property:sys.usb.configfs=1
128 mount configfs none /config
129 mkdir /config/usb_gadget/g1 0770 shell shell
130 write /config/usb_gadget/g1/idVendor 0x18D1
131 mkdir /config/usb_gadget/g1/strings/0x409 0770
132 write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
133 write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer}
134 write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model}
135 mkdir /config/usb_gadget/g1/functions/ffs.adb
136 mkdir /config/usb_gadget/g1/functions/ffs.fastboot
137 mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell
138 mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell
139
140on fs && property:sys.usb.configfs=0
141 write /sys/class/android_usb/android0/f_ffs/aliases adb,fastboot
142 write /sys/class/android_usb/android0/idVendor 18D1
143 write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
144 write /sys/class/android_usb/android0/iProduct ${ro.product.model}
145 write /sys/class/android_usb/android0/iSerial ${ro.serialno}
146
147on fs
Captain Throwback82c66932020-10-13 15:03:11 -0400148 mount pstore pstore /sys/fs/pstore
149 mkdir /dev/usb-ffs 0770 shell shell
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700150 mkdir /dev/usb-ffs/adb 0770 shell shell
151 mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
152 mkdir /dev/usb-ffs/fastboot 0770 system system
153 mount functionfs fastboot /dev/usb-ffs/fastboot rmode=0770,fmode=0660,uid=1000,gid=1000
154
155on property:sys.usb.config=adb
156 start adbd
157
158on property:sys.usb.config=fastboot
159 start fastbootd
160
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700161on property:sys.usb.config=none && property:sys.usb.configfs=0
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700162 stop adbd
Dmytro Prokopchukdf354052019-11-13 13:30:17 +0200163 stop fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700164 write /sys/class/android_usb/android0/enable 0
165 setprop sys.usb.state ${sys.usb.config}
166
167on property:sys.usb.config=adb && property:sys.usb.configfs=0
168 write /sys/class/android_usb/android0/idProduct D001
169 write /sys/class/android_usb/android0/functions adb
Benoit Goby689e06b2014-02-19 17:41:02 -0800170 write /sys/class/android_usb/android0/enable 1
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700171 setprop sys.usb.state ${sys.usb.config}
172
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700173on property:sys.usb.config=sideload && property:sys.usb.configfs=0
174 write /sys/class/android_usb/android0/idProduct D001
175 write /sys/class/android_usb/android0/functions adb
176 write /sys/class/android_usb/android0/enable 1
177 setprop sys.usb.state ${sys.usb.config}
178
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700179on property:sys.usb.config=fastboot && property:sys.usb.configfs=0
180 write /sys/class/android_usb/android0/idProduct 4EE0
181 write /sys/class/android_usb/android0/functions fastboot
182 write /sys/class/android_usb/android0/enable 1
183 setprop sys.usb.state ${sys.usb.config}
184
185# Configfs triggers
186on property:sys.usb.config=none && property:sys.usb.configfs=1
187 write /config/usb_gadget/g1/UDC "none"
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700188 stop adbd
189 stop fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700190 setprop sys.usb.ffs.ready 0
191 rm /config/usb_gadget/g1/configs/b.1/f1
192 setprop sys.usb.state ${sys.usb.config}
193
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700194on property:sys.usb.config=sideload && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
195 write /config/usb_gadget/g1/idProduct 0xD001
196 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
197 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
198 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
199 setprop sys.usb.state ${sys.usb.config}
200
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700201on property:sys.usb.config=adb && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
202 write /config/usb_gadget/g1/idProduct 0xD001
203 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
204 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
205 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
206 setprop sys.usb.state ${sys.usb.config}
207
208on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
209 write /config/usb_gadget/g1/idProduct 0x4EE0
210 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "fastboot"
211 symlink /config/usb_gadget/g1/functions/ffs.fastboot /config/usb_gadget/g1/configs/b.1/f1
212 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
213 setprop sys.usb.state ${sys.usb.config}