init.rc revision abe3a9c30595846b7e3d705dd4b0aca37fb2f748
1 2on init 3 4sysclktz 0 5 6loglevel 3 7 8# setup the global environment 9 export PATH /sbin:/system/sbin:/system/bin:/system/xbin 10 export LD_LIBRARY_PATH /system/lib 11 export ANDROID_BOOTLOGO 1 12 export ANDROID_ROOT /system 13 export ANDROID_ASSETS /system/app 14 export ANDROID_DATA /data 15 export EXTERNAL_STORAGE /sdcard 16 export BOOTCLASSPATH /system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar 17 18# Backward compatibility 19 symlink /system/etc /etc 20 21# create mountpoints and mount tmpfs on sqlite_stmt_journals 22 mkdir /sdcard 0000 system system 23 mkdir /system 24 mkdir /data 0771 system system 25 mkdir /cache 0770 system cache 26 mkdir /config 0500 root root 27 mkdir /sqlite_stmt_journals 01777 root root 28 mount tmpfs tmpfs /sqlite_stmt_journals size=4m 29 30 mount rootfs rootfs / ro remount 31 32 write /proc/sys/kernel/panic_on_oops 1 33 write /proc/sys/kernel/hung_task_timeout_secs 0 34 write /proc/cpu/alignment 4 35 write /proc/sys/kernel/sched_latency_ns 10000000 36 write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000 37 write /proc/sys/kernel/sched_compat_yield 1 38 39# Create cgroup mount points for process groups 40 mkdir /dev/cpuctl 41 mount cgroup none /dev/cpuctl cpu 42 chown sytem system /dev/cpuctl 43 chown system system /dev/cpuctl/tasks 44 chmod 0777 /dev/cpuctl/tasks 45 write /dev/cpuctl/cpu.shares 1024 46 47 mkdir /dev/cpuctl/fg_boost 48 chown system system /dev/cpuctl/fg_boost/tasks 49 chmod 0777 /dev/cpuctl/fg_boost/tasks 50 write /dev/cpuctl/fg_boost/cpu.shares 1024 51 52 mkdir /dev/cpuctl/bg_non_interactive 53 chown system system /dev/cpuctl/bg_non_interactive/tasks 54 chmod 0777 /dev/cpuctl/bg_non_interactive/tasks 55 # 5.0 % 56 write /dev/cpuctl/bg_non_interactive/cpu.shares 52 57 58# mount mtd partitions 59 # Mount /system rw first to give the filesystem a chance to save a checkpoint 60 mount yaffs2 mtd@system /system 61 mount yaffs2 mtd@system /system ro remount 62 63 # We chown/chmod /data again so because mount is run as root + defaults 64 mount yaffs2 mtd@userdata /data nosuid nodev 65 chown system system /data 66 chmod 0771 /data 67 68 # Create dump dir and collect dumps. 69 # Do this before we mount cache so eventually we can use cache for 70 # storing dumps on platforms which do not have a dedicated dump partition. 71 72 mkdir /data/dontpanic 73 chmod 0770 /data/dontpanic 74 75 # Collect apanic data, free resources and re-arm trigger 76 copy /proc/apanic_console /data/dontpanic/apanic_console 77 chown root system /data/dontpanic/apanic_console 78 # STOPSHIP! 79 chmod 0664 /data/dontpanic/apanic_console 80 81 copy /proc/apanic_threads /data/dontpanic/apanic_threads 82 chown root system /data/dontpanic/apanic_threads 83 # STOPSHIP! 84 chmod 0664 /data/dontpanic/apanic_threads 85 86 write /proc/apanic_console 1 87 88 # Collect ramconsole data 89 copy /proc/last_kmsg /data/dontpanic/last_kmsg 90 chown root system /data/dontpanic/last_kmsg 91 # STOPSHIP! 92 chmod 0664 /data/dontpanic/last_kmsg 93 94 # Same reason as /data above 95 mount yaffs2 mtd@cache /cache nosuid nodev 96 chown system cache /cache 97 chmod 0770 /cache 98 99 # This may have been created by the recovery system with odd permissions 100 chown system system /cache/recovery 101 chmod 0770 /cache/recovery 102 103# create basic filesystem structure 104 mkdir /data/misc 01771 system misc 105 mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth 106 mkdir /data/misc/keystore 0770 keystore keystore 107 mkdir /data/misc/vpn 0770 system system 108 mkdir /data/misc/vpn/profiles 0770 system system 109 # give system access to wpa_supplicant.conf for backup and restore 110 mkdir /data/misc/wifi 0770 wifi wifi 111 chmod 0770 /data/misc/wifi 112 chmod 0660 /data/misc/wifi/wpa_supplicant.conf 113 mkdir /data/local 0771 shell shell 114 mkdir /data/local/tmp 0771 shell shell 115 mkdir /data/data 0771 system system 116 mkdir /data/app-private 0771 system system 117 mkdir /data/app 0771 system system 118 mkdir /data/property 0700 root root 119 120 121 # create dalvik-cache and double-check the perms 122 mkdir /data/dalvik-cache 0771 system system 123 chown system system /data/dalvik-cache 124 chmod 0771 /data/dalvik-cache 125 126 # create the lost+found directories, so as to enforce our permissions 127 mkdir /data/lost+found 0770 128 mkdir /cache/lost+found 0770 129 130 # double check the perms, in case lost+found already exists, and set owner 131 chown root root /data/lost+found 132 chmod 0770 /data/lost+found 133 chown root root /cache/lost+found 134 chmod 0770 /cache/lost+found 135 136on boot 137# basic network init 138 ifup lo 139 hostname localhost 140 domainname localdomain 141 142# set RLIMIT_NICE to allow priorities from 19 to -20 143 setrlimit 13 40 40 144 145# Define the oom_adj values for the classes of processes that can be 146# killed by the kernel. These are used in ActivityManagerService. 147 setprop ro.FOREGROUND_APP_ADJ 0 148 setprop ro.VISIBLE_APP_ADJ 1 149 setprop ro.SECONDARY_SERVER_ADJ 2 150 setprop ro.BACKUP_APP_ADJ 2 151 setprop ro.HOME_APP_ADJ 4 152 setprop ro.HIDDEN_APP_MIN_ADJ 7 153 setprop ro.CONTENT_PROVIDER_ADJ 14 154 setprop ro.EMPTY_APP_ADJ 15 155 156# Define the memory thresholds at which the above process classes will 157# be killed. These numbers are in pages (4k). 158 setprop ro.FOREGROUND_APP_MEM 1536 159 setprop ro.VISIBLE_APP_MEM 2048 160 setprop ro.SECONDARY_SERVER_MEM 4096 161 setprop ro.BACKUP_APP_MEM 4096 162 setprop ro.HOME_APP_MEM 4096 163 setprop ro.HIDDEN_APP_MEM 5120 164 setprop ro.CONTENT_PROVIDER_MEM 5632 165 setprop ro.EMPTY_APP_MEM 6144 166 167# Write value must be consistent with the above properties. 168# Note that the driver only supports 6 slots, so we have HOME_APP at the 169# same memory level as services. 170 write /sys/module/lowmemorykiller/parameters/adj 0,1,2,7,14,15 171 172 write /proc/sys/vm/overcommit_memory 1 173 write /proc/sys/vm/min_free_order_shift 4 174 write /sys/module/lowmemorykiller/parameters/minfree 1536,2048,4096,5120,5632,6144 175 176 # Set init its forked children's oom_adj. 177 write /proc/1/oom_adj -16 178 179 # Permissions for System Server and daemons. 180 chown radio system /sys/android_power/state 181 chown radio system /sys/android_power/request_state 182 chown radio system /sys/android_power/acquire_full_wake_lock 183 chown radio system /sys/android_power/acquire_partial_wake_lock 184 chown radio system /sys/android_power/release_wake_lock 185 chown radio system /sys/power/state 186 chown radio system /sys/power/wake_lock 187 chown radio system /sys/power/wake_unlock 188 chmod 0660 /sys/power/state 189 chmod 0660 /sys/power/wake_lock 190 chmod 0660 /sys/power/wake_unlock 191 chown system system /sys/class/timed_output/vibrator/enable 192 chown system system /sys/class/leds/keyboard-backlight/brightness 193 chown system system /sys/class/leds/lcd-backlight/brightness 194 chown system system /sys/class/leds/button-backlight/brightness 195 chown system system /sys/class/leds/jogball-backlight/brightness 196 chown system system /sys/class/leds/red/brightness 197 chown system system /sys/class/leds/green/brightness 198 chown system system /sys/class/leds/blue/brightness 199 chown system system /sys/class/leds/red/device/grpfreq 200 chown system system /sys/class/leds/red/device/grppwm 201 chown system system /sys/class/leds/red/device/blink 202 chown system system /sys/class/leds/red/brightness 203 chown system system /sys/class/leds/green/brightness 204 chown system system /sys/class/leds/blue/brightness 205 chown system system /sys/class/leds/red/device/grpfreq 206 chown system system /sys/class/leds/red/device/grppwm 207 chown system system /sys/class/leds/red/device/blink 208 chown system system /sys/class/timed_output/vibrator/enable 209 chown system system /sys/module/sco/parameters/disable_esco 210 chown system system /sys/kernel/ipv4/tcp_wmem_min 211 chown system system /sys/kernel/ipv4/tcp_wmem_def 212 chown system system /sys/kernel/ipv4/tcp_wmem_max 213 chown system system /sys/kernel/ipv4/tcp_rmem_min 214 chown system system /sys/kernel/ipv4/tcp_rmem_def 215 chown system system /sys/kernel/ipv4/tcp_rmem_max 216 chown root radio /proc/cmdline 217 218# Define TCP buffer sizes for various networks 219# ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax, 220 setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208 221 setprop net.tcp.buffersize.wifi 4095,87380,110208,4096,16384,110208 222 setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208 223 setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040 224 setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680 225 226 class_start default 227 228## Daemon processes to be run by init. 229## 230service console /system/bin/sh 231 console 232 233# adbd is controlled by the persist.service.adb.enable system property 234service adbd /sbin/adbd 235 disabled 236 237# adbd on at boot in emulator 238on property:ro.kernel.qemu=1 239 start adbd 240 241on property:persist.service.adb.enable=1 242 start adbd 243 244on property:persist.service.adb.enable=0 245 stop adbd 246 247service servicemanager /system/bin/servicemanager 248 user system 249 critical 250 onrestart restart zygote 251 onrestart restart media 252 253service vold /system/bin/vold 254 socket vold stream 0660 root mount 255 256service nexus /system/bin/nexus 257 socket nexus stream 0660 root system 258 disabled 259 260#service mountd /system/bin/mountd 261# socket mountd stream 0660 root mount 262 263service debuggerd /system/bin/debuggerd 264 265service ril-daemon /system/bin/rild 266 socket rild stream 660 root radio 267 socket rild-debug stream 660 radio system 268 user root 269 group radio cache inet misc 270 271service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server 272 socket zygote stream 666 273 onrestart write /sys/android_power/request_state wake 274 onrestart write /sys/power/state on 275 276service media /system/bin/mediaserver 277 user media 278 group system audio camera graphics inet net_bt net_bt_admin 279 280service bootsound /system/bin/playmp3 281 user media 282 group audio 283 oneshot 284 285service bootanim /system/bin/bootanimation 286 user graphics 287 group graphics 288 disabled 289 oneshot 290 291#STOPSHIP: Remove logwrapper before production 292service dbus /system/bin/logwrapper /system/bin/dbus-daemon --system --nofork 293 socket dbus stream 660 bluetooth bluetooth 294 user bluetooth 295 group bluetooth net_bt_admin 296 297#STOPSHIP: Remove logwrapper and -d option before production 298service bluetoothd /system/bin/logwrapper /system/bin/bluetoothd -d -n 299 socket bluetooth stream 660 bluetooth bluetooth 300 socket dbus_bluetooth stream 660 bluetooth bluetooth 301 # init.rc does not yet support applying capabilities, so run as root and 302 # let bluetoothd drop uid to bluetooth with the right linux capabilities 303 group bluetooth net_bt_admin misc 304 disabled 305 306service hfag /system/bin/sdptool add --channel=10 HFAG 307 user bluetooth 308 group bluetooth net_bt_admin 309 disabled 310 oneshot 311 312service hsag /system/bin/sdptool add --channel=11 HSAG 313 user bluetooth 314 group bluetooth net_bt_admin 315 disabled 316 oneshot 317 318service opush /system/bin/sdptool add --channel=12 OPUSH 319 user bluetooth 320 group bluetooth net_bt_admin 321 disabled 322 oneshot 323 324service pbap /system/bin/sdptool add --channel=19 PBAP 325 user bluetooth 326 group bluetooth net_bt_admin 327 disabled 328 oneshot 329 330service installd /system/bin/installd 331 socket installd stream 600 system system 332 333service flash_recovery /system/etc/install-recovery.sh 334 oneshot 335 336service racoon /system/bin/racoon 337 socket racoon stream 600 system system 338 # racoon will setuid to vpn after getting necessary resources. 339 group net_admin keystore 340 disabled 341 oneshot 342 343service mtpd /system/bin/mtpd 344 socket mtpd stream 600 system system 345 user vpn 346 group vpn net_admin net_raw 347 disabled 348 oneshot 349 350service keystore /system/bin/keystore 351 user keystore 352 group keystore 353 socket keystore stream 666 354 355service dumpstate /system/bin/dumpstate -s 356 socket dumpstate stream 0660 shell log 357 disabled 358 oneshot 359