Captain Throwback | 1f12775 | 2016-01-19 17:30:20 -0500 | [diff] [blame] | 1 | import /init.recovery.logd.rc |
Captain Throwback | 170964d | 2019-10-21 19:42:50 -0400 | [diff] [blame] | 2 | import /init.recovery.ldconfig.rc |
Captain Throwback | 5ab5964 | 2019-02-07 17:22:49 -0500 | [diff] [blame] | 3 | import /init.recovery.mksh.rc |
Matt Mower | ec009e8 | 2015-01-30 13:00:49 -0600 | [diff] [blame] | 4 | import /init.recovery.usb.rc |
Ethan Yonker | f117962 | 2016-08-25 15:32:21 -0500 | [diff] [blame] | 5 | import /init.recovery.service.rc |
nkk71 | 71c6c50 | 2017-01-05 23:55:05 +0200 | [diff] [blame] | 6 | import /init.recovery.vold_decrypt.rc |
Matt Mower | 556411f | 2013-02-17 16:52:44 -0600 | [diff] [blame] | 7 | import /init.recovery.${ro.hardware}.rc |
| 8 | |
Colin Cross | dd6a041 | 2010-05-14 13:42:20 -0700 | [diff] [blame] | 9 | on early-init |
Alex Deymo | 080f522 | 2016-03-02 14:21:02 -0800 | [diff] [blame] | 10 | # Set the security context of /postinstall if present. |
| 11 | restorecon /postinstall |
| 12 | |
Andreas Schneider | a4e510e | 2020-03-11 19:19:12 +0100 | [diff] [blame] | 13 | # ueventd wants to write to /acct |
| 14 | mount cgroup none /acct cpuacct |
| 15 | mkdir /acct/uid |
Colin Cross | dd6a041 | 2010-05-14 13:42:20 -0700 | [diff] [blame] | 16 | start ueventd |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 17 | |
| 18 | on init |
Doug Zongker | 55d6542 | 2014-01-14 09:50:35 -0800 | [diff] [blame] | 19 | export PATH /sbin:/system/bin |
bigbiff | ad58e1b | 2020-07-06 20:24:34 -0400 | [diff] [blame] | 20 | export LD_LIBRARY_PATH /system/lib64 |
Ethan Yonker | 34ae483 | 2016-08-24 15:32:18 -0500 | [diff] [blame] | 21 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 22 | export ANDROID_ROOT /system |
| 23 | export ANDROID_DATA /data |
| 24 | export EXTERNAL_STORAGE /sdcard |
| 25 | |
Elliott Hughes | a4495b5 | 2018-08-23 08:31:59 -0700 | [diff] [blame] | 26 | 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 Hughes | 4dca6f1 | 2017-12-06 08:41:50 -0800 | [diff] [blame] | 30 | symlink /system/bin /bin |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 31 | symlink /system/etc /etc |
| 32 | |
Elliott Hughes | 48ebb07 | 2016-06-15 15:15:15 -0700 | [diff] [blame] | 33 | mount cgroup none /acct cpuacct |
| 34 | mkdir /acct/uid |
| 35 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 36 | mkdir /system |
| 37 | mkdir /data |
| 38 | mkdir /cache |
Doug Zongker | 075ad80 | 2014-06-26 15:35:51 -0700 | [diff] [blame] | 39 | mkdir /sideload |
Jiyong Park | 8b7af4c | 2018-06-01 11:58:54 +0900 | [diff] [blame] | 40 | mkdir /mnt/system |
Doug Zongker | 55d6542 | 2014-01-14 09:50:35 -0800 | [diff] [blame] | 41 | mount tmpfs tmpfs /tmp |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 42 | |
Matt Mower | 556411f | 2013-02-17 16:52:44 -0600 | [diff] [blame] | 43 | chown root shell /tmp |
| 44 | chmod 0775 /tmp |
| 45 | |
Colin Cross | 22bcf97 | 2014-06-24 13:43:39 -0700 | [diff] [blame] | 46 | write /proc/sys/kernel/panic_on_oops 1 |
Jesse Zhao | 5bf74b2 | 2015-01-08 15:59:23 -0800 | [diff] [blame] | 47 | write /proc/sys/vm/max_map_count 1000000 |
Colin Cross | 22bcf97 | 2014-06-24 13:43:39 -0700 | [diff] [blame] | 48 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 49 | on boot |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 50 | ifup lo |
| 51 | hostname localhost |
| 52 | domainname localdomain |
| 53 | |
| 54 | class_start default |
| 55 | |
Matt Mower | 4251a9b | 2015-11-13 14:01:49 -0600 | [diff] [blame] | 56 | # Load properties, pre-Android 6.0 |
Riley Andrews | e739d7e | 2014-06-24 16:29:16 -0700 | [diff] [blame] | 57 | on load_all_props_action |
| 58 | load_all_props |
| 59 | |
Matt Mower | 4251a9b | 2015-11-13 14:01:49 -0600 | [diff] [blame] | 60 | # Load properties, Android 6.0+ |
| 61 | on load_system_props_action |
| 62 | load_system_props |
| 63 | |
| 64 | # Load properties, Android 6.0+, vendor init lives here |
| 65 | on load_persist_props_action |
| 66 | load_persist_props |
| 67 | |
JP Abgrall | 9eb8c8b | 2014-10-20 20:02:57 -0700 | [diff] [blame] | 68 | on firmware_mounts_complete |
Matt Mower | 4251a9b | 2015-11-13 14:01:49 -0600 | [diff] [blame] | 69 | rm /dev/.booting |
JP Abgrall | 9eb8c8b | 2014-10-20 20:02:57 -0700 | [diff] [blame] | 70 | |
Riley Andrews | e739d7e | 2014-06-24 16:29:16 -0700 | [diff] [blame] | 71 | # Mount filesystems and start core system services. |
| 72 | on late-init |
| 73 | trigger early-fs |
| 74 | trigger fs |
| 75 | trigger post-fs |
| 76 | trigger post-fs-data |
| 77 | |
Matt Mower | 4251a9b | 2015-11-13 14:01:49 -0600 | [diff] [blame] | 78 | # Load properties, pre-Android 6.0 |
Riley Andrews | e739d7e | 2014-06-24 16:29:16 -0700 | [diff] [blame] | 79 | trigger load_all_props_action |
| 80 | |
Riley Andrews | e739d7e | 2014-06-24 16:29:16 -0700 | [diff] [blame] | 81 | # Load properties from /system/ + /factory after fs mount. Place |
| 82 | # this in another action so that the load will be scheduled after the prior |
| 83 | # issued fs triggers have completed. |
Paul Lawrence | 90c75b0 | 2015-07-06 10:44:33 -0700 | [diff] [blame] | 84 | trigger load_system_props_action |
Riley Andrews | e739d7e | 2014-06-24 16:29:16 -0700 | [diff] [blame] | 85 | |
Matt Mower | 4251a9b | 2015-11-13 14:01:49 -0600 | [diff] [blame] | 86 | # Load properties, Android 6.0+, vendor init lives here |
| 87 | trigger load_persist_props_action |
| 88 | |
JP Abgrall | 9eb8c8b | 2014-10-20 20:02:57 -0700 | [diff] [blame] | 89 | # Remove a file to wake up anything waiting for firmware |
| 90 | trigger firmware_mounts_complete |
| 91 | |
Riley Andrews | e739d7e | 2014-06-24 16:29:16 -0700 | [diff] [blame] | 92 | trigger early-boot |
| 93 | trigger boot |
| 94 | |
Doug Zongker | 77ea71d | 2013-08-30 12:20:16 -0700 | [diff] [blame] | 95 | on property:sys.powerctl=* |
| 96 | powerctl ${sys.powerctl} |
| 97 | |
bigbiff | ad58e1b | 2020-07-06 20:24:34 -0400 | [diff] [blame] | 98 | service ueventd /system/bin/ueventd |
Colin Cross | dd6a041 | 2010-05-14 13:42:20 -0700 | [diff] [blame] | 99 | critical |
Stephen Smalley | 2c9d5b2 | 2014-01-13 09:44:42 -0500 | [diff] [blame] | 100 | seclabel u:r:ueventd:s0 |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 101 | |
bigbiff | ad58e1b | 2020-07-06 20:24:34 -0400 | [diff] [blame] | 102 | service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery |
Kenny Root | ecc76ba | 2010-06-28 09:01:22 -0700 | [diff] [blame] | 103 | disabled |
Doug Zongker | cc2958f | 2013-09-11 13:24:32 -0700 | [diff] [blame] | 104 | socket adbd stream 660 system system |
Stephen Smalley | 2c9d5b2 | 2014-01-13 09:44:42 -0500 | [diff] [blame] | 105 | seclabel u:r:adbd:s0 |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 106 | |
Mike Lockwood | 718a2f7 | 2011-06-29 10:22:04 -0400 | [diff] [blame] | 107 | # Always start adbd on userdebug and eng builds |
| 108 | on property:ro.debuggable=1 |
Dees_Troy | 0cd4cc2 | 2013-06-09 20:56:38 +0000 | [diff] [blame] | 109 | #write /sys/class/android_usb/android0/enable 1 |
| 110 | #start adbd |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 111 | setprop service.adb.root 1 |
bigbiff | d58ba18 | 2020-03-23 10:02:29 -0400 | [diff] [blame] | 112 | |
bigbiff | ad58e1b | 2020-07-06 20:24:34 -0400 | [diff] [blame] | 113 | service fastbootd /system/bin/fastbootd |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 114 | disabled |
| 115 | group system |
| 116 | seclabel u:r:fastbootd:s0 |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 117 | |
Mike Lockwood | 718a2f7 | 2011-06-29 10:22:04 -0400 | [diff] [blame] | 118 | # Restart adbd so it can run as root |
Doug Zongker | fb04b87 | 2011-06-23 15:30:34 -0700 | [diff] [blame] | 119 | on property:service.adb.root=1 |
Doug Zongker | fb04b87 | 2011-06-23 15:30:34 -0700 | [diff] [blame] | 120 | restart adbd |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 121 | |
| 122 | # Always start adbd on userdebug and eng builds |
| 123 | on fs && property:ro.debuggable=1 |
| 124 | setprop sys.usb.config adb |
| 125 | |
| 126 | on fs && property:sys.usb.configfs=1 |
| 127 | mount configfs none /config |
| 128 | mkdir /config/usb_gadget/g1 0770 shell shell |
| 129 | write /config/usb_gadget/g1/idVendor 0x18D1 |
| 130 | mkdir /config/usb_gadget/g1/strings/0x409 0770 |
| 131 | write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno} |
| 132 | write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer} |
| 133 | write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model} |
| 134 | mkdir /config/usb_gadget/g1/functions/ffs.adb |
| 135 | mkdir /config/usb_gadget/g1/functions/ffs.fastboot |
| 136 | mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell |
| 137 | mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell |
| 138 | |
| 139 | on fs && property:sys.usb.configfs=0 |
| 140 | write /sys/class/android_usb/android0/f_ffs/aliases adb,fastboot |
| 141 | write /sys/class/android_usb/android0/idVendor 18D1 |
| 142 | write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer} |
| 143 | write /sys/class/android_usb/android0/iProduct ${ro.product.model} |
| 144 | write /sys/class/android_usb/android0/iSerial ${ro.serialno} |
| 145 | |
| 146 | on fs |
Captain Throwback | 82c6693 | 2020-10-13 15:03:11 -0400 | [diff] [blame] | 147 | mount pstore pstore /sys/fs/pstore |
| 148 | mkdir /dev/usb-ffs 0770 shell shell |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 149 | mkdir /dev/usb-ffs/adb 0770 shell shell |
| 150 | mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000 |
| 151 | mkdir /dev/usb-ffs/fastboot 0770 system system |
| 152 | mount functionfs fastboot /dev/usb-ffs/fastboot rmode=0770,fmode=0660,uid=1000,gid=1000 |
| 153 | |
| 154 | on property:sys.usb.config=adb |
| 155 | start adbd |
| 156 | |
| 157 | on property:sys.usb.config=fastboot |
| 158 | start fastbootd |
| 159 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 160 | on property:sys.usb.config=none && property:sys.usb.configfs=0 |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 161 | stop adbd |
| 162 | stop fastboot |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 163 | write /sys/class/android_usb/android0/enable 0 |
| 164 | setprop sys.usb.state ${sys.usb.config} |
| 165 | |
| 166 | on property:sys.usb.config=adb && property:sys.usb.configfs=0 |
| 167 | write /sys/class/android_usb/android0/idProduct D001 |
| 168 | write /sys/class/android_usb/android0/functions adb |
Benoit Goby | 689e06b | 2014-02-19 17:41:02 -0800 | [diff] [blame] | 169 | write /sys/class/android_usb/android0/enable 1 |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 170 | setprop sys.usb.state ${sys.usb.config} |
| 171 | |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 172 | on property:sys.usb.config=sideload && property:sys.usb.configfs=0 |
| 173 | write /sys/class/android_usb/android0/idProduct D001 |
| 174 | write /sys/class/android_usb/android0/functions adb |
| 175 | write /sys/class/android_usb/android0/enable 1 |
| 176 | setprop sys.usb.state ${sys.usb.config} |
| 177 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 178 | on property:sys.usb.config=fastboot && property:sys.usb.configfs=0 |
| 179 | write /sys/class/android_usb/android0/idProduct 4EE0 |
| 180 | write /sys/class/android_usb/android0/functions fastboot |
| 181 | write /sys/class/android_usb/android0/enable 1 |
| 182 | setprop sys.usb.state ${sys.usb.config} |
| 183 | |
| 184 | # Configfs triggers |
| 185 | on property:sys.usb.config=none && property:sys.usb.configfs=1 |
| 186 | write /config/usb_gadget/g1/UDC "none" |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 187 | stop adbd |
| 188 | stop fastbootd |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 189 | setprop sys.usb.ffs.ready 0 |
| 190 | rm /config/usb_gadget/g1/configs/b.1/f1 |
| 191 | setprop sys.usb.state ${sys.usb.config} |
| 192 | |
Hridya Valsaraju | e4ef453 | 2018-08-31 11:57:51 -0700 | [diff] [blame] | 193 | on property:sys.usb.config=sideload && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 |
| 194 | write /config/usb_gadget/g1/idProduct 0xD001 |
| 195 | write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb" |
| 196 | symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 |
| 197 | write /config/usb_gadget/g1/UDC ${sys.usb.controller} |
| 198 | setprop sys.usb.state ${sys.usb.config} |
| 199 | |
Hridya Valsaraju | 20c81b3 | 2018-07-27 22:09:12 -0700 | [diff] [blame] | 200 | on property:sys.usb.config=adb && 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 | |
| 207 | on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 |
| 208 | write /config/usb_gadget/g1/idProduct 0x4EE0 |
| 209 | write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "fastboot" |
| 210 | symlink /config/usb_gadget/g1/functions/ffs.fastboot /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} |