blob: 81a197455a50c9ff3f107ff31fdabba2d9bc6a90 [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
nkk7171c6c502017-01-05 23:55:05 +02006import /init.recovery.vold_decrypt.rc
Matt Mower556411f2013-02-17 16:52:44 -06007import /init.recovery.${ro.hardware}.rc
8
Colin Crossdd6a0412010-05-14 13:42:20 -07009on early-init
Alex Deymo080f5222016-03-02 14:21:02 -080010 # Set the security context of /postinstall if present.
11 restorecon /postinstall
12
Andreas Schneidera4e510e2020-03-11 19:19:12 +010013 # ueventd wants to write to /acct
14 mount cgroup none /acct cpuacct
15 mkdir /acct/uid
Colin Crossdd6a0412010-05-14 13:42:20 -070016 start ueventd
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080017
18on init
Doug Zongker55d65422014-01-14 09:50:35 -080019 export PATH /sbin:/system/bin
bigbiffad58e1b2020-07-06 20:24:34 -040020 export LD_LIBRARY_PATH /system/lib64
Ethan Yonker34ae4832016-08-24 15:32:18 -050021
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080022 export ANDROID_ROOT /system
23 export ANDROID_DATA /data
24 export EXTERNAL_STORAGE /sdcard
25
Elliott Hughesa4495b52018-08-23 08:31:59 -070026 symlink /proc/self/fd/0 /dev/stdin
27 symlink /proc/self/fd/1 /dev/stdout
28 symlink /proc/self/fd/2 /dev/stderr
29
Elliott Hughes4dca6f12017-12-06 08:41:50 -080030 symlink /system/bin /bin
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080031 symlink /system/etc /etc
32
Elliott Hughes48ebb072016-06-15 15:15:15 -070033 mount cgroup none /acct cpuacct
34 mkdir /acct/uid
35
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080036 mkdir /system
37 mkdir /data
38 mkdir /cache
Doug Zongker075ad802014-06-26 15:35:51 -070039 mkdir /sideload
Jiyong Park8b7af4c2018-06-01 11:58:54 +090040 mkdir /mnt/system
Doug Zongker55d65422014-01-14 09:50:35 -080041 mount tmpfs tmpfs /tmp
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080042
Matt Mower556411f2013-02-17 16:52:44 -060043 chown root shell /tmp
44 chmod 0775 /tmp
45
Colin Cross22bcf972014-06-24 13:43:39 -070046 write /proc/sys/kernel/panic_on_oops 1
Jesse Zhao5bf74b22015-01-08 15:59:23 -080047 write /proc/sys/vm/max_map_count 1000000
Colin Cross22bcf972014-06-24 13:43:39 -070048
Benoit Goby689e06b2014-02-19 17:41:02 -080049on fs
Vojtech Bocek05ec1d42015-03-08 16:32:41 +010050 mount pstore pstore /sys/fs/pstore
Benoit Goby689e06b2014-02-19 17:41:02 -080051 mkdir /dev/usb-ffs 0770 shell shell
52 mkdir /dev/usb-ffs/adb 0770 shell shell
53 mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
54
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080055on boot
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080056 ifup lo
57 hostname localhost
58 domainname localdomain
59
60 class_start default
61
Matt Mower4251a9b2015-11-13 14:01:49 -060062# Load properties, pre-Android 6.0
Riley Andrewse739d7e2014-06-24 16:29:16 -070063on load_all_props_action
64 load_all_props
65
Matt Mower4251a9b2015-11-13 14:01:49 -060066# Load properties, Android 6.0+
67on load_system_props_action
68 load_system_props
69
70# Load properties, Android 6.0+, vendor init lives here
71on load_persist_props_action
72 load_persist_props
73
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070074on firmware_mounts_complete
Matt Mower4251a9b2015-11-13 14:01:49 -060075 rm /dev/.booting
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070076
Riley Andrewse739d7e2014-06-24 16:29:16 -070077# Mount filesystems and start core system services.
78on late-init
79 trigger early-fs
80 trigger fs
81 trigger post-fs
82 trigger post-fs-data
83
Matt Mower4251a9b2015-11-13 14:01:49 -060084 # Load properties, pre-Android 6.0
Riley Andrewse739d7e2014-06-24 16:29:16 -070085 trigger load_all_props_action
86
Riley Andrewse739d7e2014-06-24 16:29:16 -070087 # Load properties from /system/ + /factory after fs mount. Place
88 # this in another action so that the load will be scheduled after the prior
89 # issued fs triggers have completed.
Paul Lawrence90c75b02015-07-06 10:44:33 -070090 trigger load_system_props_action
Riley Andrewse739d7e2014-06-24 16:29:16 -070091
Matt Mower4251a9b2015-11-13 14:01:49 -060092 # Load properties, Android 6.0+, vendor init lives here
93 trigger load_persist_props_action
94
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070095 # Remove a file to wake up anything waiting for firmware
96 trigger firmware_mounts_complete
97
Riley Andrewse739d7e2014-06-24 16:29:16 -070098 trigger early-boot
99 trigger boot
100
bigbiff63d7add2020-03-31 18:00:59 -0400101 start logd
102
Doug Zongker77ea71d2013-08-30 12:20:16 -0700103on property:sys.powerctl=*
104 powerctl ${sys.powerctl}
105
bigbiffad58e1b2020-07-06 20:24:34 -0400106service ueventd /system/bin/ueventd
Colin Crossdd6a0412010-05-14 13:42:20 -0700107 critical
Stephen Smalley2c9d5b22014-01-13 09:44:42 -0500108 seclabel u:r:ueventd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800109
bigbiffad58e1b2020-07-06 20:24:34 -0400110service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
Kenny Rootecc76ba2010-06-28 09:01:22 -0700111 disabled
Doug Zongkercc2958f2013-09-11 13:24:32 -0700112 socket adbd stream 660 system system
Stephen Smalley2c9d5b22014-01-13 09:44:42 -0500113 seclabel u:r:adbd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800114
Mike Lockwood718a2f72011-06-29 10:22:04 -0400115# Always start adbd on userdebug and eng builds
116on property:ro.debuggable=1
Dees_Troy0cd4cc22013-06-09 20:56:38 +0000117 #write /sys/class/android_usb/android0/enable 1
118 #start adbd
Dees_Troy51a0e822012-09-05 15:24:24 -0400119 setprop service.adb.root 1
bigbiffd58ba182020-03-23 10:02:29 -0400120
bigbiffad58e1b2020-07-06 20:24:34 -0400121service fastbootd /system/bin/fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700122 disabled
123 group system
124 seclabel u:r:fastbootd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800125
Mike Lockwood718a2f72011-06-29 10:22:04 -0400126# Restart adbd so it can run as root
Doug Zongkerfb04b872011-06-23 15:30:34 -0700127on property:service.adb.root=1
Doug Zongkerfb04b872011-06-23 15:30:34 -0700128 restart adbd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700129
130# Always start adbd on userdebug and eng builds
131on fs && property:ro.debuggable=1
132 setprop sys.usb.config adb
133
134on fs && property:sys.usb.configfs=1
135 mount configfs none /config
136 mkdir /config/usb_gadget/g1 0770 shell shell
137 write /config/usb_gadget/g1/idVendor 0x18D1
138 mkdir /config/usb_gadget/g1/strings/0x409 0770
139 write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
140 write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer}
141 write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model}
142 mkdir /config/usb_gadget/g1/functions/ffs.adb
143 mkdir /config/usb_gadget/g1/functions/ffs.fastboot
144 mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell
145 mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell
146
147on fs && property:sys.usb.configfs=0
148 write /sys/class/android_usb/android0/f_ffs/aliases adb,fastboot
149 write /sys/class/android_usb/android0/idVendor 18D1
150 write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
151 write /sys/class/android_usb/android0/iProduct ${ro.product.model}
152 write /sys/class/android_usb/android0/iSerial ${ro.serialno}
153
154on fs
155 mkdir /dev/usb-ffs 0775 shell shell
156 mkdir /dev/usb-ffs/adb 0770 shell shell
157 mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
158 mkdir /dev/usb-ffs/fastboot 0770 system system
159 mount functionfs fastboot /dev/usb-ffs/fastboot rmode=0770,fmode=0660,uid=1000,gid=1000
160
161on property:sys.usb.config=adb
162 start adbd
163
164on property:sys.usb.config=fastboot
165 start fastbootd
166
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700167on property:sys.usb.config=none && property:sys.usb.configfs=0
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700168 stop adbd
169 stop fastboot
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700170 write /sys/class/android_usb/android0/enable 0
171 setprop sys.usb.state ${sys.usb.config}
172
173on property:sys.usb.config=adb && property:sys.usb.configfs=0
174 write /sys/class/android_usb/android0/idProduct D001
175 write /sys/class/android_usb/android0/functions adb
Benoit Goby689e06b2014-02-19 17:41:02 -0800176 write /sys/class/android_usb/android0/enable 1
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700177 setprop sys.usb.state ${sys.usb.config}
178
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700179on property:sys.usb.config=sideload && property:sys.usb.configfs=0
180 write /sys/class/android_usb/android0/idProduct D001
181 write /sys/class/android_usb/android0/functions adb
182 write /sys/class/android_usb/android0/enable 1
183 setprop sys.usb.state ${sys.usb.config}
184
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700185on property:sys.usb.config=fastboot && property:sys.usb.configfs=0
186 write /sys/class/android_usb/android0/idProduct 4EE0
187 write /sys/class/android_usb/android0/functions fastboot
188 write /sys/class/android_usb/android0/enable 1
189 setprop sys.usb.state ${sys.usb.config}
190
191# Configfs triggers
192on property:sys.usb.config=none && property:sys.usb.configfs=1
193 write /config/usb_gadget/g1/UDC "none"
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700194 stop adbd
195 stop fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700196 setprop sys.usb.ffs.ready 0
197 rm /config/usb_gadget/g1/configs/b.1/f1
198 setprop sys.usb.state ${sys.usb.config}
199
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700200on property:sys.usb.config=sideload && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
201 write /config/usb_gadget/g1/idProduct 0xD001
202 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
203 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
204 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
205 setprop sys.usb.state ${sys.usb.config}
206
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700207on property:sys.usb.config=adb && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
208 write /config/usb_gadget/g1/idProduct 0xD001
209 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
210 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
211 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
212 setprop sys.usb.state ${sys.usb.config}
213
214on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
215 write /config/usb_gadget/g1/idProduct 0x4EE0
216 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "fastboot"
217 symlink /config/usb_gadget/g1/functions/ffs.fastboot /config/usb_gadget/g1/configs/b.1/f1
218 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
219 setprop sys.usb.state ${sys.usb.config}