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