10 # setup the global environment
11 export PATH /bin:/sbin:/system/sbin:/system/bin:/system/xbin:/system/xbin/bb:/data/local/bin
12 export LD_LIBRARY_PATH /system/lib
13 export ANDROID_BOOTLOGO 1
14 export ANDROID_ROOT /system
15 export ANDROID_ASSETS /system/app
16 export ANDROID_DATA /data
17 export EXTERNAL_STORAGE /sdcard
18 export ASEC_MOUNTPOINT /mnt/asec
19 export BOOTCLASSPATH /system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar
21 # Backward compatibility
22 symlink /system/etc /etc
23 symlink /sys/kernel/debug /d
26 mkdir /mnt 0775 root system
27 mkdir /sdcard 0000 system system
29 # Create cgroup mount point for cpu accounting
31 mount cgroup none /acct cpuacct
35 mkdir /data 0771 system system
36 mkdir /cache 0770 system cache
37 mkdir /config 0500 root root
39 # Directory for putting things only root should see.
40 mkdir /mnt/secure 0700 root root
42 # Directory for staging bindmounts
43 mkdir /mnt/secure/staging 0700 root root
45 # Directory-target for where the secure container
46 # imagefile directory will be bind-mounted
47 mkdir /mnt/secure/asec 0700 root root
49 # Secure container public mount points.
50 mkdir /mnt/asec 0700 root system
51 mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
53 mount rootfs rootfs / ro remount
55 write /proc/sys/kernel/panic_on_oops 1
56 write /proc/sys/kernel/hung_task_timeout_secs 0
57 write /proc/cpu/alignment 4
58 write /proc/sys/kernel/sched_latency_ns 10000000
59 write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
60 write /proc/sys/kernel/sched_compat_yield 1
61 write /proc/sys/kernel/sched_child_runs_first 0
63 # Create cgroup mount points for process groups
65 mount cgroup none /dev/cpuctl cpu
66 chown system system /dev/cpuctl
67 chown system system /dev/cpuctl/tasks
68 chmod 0777 /dev/cpuctl/tasks
69 write /dev/cpuctl/cpu.shares 1024
71 mkdir /dev/cpuctl/fg_boost
72 chown system system /dev/cpuctl/fg_boost/tasks
73 chmod 0777 /dev/cpuctl/fg_boost/tasks
74 write /dev/cpuctl/fg_boost/cpu.shares 1024
76 mkdir /dev/cpuctl/bg_non_interactive
77 chown system system /dev/cpuctl/bg_non_interactive/tasks
78 chmod 0777 /dev/cpuctl/bg_non_interactive/tasks
80 write /dev/cpuctl/bg_non_interactive/cpu.shares 52
82 # mount mtd partitions
83 # Mount /system rw first to give the filesystem a chance to save a checkpoint
84 mount yaffs2 mtd@system /system
85 mount yaffs2 mtd@system /system ro remount
87 # We chown/chmod /data again so because mount is run as root + defaults
88 mount yaffs2 mtd@userdata /data nosuid nodev
89 chown system system /data
92 # Create dump dir and collect dumps.
93 # Do this before we mount cache so eventually we can use cache for
94 # storing dumps on platforms which do not have a dedicated dump partition.
97 chown root log /data/dontpanic
98 chmod 0750 /data/dontpanic
100 # Collect apanic data, free resources and re-arm trigger
101 #copy /proc/apanic_console /data/dontpanic/apanic_console
102 #chown root log /data/dontpanic/apanic_console
103 #chmod 0640 /data/dontpanic/apanic_console
105 #copy /proc/apanic_threads /data/dontpanic/apanic_threads
106 #chown root log /data/dontpanic/apanic_threads
107 #chmod 0640 /data/dontpanic/apanic_threads
109 #write /proc/apanic_console 1
111 # Same reason as /data above
112 mount yaffs2 mtd@cache /cache nosuid nodev
113 chown system cache /cache
116 # XDAndroid permissions
119 chmod 0777 /dev/smd27
120 chown radio radio /etc/ppp/pap-secrets
121 chown radio radio /etc/ppp/chap-secrets
122 chown root radio /etc/ppp/options.smd1
123 chmod 0600 /etc/ppp/pap-secrets
124 chmod 0600 /etc/ppp/chap-secrets
125 chmod 0775 /etc/ppp/options.smd1
127 chmod 0777 /dev/camera
128 chmod 0777 /dev/vogue_gps
130 # This may have been created by the recovery system with odd permissions
131 chown system cache /cache/recovery
132 chmod 0770 /cache/recovery
134 #change permissions on vmallocinfo so we can grab it from bugreports
135 chown root log /proc/vmallocinfo
136 chmod 0440 /proc/vmallocinfo
138 #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
139 chown root system /proc/kmsg
140 chmod 0440 /proc/kmsg
141 chown root system /proc/sysrq-trigger
142 chmod 0220 /proc/sysrq-trigger
144 # create basic filesystem structure
145 mkdir /data/misc 01771 system misc
146 mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
147 mkdir /data/misc/bluetooth 0770 system system
148 mkdir /data/misc/keystore 0700 1017 1017
149 mkdir /data/misc/vpn 0770 system system
150 mkdir /data/misc/systemkeys 0700 system system
151 mkdir /data/misc/vpn/profiles 0770 system system
154 # give system access to wpa_supplicant.conf for backup and restore
155 mkdir /data/misc/wifi 0770 wifi wifi
156 chmod 0770 /data/misc/wifi
157 chmod 0660 /data/misc/wifi/wpa_supplicant.conf
158 mkdir /data/misc/wifi/sockets 0770 wifi wifi
159 mkdir /data/misc/dhcp 0770 dhcp dhcp
160 chown dhcp dhcp /data/misc/dhcp
162 mkdir /data/local 0771 shell shell
163 mkdir /data/local/tmp 0771 shell shell
164 mkdir /data/data 0771 system system
165 mkdir /data/app-private 0771 system system
166 mkdir /data/app 0771 system system
167 mkdir /data/property 0700 root root
169 # create dalvik-cache and double-check the perms
170 mkdir /data/dalvik-cache 0771 system system
171 chown system system /data/dalvik-cache
172 chmod 0771 /data/dalvik-cache
174 # create the lost+found directories, so as to enforce our permissions
175 mkdir /data/lost+found 0770
176 mkdir /cache/lost+found 0770
178 # double check the perms, in case lost+found already exists, and set owner
179 chown root root /data/lost+found
180 chmod 0770 /data/lost+found
181 chown root root /cache/lost+found
182 chmod 0770 /cache/lost+found
188 domainname localdomain
190 # set RLIMIT_NICE to allow priorities from 19 to -20
193 # Define the oom_adj values for the classes of processes that can be
194 # killed by the kernel. These are used in ActivityManagerService.
195 setprop ro.FOREGROUND_APP_ADJ 0
196 setprop ro.VISIBLE_APP_ADJ 1
197 setprop ro.PERCEPTIBLE_APP_ADJ 2
198 setprop ro.HEAVY_WEIGHT_APP_ADJ 3
199 setprop ro.SECONDARY_SERVER_ADJ 4
200 setprop ro.BACKUP_APP_ADJ 5
201 setprop ro.HOME_APP_ADJ 6
202 setprop ro.HIDDEN_APP_MIN_ADJ 7
203 setprop ro.EMPTY_APP_ADJ 15
205 # Define the memory thresholds at which the above process classes will
206 # be killed. These numbers are in pages (4k).
207 setprop ro.FOREGROUND_APP_MEM 2048
208 setprop ro.VISIBLE_APP_MEM 3072
209 setprop ro.PERCEPTIBLE_APP_MEM 4096
210 setprop ro.HEAVY_WEIGHT_APP_MEM 4096
211 setprop ro.SECONDARY_SERVER_MEM 6144
212 setprop ro.BACKUP_APP_MEM 6144
213 setprop ro.HOME_APP_MEM 6144
214 setprop ro.HIDDEN_APP_MEM 7168
215 setprop ro.EMPTY_APP_MEM 8192
217 # Write value must be consistent with the above properties.
218 # Note that the driver only supports 6 slots, so we have HOME_APP at the
219 # same memory level as services.
220 write /sys/module/lowmemorykiller/parameters/adj 0,1,2,7,14,15
222 write /proc/sys/vm/overcommit_memory 1
223 write /proc/sys/vm/min_free_order_shift 4
224 write /sys/module/lowmemorykiller/parameters/minfree 1536,2048,4096,5120,5632,6144
226 # Set init its forked children's oom_adj.
227 write /proc/1/oom_adj -16
229 # Tweak background writeout
230 write /proc/sys/vm/dirty_expire_centisecs 200
231 write /proc/sys/vm/dirty_background_ratio 5
233 # Permissions for System Server and daemons.
234 chown radio system /sys/android_power/state
235 chown radio system /sys/android_power/request_state
236 chown radio system /sys/android_power/acquire_full_wake_lock
237 chown radio system /sys/android_power/acquire_partial_wake_lock
238 chown radio system /sys/android_power/release_wake_lock
239 chown radio system /sys/power/state
240 chown radio system /sys/power/wake_lock
241 chown radio system /sys/power/wake_unlock
242 chmod 0660 /sys/power/state
243 chmod 0660 /sys/power/wake_lock
244 chmod 0660 /sys/power/wake_unlock
245 chown system system /sys/class/timed_output/vibrator/enable
246 chown system system /sys/class/leds/keyboard-backlight/brightness
247 chown system system /sys/class/leds/lcd-backlight/brightness
248 chown system system /sys/class/leds/button-backlight/brightness
249 chown system system /sys/class/leds/jogball-backlight/brightness
250 chown system system /sys/class/leds/red/brightness
251 chown system system /sys/class/leds/green/brightness
252 chown system system /sys/class/leds/blue/brightness
253 chown system system /sys/class/leds/red/device/grpfreq
254 chown system system /sys/class/leds/red/device/grppwm
255 chown system system /sys/class/leds/red/device/blink
256 chown system system /sys/class/leds/red/brightness
257 chown system system /sys/class/leds/green/brightness
258 chown system system /sys/class/leds/blue/brightness
259 chown system system /sys/class/leds/red/device/grpfreq
260 chown system system /sys/class/leds/red/device/grppwm
261 chown system system /sys/class/leds/red/device/blink
262 chown system system /sys/class/timed_output/vibrator/enable
263 chown system system /sys/module/sco/parameters/disable_esco
264 chown system system /sys/kernel/ipv4/tcp_wmem_min
265 chown system system /sys/kernel/ipv4/tcp_wmem_def
266 chown system system /sys/kernel/ipv4/tcp_wmem_max
267 chown system system /sys/kernel/ipv4/tcp_rmem_min
268 chown system system /sys/kernel/ipv4/tcp_rmem_def
269 chown system system /sys/kernel/ipv4/tcp_rmem_max
270 chown root radio /proc/cmdline
272 # XDAndroid permissions
273 chmod 0777 /sys/class/vogue_hw/audio
274 chmod 0777 /sys/class/vogue_hw/vibrate
275 chmod 0777 /sys/class/vogue_hw/lcd
276 chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type
277 chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state
278 chmod 0660 /sys/class/rfkill/rfkill0/state
279 chown bluetooth bluetooth /dev/ttyMSM0
280 chmod 0666 /dev/ttyHS1
281 chown root radio /proc/cmdline
282 chmod 666 /proc/cmdline
283 chmod 666 /dev/input/event0
284 chmod 666 /dev/input/event1
285 chmod 666 /dev/input/event2
286 chmod 666 /dev/input/event3
287 chmod 666 /dev/input/event4
288 chmod 666 /dev/input/event5
289 chmod 666 /dev/input/event6
290 chmod 666 /sys/class/i2c-adapter/i2c-0/0-0018/enable
291 chmod 666 /sys/class/i2c-adapter/i2c-0/0-0019/enable
292 chmod 666 /sys/class/i2c-adapter/i2c-0/0-0018/rate
293 chmod 666 /sys/class/i2c-adapter/i2c-0/0-0019/rate
294 chmod 666 /sys/class/i2c-adapter/i2c-0/0-0018/scale
295 chmod 666 /sys/class/i2c-adapter/i2c-0/0-0019/scale
296 chmod 666 /dev/uinput
297 chmod 666 /etc/bluez/audio.conf
298 chmod 666 /etc/bluez/hcid.conf
299 chmod 666 /etc/bluez/input.conf
300 chmod 666 /dev/msm_snd
301 chmod 666 /dev/msm_pcm_in
302 chmod 666 /dev/msm_audpre
303 chmod 666 /dev/msm_mp3
304 chmod 666 /dev/msm_pcm_out
305 chmod 666 /dev/msm_pcm_ctl
306 chmod 666 /dev/msm_hw3dm
307 chmod 666 /dev/msm_hw3dc
309 # Define TCP buffer sizes for various networks
310 # ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
311 setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
312 setprop net.tcp.buffersize.wifi 4095,87380,110208,4096,16384,110208
313 setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208
314 setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040
315 setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680
317 # XDAndroid boots off an sd card, so tell vold that it's already mounted
318 setprop EXTERNAL_STORAGE_STATE mounted
322 ## Daemon processes to be run by init.
324 service ueventd /sbin/ueventd
327 service console /bin/sh
330 # adbd is controlled by the persist.service.adb.enable system property
331 service adbd /sbin/adbd
334 # adbd on at boot in emulator
335 on property:ro.kernel.qemu=1
338 on property:persist.service.adb.enable=1
341 on property:persist.service.adb.enable=0
344 service servicemanager /system/bin/servicemanager
347 onrestart restart zygote
348 onrestart restart media
349 onrestart restart netd
351 service vold /system/bin/vold
352 socket vold stream 0660 root mount
355 service netd /bin/netd
356 socket netd stream 0660 root system
358 service debuggerd /system/bin/debuggerd
360 service ril-daemon /system/bin/rild -l /system/lib/libhtcgeneric-ril.so -- -d /dev/smd0
361 socket rild stream 660 root radio
362 socket rild-debug stream 660 radio system
364 group radio cache inet misc audio sdcard_rw
366 service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
367 socket zygote stream 666
368 onrestart write /sys/android_power/request_state wake
369 onrestart write /sys/power/state on
370 onrestart restart media
372 service media /system/bin/mediaserver
374 group system audio camera graphics inet net_bt net_bt_admin net_raw
377 service bootanim /system/bin/bootanimation
383 service dbus /system/bin/dbus-daemon --system --nofork
384 socket dbus stream 660 bluetooth bluetooth
386 group bluetooth net_bt_admin
388 service bluetoothd /system/bin/bluetoothd -n
389 socket bluetooth stream 660 bluetooth bluetooth
390 socket dbus_bluetooth stream 660 bluetooth bluetooth
391 # init.rc does not yet support applying capabilities, so run as root and
392 # let bluetoothd drop uid to bluetooth with the right linux capabilities
393 group bluetooth net_bt_admin misc
396 service hfag /system/bin/sdptool add --channel=10 HFAG
398 group bluetooth net_bt_admin
402 service hsag /system/bin/sdptool add --channel=11 HSAG
404 group bluetooth net_bt_admin
408 service opush /system/bin/sdptool add --channel=12 OPUSH
410 group bluetooth net_bt_admin
414 service pbap /system/bin/sdptool add --channel=19 PBAP
416 group bluetooth net_bt_admin
420 service installd /system/bin/installd
421 socket installd stream 600 system system
423 service flash_recovery /system/etc/install-recovery.sh
426 service racoon /system/bin/racoon
427 socket racoon stream 600 system system
428 # racoon will setuid to vpn after getting necessary resources.
433 service mtpd /system/bin/mtpd
434 socket mtpd stream 600 system system
436 group vpn net_admin net_raw
440 service keystore /system/bin/keystore /data/misc/keystore
443 socket keystore stream 666
445 service dumpstate /system/bin/dumpstate -s
446 socket dumpstate stream 0660 shell log
450 service hciattach /system/bin/hciattach \
451 -n -s 115200 /dev/ttyHS1 texas 115200 flow
453 group bluetooth net_bt_admin
456 service wlan_loader /etc/wifi/loadit
460 service wpa_supplicant /system/bin/wpa_supplicant \
461 -Dtiwlan0 -itiwlan0 -c/data/misc/wifi/wpa_supplicant.conf -q
462 # we will start as root and wpa_supplicant will switch to user wifi
463 # after setting up the capabilities required for WEXT
465 # group wifi inet keystore
466 socket wpa_tiwlan0 dgram 660 wifi wifi
470 service dhcpcd /system/bin/dhcpcd -ABKL
474 service pppd_gprs /system/bin/pppd /dev/smd1 defaultroute local usepeerdns \
475 noipdefault unit 0 nodetach linkname gprs novj novjccomp