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