blob: b96016ca6e567a603d9ccc4ffda1ae0e58562ab1 [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
Colin Crossdd6a0412010-05-14 13:42:20 -070013 start ueventd
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080014
15on init
Doug Zongker55d65422014-01-14 09:50:35 -080016 export PATH /sbin:/system/bin
that9c3b7e92017-03-14 20:42:45 +010017 export LD_LIBRARY_PATH /sbin
Ethan Yonker34ae4832016-08-24 15:32:18 -050018
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080019 export ANDROID_ROOT /system
20 export ANDROID_DATA /data
21 export EXTERNAL_STORAGE /sdcard
22
Elliott Hughesa4495b52018-08-23 08:31:59 -070023 symlink /proc/self/fd/0 /dev/stdin
24 symlink /proc/self/fd/1 /dev/stdout
25 symlink /proc/self/fd/2 /dev/stderr
26
Elliott Hughes4dca6f12017-12-06 08:41:50 -080027 symlink /system/bin /bin
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080028 symlink /system/etc /etc
29
Elliott Hughes48ebb072016-06-15 15:15:15 -070030 mount cgroup none /acct cpuacct
31 mkdir /acct/uid
32
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080033 mkdir /system
34 mkdir /data
35 mkdir /cache
Doug Zongker075ad802014-06-26 15:35:51 -070036 mkdir /sideload
Jiyong Park8b7af4c2018-06-01 11:58:54 +090037 mkdir /mnt/system
Doug Zongker55d65422014-01-14 09:50:35 -080038 mount tmpfs tmpfs /tmp
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080039
Matt Mower556411f2013-02-17 16:52:44 -060040 chown root shell /tmp
41 chmod 0775 /tmp
42
Colin Cross22bcf972014-06-24 13:43:39 -070043 write /proc/sys/kernel/panic_on_oops 1
Jesse Zhao5bf74b22015-01-08 15:59:23 -080044 write /proc/sys/vm/max_map_count 1000000
Colin Cross22bcf972014-06-24 13:43:39 -070045
Benoit Goby689e06b2014-02-19 17:41:02 -080046on fs
Vojtech Bocek05ec1d42015-03-08 16:32:41 +010047 mount pstore pstore /sys/fs/pstore
Benoit Goby689e06b2014-02-19 17:41:02 -080048 mkdir /dev/usb-ffs 0770 shell shell
49 mkdir /dev/usb-ffs/adb 0770 shell shell
50 mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
51
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080052on boot
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080053 ifup lo
54 hostname localhost
55 domainname localdomain
56
57 class_start default
58
Matt Mower4251a9b2015-11-13 14:01:49 -060059# Load properties, pre-Android 6.0
Riley Andrewse739d7e2014-06-24 16:29:16 -070060on load_all_props_action
61 load_all_props
62
Matt Mower4251a9b2015-11-13 14:01:49 -060063# Load properties, Android 6.0+
64on load_system_props_action
65 load_system_props
66
67# Load properties, Android 6.0+, vendor init lives here
68on load_persist_props_action
69 load_persist_props
70
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070071on firmware_mounts_complete
Matt Mower4251a9b2015-11-13 14:01:49 -060072 rm /dev/.booting
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070073
Riley Andrewse739d7e2014-06-24 16:29:16 -070074# Mount filesystems and start core system services.
75on late-init
76 trigger early-fs
77 trigger fs
78 trigger post-fs
79 trigger post-fs-data
80
Matt Mower4251a9b2015-11-13 14:01:49 -060081 # Load properties, pre-Android 6.0
Riley Andrewse739d7e2014-06-24 16:29:16 -070082 trigger load_all_props_action
83
Riley Andrewse739d7e2014-06-24 16:29:16 -070084 # Load properties from /system/ + /factory after fs mount. Place
85 # this in another action so that the load will be scheduled after the prior
86 # issued fs triggers have completed.
Paul Lawrence90c75b02015-07-06 10:44:33 -070087 trigger load_system_props_action
Riley Andrewse739d7e2014-06-24 16:29:16 -070088
Matt Mower4251a9b2015-11-13 14:01:49 -060089 # Load properties, Android 6.0+, vendor init lives here
90 trigger load_persist_props_action
91
JP Abgrall9eb8c8b2014-10-20 20:02:57 -070092 # Remove a file to wake up anything waiting for firmware
93 trigger firmware_mounts_complete
94
Riley Andrewse739d7e2014-06-24 16:29:16 -070095 trigger early-boot
96 trigger boot
97
Doug Zongker77ea71d2013-08-30 12:20:16 -070098on property:sys.powerctl=*
99 powerctl ${sys.powerctl}
100
Colin Crossdd6a0412010-05-14 13:42:20 -0700101service ueventd /sbin/ueventd
102 critical
Stephen Smalley2c9d5b22014-01-13 09:44:42 -0500103 seclabel u:r:ueventd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800104
Nick Kralevichc52c5b82014-01-18 09:22:50 -0800105service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
Kenny Rootecc76ba2010-06-28 09:01:22 -0700106 disabled
Doug Zongkercc2958f2013-09-11 13:24:32 -0700107 socket adbd stream 660 system system
Stephen Smalley2c9d5b22014-01-13 09:44:42 -0500108 seclabel u:r:adbd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800109
Mike Lockwood718a2f72011-06-29 10:22:04 -0400110# Always start adbd on userdebug and eng builds
111on property:ro.debuggable=1
Dees_Troy0cd4cc22013-06-09 20:56:38 +0000112 #write /sys/class/android_usb/android0/enable 1
113 #start adbd
Dees_Troy51a0e822012-09-05 15:24:24 -0400114 setprop service.adb.root 1
bigbiffd58ba182020-03-23 10:02:29 -0400115
116service fastbootd /sbin/fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700117 disabled
118 group system
119 seclabel u:r:fastbootd:s0
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800120
Mike Lockwood718a2f72011-06-29 10:22:04 -0400121# Restart adbd so it can run as root
Doug Zongkerfb04b872011-06-23 15:30:34 -0700122on property:service.adb.root=1
Doug Zongkerfb04b872011-06-23 15:30:34 -0700123 restart adbd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700124
125# Always start adbd on userdebug and eng builds
126on fs && property:ro.debuggable=1
127 setprop sys.usb.config adb
128
129on fs && property:sys.usb.configfs=1
130 mount configfs none /config
131 mkdir /config/usb_gadget/g1 0770 shell shell
132 write /config/usb_gadget/g1/idVendor 0x18D1
133 mkdir /config/usb_gadget/g1/strings/0x409 0770
134 write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
135 write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer}
136 write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model}
137 mkdir /config/usb_gadget/g1/functions/ffs.adb
138 mkdir /config/usb_gadget/g1/functions/ffs.fastboot
139 mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell
140 mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell
141
142on fs && property:sys.usb.configfs=0
143 write /sys/class/android_usb/android0/f_ffs/aliases adb,fastboot
144 write /sys/class/android_usb/android0/idVendor 18D1
145 write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
146 write /sys/class/android_usb/android0/iProduct ${ro.product.model}
147 write /sys/class/android_usb/android0/iSerial ${ro.serialno}
148
149on fs
150 mkdir /dev/usb-ffs 0775 shell shell
151 mkdir /dev/usb-ffs/adb 0770 shell shell
152 mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
153 mkdir /dev/usb-ffs/fastboot 0770 system system
154 mount functionfs fastboot /dev/usb-ffs/fastboot rmode=0770,fmode=0660,uid=1000,gid=1000
155
156on property:sys.usb.config=adb
157 start adbd
158
159on property:sys.usb.config=fastboot
160 start fastbootd
161
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700162on property:sys.usb.config=none && property:sys.usb.configfs=0
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700163 stop adbd
164 stop fastboot
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700165 write /sys/class/android_usb/android0/enable 0
166 setprop sys.usb.state ${sys.usb.config}
167
168on property:sys.usb.config=adb && property:sys.usb.configfs=0
169 write /sys/class/android_usb/android0/idProduct D001
170 write /sys/class/android_usb/android0/functions adb
Benoit Goby689e06b2014-02-19 17:41:02 -0800171 write /sys/class/android_usb/android0/enable 1
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700172 setprop sys.usb.state ${sys.usb.config}
173
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700174on property:sys.usb.config=sideload && property:sys.usb.configfs=0
175 write /sys/class/android_usb/android0/idProduct D001
176 write /sys/class/android_usb/android0/functions adb
177 write /sys/class/android_usb/android0/enable 1
178 setprop sys.usb.state ${sys.usb.config}
179
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700180on property:sys.usb.config=fastboot && property:sys.usb.configfs=0
181 write /sys/class/android_usb/android0/idProduct 4EE0
182 write /sys/class/android_usb/android0/functions fastboot
183 write /sys/class/android_usb/android0/enable 1
184 setprop sys.usb.state ${sys.usb.config}
185
186# Configfs triggers
187on property:sys.usb.config=none && property:sys.usb.configfs=1
188 write /config/usb_gadget/g1/UDC "none"
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700189 stop adbd
190 stop fastbootd
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700191 setprop sys.usb.ffs.ready 0
192 rm /config/usb_gadget/g1/configs/b.1/f1
193 setprop sys.usb.state ${sys.usb.config}
194
Hridya Valsarajue4ef4532018-08-31 11:57:51 -0700195on property:sys.usb.config=sideload && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
196 write /config/usb_gadget/g1/idProduct 0xD001
197 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
198 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
199 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
200 setprop sys.usb.state ${sys.usb.config}
201
Hridya Valsaraju20c81b32018-07-27 22:09:12 -0700202on property:sys.usb.config=adb && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
203 write /config/usb_gadget/g1/idProduct 0xD001
204 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
205 symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
206 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
207 setprop sys.usb.state ${sys.usb.config}
208
209on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
210 write /config/usb_gadget/g1/idProduct 0x4EE0
211 write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "fastboot"
212 symlink /config/usb_gadget/g1/functions/ffs.fastboot /config/usb_gadget/g1/configs/b.1/f1
213 write /config/usb_gadget/g1/UDC ${sys.usb.controller}
214 setprop sys.usb.state ${sys.usb.config}