The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1 | |
| 2 | on init |
| 3 | |
| 4 | sysclktz 0 |
| 5 | |
| 6 | loglevel 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 |
Dmitry Shmidt | 720f08f | 2009-06-09 14:38:56 -0700 | [diff] [blame] | 26 | mkdir /config 0500 root root |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 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 |
San Mehat | 4322f2d | 2009-06-29 08:47:43 -0700 | [diff] [blame] | 37 | write /proc/sys/kernel/sched_compat_yield 1 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 38 | |
San Mehat | 4933098 | 2009-04-21 14:34:19 -0700 | [diff] [blame] | 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 |
San Mehat | ee40fc4 | 2009-08-06 14:13:35 -0700 | [diff] [blame] | 55 | # 5.0 % |
| 56 | write /dev/cpuctl/bg_non_interactive/cpu.shares 52 |
San Mehat | 4933098 | 2009-04-21 14:34:19 -0700 | [diff] [blame] | 57 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 58 | # mount mtd partitions |
| 59 | # Mount /system rw first to give the filesystem a chance to save a checkpoint |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 60 | mount yaffs2 mtd@system /system |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 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 | # Same reason as /data above |
| 69 | mount yaffs2 mtd@cache /cache nosuid nodev |
| 70 | chown system cache /cache |
| 71 | chmod 0770 /cache |
| 72 | |
| 73 | # This may have been created by the recovery system with odd permissions |
| 74 | chown system system /cache/recovery |
| 75 | chmod 0770 /cache/recovery |
| 76 | |
| 77 | # create basic filesystem structure |
| 78 | mkdir /data/misc 01771 system misc |
Jaikumar Ganesh | 1d36696 | 2009-05-05 22:28:54 -0700 | [diff] [blame] | 79 | mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 80 | mkdir /data/misc/keystore 0770 keystore keystore |
| 81 | mkdir /data/misc/vpn 0770 system system |
| 82 | mkdir /data/misc/vpn/profiles 0770 system system |
Mike Lockwood | 48d116e | 2009-07-08 18:42:08 -0400 | [diff] [blame] | 83 | # give system access to wpa_supplicant.conf for backup and restore |
| 84 | mkdir /data/misc/wifi 0770 wifi wifi |
| 85 | chmod 0770 /data/misc/wifi |
Amith Yamasani | eefef32 | 2009-07-02 12:08:13 -0700 | [diff] [blame] | 86 | chmod 0660 /data/misc/wifi/wpa_supplicant.conf |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 87 | mkdir /data/local 0771 shell shell |
| 88 | mkdir /data/local/tmp 0771 shell shell |
| 89 | mkdir /data/data 0771 system system |
| 90 | mkdir /data/app-private 0771 system system |
| 91 | mkdir /data/app 0771 system system |
| 92 | mkdir /data/property 0700 root root |
| 93 | |
San Mehat | 2154187 | 2009-08-26 16:38:51 -0700 | [diff] [blame] | 94 | # Collect kernel crash-dump info |
| 95 | copy /proc/last_console /data/last_console |
| 96 | chown root system /data/last_console |
| 97 | copy /proc/last_threads /data/last_threads |
| 98 | chown root system /data/last_threads |
| 99 | copy /proc/last_kmsg /data/last_kmsg |
| 100 | chown root system /data/last_kmsg |
| 101 | |
| 102 | # Free crash resources and re-arm |
| 103 | write /proc/last_kmsg 1 |
| 104 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 105 | # create dalvik-cache and double-check the perms |
| 106 | mkdir /data/dalvik-cache 0771 system system |
| 107 | chown system system /data/dalvik-cache |
| 108 | chmod 0771 /data/dalvik-cache |
| 109 | |
| 110 | # create the lost+found directories, so as to enforce our permissions |
| 111 | mkdir /data/lost+found 0770 |
| 112 | mkdir /cache/lost+found 0770 |
| 113 | |
| 114 | # double check the perms, in case lost+found already exists, and set owner |
| 115 | chown root root /data/lost+found |
| 116 | chmod 0770 /data/lost+found |
| 117 | chown root root /cache/lost+found |
| 118 | chmod 0770 /cache/lost+found |
| 119 | |
| 120 | on boot |
| 121 | # basic network init |
| 122 | ifup lo |
| 123 | hostname localhost |
| 124 | domainname localdomain |
| 125 | |
| 126 | # set RLIMIT_NICE to allow priorities from 19 to -20 |
| 127 | setrlimit 13 40 40 |
| 128 | |
| 129 | # Define the oom_adj values for the classes of processes that can be |
| 130 | # killed by the kernel. These are used in ActivityManagerService. |
| 131 | setprop ro.FOREGROUND_APP_ADJ 0 |
| 132 | setprop ro.VISIBLE_APP_ADJ 1 |
| 133 | setprop ro.SECONDARY_SERVER_ADJ 2 |
Christopher Tate | 17df71e | 2009-06-05 18:20:08 -0700 | [diff] [blame] | 134 | setprop ro.BACKUP_APP_ADJ 2 |
The Android Open Source Project | e4749f3 | 2009-03-09 11:52:15 -0700 | [diff] [blame] | 135 | setprop ro.HOME_APP_ADJ 4 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 136 | setprop ro.HIDDEN_APP_MIN_ADJ 7 |
| 137 | setprop ro.CONTENT_PROVIDER_ADJ 14 |
| 138 | setprop ro.EMPTY_APP_ADJ 15 |
| 139 | |
| 140 | # Define the memory thresholds at which the above process classes will |
| 141 | # be killed. These numbers are in pages (4k). |
| 142 | setprop ro.FOREGROUND_APP_MEM 1536 |
| 143 | setprop ro.VISIBLE_APP_MEM 2048 |
| 144 | setprop ro.SECONDARY_SERVER_MEM 4096 |
Christopher Tate | 17df71e | 2009-06-05 18:20:08 -0700 | [diff] [blame] | 145 | setprop ro.BACKUP_APP_MEM 4096 |
The Android Open Source Project | e4749f3 | 2009-03-09 11:52:15 -0700 | [diff] [blame] | 146 | setprop ro.HOME_APP_MEM 4096 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 147 | setprop ro.HIDDEN_APP_MEM 5120 |
| 148 | setprop ro.CONTENT_PROVIDER_MEM 5632 |
| 149 | setprop ro.EMPTY_APP_MEM 6144 |
| 150 | |
| 151 | # Write value must be consistent with the above properties. |
The Android Open Source Project | e4749f3 | 2009-03-09 11:52:15 -0700 | [diff] [blame] | 152 | # Note that the driver only supports 6 slots, so we have HOME_APP at the |
| 153 | # same memory level as services. |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 154 | write /sys/module/lowmemorykiller/parameters/adj 0,1,2,7,14,15 |
| 155 | |
| 156 | write /proc/sys/vm/overcommit_memory 1 |
The Android Open Source Project | e037fd7 | 2009-03-13 13:04:37 -0700 | [diff] [blame] | 157 | write /proc/sys/vm/min_free_order_shift 4 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 158 | write /sys/module/lowmemorykiller/parameters/minfree 1536,2048,4096,5120,5632,6144 |
| 159 | |
| 160 | # Set init its forked children's oom_adj. |
| 161 | write /proc/1/oom_adj -16 |
| 162 | |
| 163 | # Permissions for System Server and daemons. |
| 164 | chown radio system /sys/android_power/state |
| 165 | chown radio system /sys/android_power/request_state |
| 166 | chown radio system /sys/android_power/acquire_full_wake_lock |
| 167 | chown radio system /sys/android_power/acquire_partial_wake_lock |
| 168 | chown radio system /sys/android_power/release_wake_lock |
| 169 | chown radio system /sys/power/state |
| 170 | chown radio system /sys/power/wake_lock |
| 171 | chown radio system /sys/power/wake_unlock |
| 172 | chmod 0660 /sys/power/state |
| 173 | chmod 0660 /sys/power/wake_lock |
| 174 | chmod 0660 /sys/power/wake_unlock |
| 175 | chown system system /sys/class/timed_output/vibrator/enable |
| 176 | chown system system /sys/class/leds/keyboard-backlight/brightness |
| 177 | chown system system /sys/class/leds/lcd-backlight/brightness |
| 178 | chown system system /sys/class/leds/button-backlight/brightness |
The Android Open Source Project | f614d64 | 2009-03-18 17:39:49 -0700 | [diff] [blame] | 179 | chown system system /sys/class/leds/jogball-backlight/brightness |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 180 | chown system system /sys/class/leds/red/brightness |
| 181 | chown system system /sys/class/leds/green/brightness |
| 182 | chown system system /sys/class/leds/blue/brightness |
| 183 | chown system system /sys/class/leds/red/device/grpfreq |
| 184 | chown system system /sys/class/leds/red/device/grppwm |
| 185 | chown system system /sys/class/leds/red/device/blink |
| 186 | chown system system /sys/class/leds/red/brightness |
| 187 | chown system system /sys/class/leds/green/brightness |
| 188 | chown system system /sys/class/leds/blue/brightness |
| 189 | chown system system /sys/class/leds/red/device/grpfreq |
| 190 | chown system system /sys/class/leds/red/device/grppwm |
| 191 | chown system system /sys/class/leds/red/device/blink |
| 192 | chown system system /sys/class/timed_output/vibrator/enable |
| 193 | chown system system /sys/module/sco/parameters/disable_esco |
| 194 | chown system system /sys/kernel/ipv4/tcp_wmem_min |
| 195 | chown system system /sys/kernel/ipv4/tcp_wmem_def |
| 196 | chown system system /sys/kernel/ipv4/tcp_wmem_max |
| 197 | chown system system /sys/kernel/ipv4/tcp_rmem_min |
| 198 | chown system system /sys/kernel/ipv4/tcp_rmem_def |
| 199 | chown system system /sys/kernel/ipv4/tcp_rmem_max |
| 200 | chown root radio /proc/cmdline |
| 201 | |
| 202 | # Define TCP buffer sizes for various networks |
| 203 | # ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax, |
| 204 | setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208 |
| 205 | setprop net.tcp.buffersize.wifi 4095,87380,110208,4096,16384,110208 |
| 206 | setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208 |
| 207 | setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040 |
| 208 | setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680 |
| 209 | |
| 210 | class_start default |
| 211 | |
| 212 | ## Daemon processes to be run by init. |
| 213 | ## |
| 214 | service console /system/bin/sh |
| 215 | console |
| 216 | |
| 217 | # adbd is controlled by the persist.service.adb.enable system property |
| 218 | service adbd /sbin/adbd |
| 219 | disabled |
| 220 | |
| 221 | # adbd on at boot in emulator |
| 222 | on property:ro.kernel.qemu=1 |
| 223 | start adbd |
| 224 | |
| 225 | on property:persist.service.adb.enable=1 |
| 226 | start adbd |
| 227 | |
| 228 | on property:persist.service.adb.enable=0 |
| 229 | stop adbd |
| 230 | |
| 231 | service servicemanager /system/bin/servicemanager |
| 232 | user system |
| 233 | critical |
| 234 | onrestart restart zygote |
| 235 | onrestart restart media |
| 236 | |
The Android Open Source Project | e4749f3 | 2009-03-09 11:52:15 -0700 | [diff] [blame] | 237 | service vold /system/bin/vold |
| 238 | socket vold stream 0660 root mount |
| 239 | |
San Mehat | 269946c | 2009-05-06 11:18:43 -0700 | [diff] [blame] | 240 | service nexus /system/bin/nexus |
| 241 | socket nexus stream 0660 root system |
| 242 | disabled |
| 243 | |
The Android Open Source Project | e4749f3 | 2009-03-09 11:52:15 -0700 | [diff] [blame] | 244 | #service mountd /system/bin/mountd |
| 245 | # socket mountd stream 0660 root mount |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 246 | |
| 247 | service debuggerd /system/bin/debuggerd |
| 248 | |
| 249 | service ril-daemon /system/bin/rild |
| 250 | socket rild stream 660 root radio |
| 251 | socket rild-debug stream 660 radio system |
| 252 | user root |
| 253 | group radio cache inet misc |
| 254 | |
| 255 | service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server |
| 256 | socket zygote stream 666 |
| 257 | onrestart write /sys/android_power/request_state wake |
| 258 | onrestart write /sys/power/state on |
| 259 | |
| 260 | service media /system/bin/mediaserver |
| 261 | user media |
| 262 | group system audio camera graphics inet net_bt net_bt_admin |
| 263 | |
| 264 | service bootsound /system/bin/playmp3 |
| 265 | user media |
| 266 | group audio |
| 267 | oneshot |
| 268 | |
Mathias Agopian | 8b2cf9f | 2009-05-20 18:09:51 -0700 | [diff] [blame] | 269 | service bootanim /system/bin/bootanimation |
| 270 | user graphics |
| 271 | group graphics |
| 272 | disabled |
| 273 | oneshot |
| 274 | |
Jaikumar Ganesh | 1d36696 | 2009-05-05 22:28:54 -0700 | [diff] [blame] | 275 | #STOPSHIP: Remove logwrapper before production |
| 276 | service dbus /system/bin/logwrapper /system/bin/dbus-daemon --system --nofork |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 277 | socket dbus stream 660 bluetooth bluetooth |
| 278 | user bluetooth |
| 279 | group bluetooth net_bt_admin |
| 280 | |
Jaikumar Ganesh | 1d36696 | 2009-05-05 22:28:54 -0700 | [diff] [blame] | 281 | #STOPSHIP: Remove logwrapper and -d option before production |
| 282 | service bluetoothd /system/bin/logwrapper /system/bin/bluetoothd -d -n |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 283 | socket bluetooth stream 660 bluetooth bluetooth |
| 284 | socket dbus_bluetooth stream 660 bluetooth bluetooth |
| 285 | # init.rc does not yet support applying capabilities, so run as root and |
Jaikumar Ganesh | 1d36696 | 2009-05-05 22:28:54 -0700 | [diff] [blame] | 286 | # let bluetoothd drop uid to bluetooth with the right linux capabilities |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 287 | group bluetooth net_bt_admin misc |
| 288 | disabled |
| 289 | |
| 290 | service hfag /system/bin/sdptool add --channel=10 HFAG |
| 291 | user bluetooth |
| 292 | group bluetooth net_bt_admin |
| 293 | disabled |
| 294 | oneshot |
| 295 | |
| 296 | service hsag /system/bin/sdptool add --channel=11 HSAG |
| 297 | user bluetooth |
| 298 | group bluetooth net_bt_admin |
| 299 | disabled |
| 300 | oneshot |
| 301 | |
Nick Pelly | b44aeb7 | 2009-07-14 21:29:15 -0700 | [diff] [blame] | 302 | service opush /system/bin/sdptool add --channel=12 OPUSH |
| 303 | user bluetooth |
| 304 | group bluetooth net_bt_admin |
| 305 | disabled |
| 306 | oneshot |
| 307 | |
Jaikumar Ganesh | 630f5f0 | 2009-07-23 21:19:04 -0700 | [diff] [blame] | 308 | service pbap /system/bin/sdptool add --channel=19 PBAP |
| 309 | user bluetooth |
| 310 | group bluetooth net_bt_admin |
| 311 | disabled |
| 312 | oneshot |
| 313 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 314 | service installd /system/bin/installd |
| 315 | socket installd stream 600 system system |
| 316 | |
Doug Zongker | d52f54c | 2009-07-23 15:18:34 -0700 | [diff] [blame] | 317 | service flash_recovery /system/etc/install-recovery.sh |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 318 | oneshot |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 319 | |
Chia-chi Yeh | 51afbf5 | 2009-07-01 07:06:47 +0800 | [diff] [blame] | 320 | service racoon /system/bin/racoon |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 321 | socket racoon stream 600 system system |
Chia-chi Yeh | 51afbf5 | 2009-07-01 07:06:47 +0800 | [diff] [blame] | 322 | # racoon will setuid to vpn after getting necessary resources. |
| 323 | group net_admin keystore |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 324 | disabled |
| 325 | oneshot |
| 326 | |
| 327 | service mtpd /system/bin/mtpd |
| 328 | socket mtpd stream 600 system system |
Chia-chi Yeh | 51afbf5 | 2009-07-01 07:06:47 +0800 | [diff] [blame] | 329 | user vpn |
| 330 | group vpn net_admin net_raw |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 331 | disabled |
| 332 | oneshot |
| 333 | |
| 334 | service keystore /system/bin/keystore |
| 335 | user keystore |
| 336 | group keystore |
| 337 | socket keystore stream 666 |
| 338 | |