blob: a01fdb553d9d612bc05c74bcd1af6698f3f282a4 [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001
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
San Mehat6ea3cc62010-02-19 18:25:22 -080015 export EXTERNAL_STORAGE /mnt/sdcard
San Mehata9db22f2010-02-24 10:17:32 -080016 export ASEC_MOUNTPOINT /mnt/asec
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080017 export BOOTCLASSPATH /system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar
18
19# Backward compatibility
20 symlink /system/etc /etc
Brian Swetlandbb6f68c2009-09-18 15:31:23 -070021 symlink /sys/kernel/debug /d
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080022
Vasu Nori55a1f082010-01-26 23:12:37 -080023# create mountpoints
San Mehat6ea3cc62010-02-19 18:25:22 -080024 mkdir /mnt 0775 root system
25 mkdir /mnt/sdcard 0000 system system
26
Mike Chan89f235c2010-03-01 11:36:10 -080027# Create cgroup mount point for cpu accounting
28 mkdir /acct
29 mount cgroup none /acct cpuacct
30 mkdir /acct/uid
31
San Mehat6ea3cc62010-02-19 18:25:22 -080032# Backwards Compat - XXX: Going away in G*
33 symlink /mnt/sdcard /sdcard
34
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080035 mkdir /system
36 mkdir /data 0771 system system
37 mkdir /cache 0770 system cache
Dmitry Shmidt720f08f2009-06-09 14:38:56 -070038 mkdir /config 0500 root root
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080039
San Mehat6ea3cc62010-02-19 18:25:22 -080040 # Directory for putting things only root should see.
41 mkdir /mnt/secure 0700 root root
42
43 # Directory for staging bindmounts
44 mkdir /mnt/secure/staging 0700 root root
45
46 # Directory-target for where the secure container
47 # imagefile directory will be bind-mounted
48 mkdir /mnt/secure/asec 0700 root root
49
50 # Secure container public mount points.
51 mkdir /mnt/asec 0700 root system
52 mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
San Mehat900570e2010-01-06 10:38:49 -080053
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080054 mount rootfs rootfs / ro remount
55
56 write /proc/sys/kernel/panic_on_oops 1
57 write /proc/sys/kernel/hung_task_timeout_secs 0
58 write /proc/cpu/alignment 4
59 write /proc/sys/kernel/sched_latency_ns 10000000
60 write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
San Mehat4322f2d2009-06-29 08:47:43 -070061 write /proc/sys/kernel/sched_compat_yield 1
San Mehat7baff712009-09-16 13:32:23 -070062 write /proc/sys/kernel/sched_child_runs_first 0
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080063
San Mehat529520e2009-10-06 11:22:55 -070064# Create cgroup mount points for process groups
65 mkdir /dev/cpuctl
San Mehatb91bf4b2010-02-27 08:20:11 -080066 mount cgroup none /dev/cpuctl cpu
San Mehat92175e02010-01-17 12:21:42 -080067 chown system system /dev/cpuctl
San Mehat529520e2009-10-06 11:22:55 -070068 chown system system /dev/cpuctl/tasks
69 chmod 0777 /dev/cpuctl/tasks
70 write /dev/cpuctl/cpu.shares 1024
71
72 mkdir /dev/cpuctl/fg_boost
73 chown system system /dev/cpuctl/fg_boost/tasks
74 chmod 0777 /dev/cpuctl/fg_boost/tasks
75 write /dev/cpuctl/fg_boost/cpu.shares 1024
76
77 mkdir /dev/cpuctl/bg_non_interactive
78 chown system system /dev/cpuctl/bg_non_interactive/tasks
79 chmod 0777 /dev/cpuctl/bg_non_interactive/tasks
80 # 5.0 %
81 write /dev/cpuctl/bg_non_interactive/cpu.shares 52
San Mehat49330982009-04-21 14:34:19 -070082
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080083# mount mtd partitions
84 # Mount /system rw first to give the filesystem a chance to save a checkpoint
Chung-yih Wang1f75d702009-06-01 19:04:05 +080085 mount yaffs2 mtd@system /system
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080086 mount yaffs2 mtd@system /system ro remount
87
88 # We chown/chmod /data again so because mount is run as root + defaults
89 mount yaffs2 mtd@userdata /data nosuid nodev
90 chown system system /data
91 chmod 0771 /data
92
San Mehatf26d6ce2009-09-01 09:11:04 -070093 # Create dump dir and collect dumps.
94 # Do this before we mount cache so eventually we can use cache for
95 # storing dumps on platforms which do not have a dedicated dump partition.
96
97 mkdir /data/dontpanic
Mike Lockwood25f1a5a2009-09-11 17:13:28 -040098 chown root log /data/dontpanic
Mike Lockwood93324822009-09-08 22:55:59 -040099 chmod 0750 /data/dontpanic
San Mehatf26d6ce2009-09-01 09:11:04 -0700100
101 # Collect apanic data, free resources and re-arm trigger
102 copy /proc/apanic_console /data/dontpanic/apanic_console
Mike Lockwood25f1a5a2009-09-11 17:13:28 -0400103 chown root log /data/dontpanic/apanic_console
Mike Lockwood93324822009-09-08 22:55:59 -0400104 chmod 0640 /data/dontpanic/apanic_console
San Mehat020f35f2009-09-01 15:38:18 -0700105
San Mehatf26d6ce2009-09-01 09:11:04 -0700106 copy /proc/apanic_threads /data/dontpanic/apanic_threads
Mike Lockwood25f1a5a2009-09-11 17:13:28 -0400107 chown root log /data/dontpanic/apanic_threads
Mike Lockwood93324822009-09-08 22:55:59 -0400108 chmod 0640 /data/dontpanic/apanic_threads
San Mehat020f35f2009-09-01 15:38:18 -0700109
San Mehatf26d6ce2009-09-01 09:11:04 -0700110 write /proc/apanic_console 1
111
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800112 # Same reason as /data above
113 mount yaffs2 mtd@cache /cache nosuid nodev
114 chown system cache /cache
115 chmod 0770 /cache
116
117 # This may have been created by the recovery system with odd permissions
Doug Zongkereb67fac2009-11-19 16:52:02 -0800118 chown system cache /cache/recovery
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800119 chmod 0770 /cache/recovery
120
Rebecca Schultz Zavin14d898e2009-10-08 15:25:52 -0700121 #change permissions on vmallocinfo so we can grab it from bugreports
122 chown root log /proc/vmallocinfo
123 chmod 0440 /proc/vmallocinfo
124
Christopher Tate230cb332010-06-01 17:46:09 -0700125 #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
126 chown root system /proc/kmsg
127 chmod 0440 /proc/kmsg
128 chown root system /proc/sysrq-trigger
129 chmod 0220 /proc/sysrq-trigger
130
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800131# create basic filesystem structure
132 mkdir /data/misc 01771 system misc
Jaikumar Ganesh1d366962009-05-05 22:28:54 -0700133 mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
Jaikumar Ganesheafdd862010-01-07 20:24:55 -0800134 mkdir /data/misc/bluetooth 0770 system system
Chia-chi Yeh9b4f1ff2009-09-18 10:35:26 +0800135 mkdir /data/misc/keystore 0700 keystore keystore
Chung-yih Wang1f75d702009-06-01 19:04:05 +0800136 mkdir /data/misc/vpn 0770 system system
Oscar Montemayord0aa32c2010-01-06 13:18:12 -0800137 mkdir /data/misc/systemkeys 0700 system system
Chung-yih Wang1f75d702009-06-01 19:04:05 +0800138 mkdir /data/misc/vpn/profiles 0770 system system
Mike Lockwood48d116e2009-07-08 18:42:08 -0400139 # give system access to wpa_supplicant.conf for backup and restore
140 mkdir /data/misc/wifi 0770 wifi wifi
141 chmod 0770 /data/misc/wifi
Amith Yamasanieefef322009-07-02 12:08:13 -0700142 chmod 0660 /data/misc/wifi/wpa_supplicant.conf
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800143 mkdir /data/local 0771 shell shell
144 mkdir /data/local/tmp 0771 shell shell
145 mkdir /data/data 0771 system system
146 mkdir /data/app-private 0771 system system
147 mkdir /data/app 0771 system system
148 mkdir /data/property 0700 root root
149
150 # create dalvik-cache and double-check the perms
151 mkdir /data/dalvik-cache 0771 system system
152 chown system system /data/dalvik-cache
153 chmod 0771 /data/dalvik-cache
154
155 # create the lost+found directories, so as to enforce our permissions
156 mkdir /data/lost+found 0770
157 mkdir /cache/lost+found 0770
158
159 # double check the perms, in case lost+found already exists, and set owner
160 chown root root /data/lost+found
161 chmod 0770 /data/lost+found
162 chown root root /cache/lost+found
163 chmod 0770 /cache/lost+found
164
aimitakeshie572d592010-07-27 08:38:35 +0900165 # create data/drm directory
166 mkdir /data/drm 0774 drm drm
167 chown drm drm /data/drm
168 chmod 0774 /data/drm
169
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800170on boot
171# basic network init
172 ifup lo
173 hostname localhost
174 domainname localdomain
175
176# set RLIMIT_NICE to allow priorities from 19 to -20
177 setrlimit 13 40 40
178
179# Define the oom_adj values for the classes of processes that can be
180# killed by the kernel. These are used in ActivityManagerService.
181 setprop ro.FOREGROUND_APP_ADJ 0
182 setprop ro.VISIBLE_APP_ADJ 1
183 setprop ro.SECONDARY_SERVER_ADJ 2
Christopher Tate17df71e2009-06-05 18:20:08 -0700184 setprop ro.BACKUP_APP_ADJ 2
The Android Open Source Projecte4749f32009-03-09 11:52:15 -0700185 setprop ro.HOME_APP_ADJ 4
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800186 setprop ro.HIDDEN_APP_MIN_ADJ 7
187 setprop ro.CONTENT_PROVIDER_ADJ 14
188 setprop ro.EMPTY_APP_ADJ 15
189
190# Define the memory thresholds at which the above process classes will
191# be killed. These numbers are in pages (4k).
192 setprop ro.FOREGROUND_APP_MEM 1536
193 setprop ro.VISIBLE_APP_MEM 2048
194 setprop ro.SECONDARY_SERVER_MEM 4096
Christopher Tate17df71e2009-06-05 18:20:08 -0700195 setprop ro.BACKUP_APP_MEM 4096
The Android Open Source Projecte4749f32009-03-09 11:52:15 -0700196 setprop ro.HOME_APP_MEM 4096
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800197 setprop ro.HIDDEN_APP_MEM 5120
198 setprop ro.CONTENT_PROVIDER_MEM 5632
199 setprop ro.EMPTY_APP_MEM 6144
200
201# Write value must be consistent with the above properties.
The Android Open Source Projecte4749f32009-03-09 11:52:15 -0700202# Note that the driver only supports 6 slots, so we have HOME_APP at the
203# same memory level as services.
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800204 write /sys/module/lowmemorykiller/parameters/adj 0,1,2,7,14,15
205
206 write /proc/sys/vm/overcommit_memory 1
The Android Open Source Projecte037fd72009-03-13 13:04:37 -0700207 write /proc/sys/vm/min_free_order_shift 4
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800208 write /sys/module/lowmemorykiller/parameters/minfree 1536,2048,4096,5120,5632,6144
209
210 # Set init its forked children's oom_adj.
211 write /proc/1/oom_adj -16
212
San Mehat831d8e12009-10-13 12:24:47 -0700213 # Tweak background writeout
214 write /proc/sys/vm/dirty_expire_centisecs 200
215 write /proc/sys/vm/dirty_background_ratio 5
216
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800217 # Permissions for System Server and daemons.
218 chown radio system /sys/android_power/state
219 chown radio system /sys/android_power/request_state
220 chown radio system /sys/android_power/acquire_full_wake_lock
221 chown radio system /sys/android_power/acquire_partial_wake_lock
222 chown radio system /sys/android_power/release_wake_lock
223 chown radio system /sys/power/state
224 chown radio system /sys/power/wake_lock
225 chown radio system /sys/power/wake_unlock
226 chmod 0660 /sys/power/state
227 chmod 0660 /sys/power/wake_lock
228 chmod 0660 /sys/power/wake_unlock
229 chown system system /sys/class/timed_output/vibrator/enable
230 chown system system /sys/class/leds/keyboard-backlight/brightness
231 chown system system /sys/class/leds/lcd-backlight/brightness
232 chown system system /sys/class/leds/button-backlight/brightness
The Android Open Source Projectf614d642009-03-18 17:39:49 -0700233 chown system system /sys/class/leds/jogball-backlight/brightness
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800234 chown system system /sys/class/leds/red/brightness
235 chown system system /sys/class/leds/green/brightness
236 chown system system /sys/class/leds/blue/brightness
237 chown system system /sys/class/leds/red/device/grpfreq
238 chown system system /sys/class/leds/red/device/grppwm
239 chown system system /sys/class/leds/red/device/blink
240 chown system system /sys/class/leds/red/brightness
241 chown system system /sys/class/leds/green/brightness
242 chown system system /sys/class/leds/blue/brightness
243 chown system system /sys/class/leds/red/device/grpfreq
244 chown system system /sys/class/leds/red/device/grppwm
245 chown system system /sys/class/leds/red/device/blink
246 chown system system /sys/class/timed_output/vibrator/enable
247 chown system system /sys/module/sco/parameters/disable_esco
248 chown system system /sys/kernel/ipv4/tcp_wmem_min
249 chown system system /sys/kernel/ipv4/tcp_wmem_def
250 chown system system /sys/kernel/ipv4/tcp_wmem_max
251 chown system system /sys/kernel/ipv4/tcp_rmem_min
252 chown system system /sys/kernel/ipv4/tcp_rmem_def
253 chown system system /sys/kernel/ipv4/tcp_rmem_max
254 chown root radio /proc/cmdline
255
256# Define TCP buffer sizes for various networks
257# ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
258 setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
259 setprop net.tcp.buffersize.wifi 4095,87380,110208,4096,16384,110208
260 setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208
261 setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040
262 setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680
263
264 class_start default
265
266## Daemon processes to be run by init.
267##
268service console /system/bin/sh
269 console
270
271# adbd is controlled by the persist.service.adb.enable system property
272service adbd /sbin/adbd
273 disabled
274
275# adbd on at boot in emulator
276on property:ro.kernel.qemu=1
277 start adbd
278
279on property:persist.service.adb.enable=1
280 start adbd
281
282on property:persist.service.adb.enable=0
283 stop adbd
284
285service servicemanager /system/bin/servicemanager
286 user system
287 critical
288 onrestart restart zygote
289 onrestart restart media
290
The Android Open Source Projecte4749f32009-03-09 11:52:15 -0700291service vold /system/bin/vold
292 socket vold stream 0660 root mount
San Mehatf0cb74e2010-02-26 10:01:14 -0800293 ioprio be 2
The Android Open Source Projecte4749f32009-03-09 11:52:15 -0700294
San Mehat192277c2010-01-15 07:48:35 -0800295service netd /system/bin/netd
296 socket netd stream 0660 root system
297
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800298service debuggerd /system/bin/debuggerd
299
300service ril-daemon /system/bin/rild
301 socket rild stream 660 root radio
302 socket rild-debug stream 660 radio system
303 user root
Jean-Michel Trivi5e7db232009-11-02 15:22:18 -0800304 group radio cache inet misc audio
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800305
306service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
307 socket zygote stream 666
308 onrestart write /sys/android_power/request_state wake
309 onrestart write /sys/power/state on
Dan Bornstein1dec5032009-10-09 14:24:51 -0700310 onrestart restart media
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800311
aimitakeshie572d592010-07-27 08:38:35 +0900312service drm /system/bin/drmserver
313 user drm
314 group system root inet
315
316service drmio /system/bin/drmioserver
317 user drmio
318
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800319service media /system/bin/mediaserver
320 user media
Nick Pellyc741f222010-03-23 17:38:12 -0700321 group system audio camera graphics inet net_bt net_bt_admin net_raw
San Mehatf0cb74e2010-02-26 10:01:14 -0800322 ioprio rt 4
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800323
Mathias Agopian8b2cf9f2009-05-20 18:09:51 -0700324service bootanim /system/bin/bootanimation
325 user graphics
326 group graphics
327 disabled
328 oneshot
329
Jaikumar Ganesh13206872009-09-18 15:45:43 -0700330service dbus /system/bin/dbus-daemon --system --nofork
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800331 socket dbus stream 660 bluetooth bluetooth
332 user bluetooth
333 group bluetooth net_bt_admin
334
Jaikumar Ganesh13206872009-09-18 15:45:43 -0700335service bluetoothd /system/bin/bluetoothd -n
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800336 socket bluetooth stream 660 bluetooth bluetooth
337 socket dbus_bluetooth stream 660 bluetooth bluetooth
338 # init.rc does not yet support applying capabilities, so run as root and
Jaikumar Ganesh1d366962009-05-05 22:28:54 -0700339 # let bluetoothd drop uid to bluetooth with the right linux capabilities
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800340 group bluetooth net_bt_admin misc
341 disabled
342
343service hfag /system/bin/sdptool add --channel=10 HFAG
344 user bluetooth
345 group bluetooth net_bt_admin
346 disabled
347 oneshot
348
349service hsag /system/bin/sdptool add --channel=11 HSAG
350 user bluetooth
351 group bluetooth net_bt_admin
352 disabled
353 oneshot
354
Nick Pellyb44aeb72009-07-14 21:29:15 -0700355service opush /system/bin/sdptool add --channel=12 OPUSH
356 user bluetooth
357 group bluetooth net_bt_admin
358 disabled
359 oneshot
360
Jaikumar Ganesh630f5f02009-07-23 21:19:04 -0700361service pbap /system/bin/sdptool add --channel=19 PBAP
362 user bluetooth
363 group bluetooth net_bt_admin
364 disabled
365 oneshot
366
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800367service installd /system/bin/installd
368 socket installd stream 600 system system
369
Doug Zongkerd52f54c2009-07-23 15:18:34 -0700370service flash_recovery /system/etc/install-recovery.sh
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800371 oneshot
Chung-yih Wang1f75d702009-06-01 19:04:05 +0800372
Chia-chi Yeh51afbf52009-07-01 07:06:47 +0800373service racoon /system/bin/racoon
Chung-yih Wang1f75d702009-06-01 19:04:05 +0800374 socket racoon stream 600 system system
Chia-chi Yeh51afbf52009-07-01 07:06:47 +0800375 # racoon will setuid to vpn after getting necessary resources.
Chia-chi Yeh9b4f1ff2009-09-18 10:35:26 +0800376 group net_admin
Chung-yih Wang1f75d702009-06-01 19:04:05 +0800377 disabled
378 oneshot
379
380service mtpd /system/bin/mtpd
381 socket mtpd stream 600 system system
Chia-chi Yeh51afbf52009-07-01 07:06:47 +0800382 user vpn
383 group vpn net_admin net_raw
Chung-yih Wang1f75d702009-06-01 19:04:05 +0800384 disabled
385 oneshot
386
Chia-chi Yeh9b4f1ff2009-09-18 10:35:26 +0800387service keystore /system/bin/keystore /data/misc/keystore
Chung-yih Wang1f75d702009-06-01 19:04:05 +0800388 user keystore
389 group keystore
390 socket keystore stream 666
391
Mike Lockwoodabe3a9c2009-09-02 18:09:26 -0400392service dumpstate /system/bin/dumpstate -s
393 socket dumpstate stream 0660 shell log
394 disabled
395 oneshot