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