Guest User

init.rc

a guest
Sep 13th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.64 KB | None | 0 0
  1. import /init.${ro.hardware}.rc
  2. import /init.usb.rc
  3. import /init.trace.rc
  4.  
  5. on early-init
  6. # Set init and its forked children's oom_adj.
  7. write /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 1200000
  8. write /proc/1/oom_adj -16
  9.  
  10. start ueventd
  11.  
  12. # create mountpoints
  13. mkdir /mnt 0775 root system
  14.  
  15. on init
  16.  
  17. sysclktz 0
  18.  
  19. loglevel 3
  20.  
  21. # setup the global environment
  22. export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
  23. export LD_LIBRARY_PATH /vendor/lib:/system/lib
  24. export ANDROID_BOOTLOGO 1
  25. export ANDROID_CACHE /cache
  26. export ANDROID_ROOT /system
  27. export ANDROID_ASSETS /system/app
  28. export ANDROID_DATA /data
  29. export ASEC_MOUNTPOINT /mnt/asec
  30. export LOOP_MOUNTPOINT /mnt/obb
  31. export BOOTCLASSPATH /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework2.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar
  32.  
  33. # Backward compatibility
  34. symlink /system/etc /etc
  35. symlink /sys/kernel/debug /d
  36.  
  37. # Right now vendor lives on the same filesystem as system,
  38. # but someday that may change.
  39. symlink /system/vendor /vendor
  40.  
  41. # Create cgroup mount point for cpu accounting
  42. mkdir /acct
  43. mount cgroup none /acct cpuacct
  44. mkdir /acct/uid
  45.  
  46. mkdir /system
  47. mkdir /data 0771 system system
  48. mkdir /cache 0771 system cache
  49. mkdir /config 0500 root root
  50.  
  51. # Directory for putting things only root should see.
  52. mkdir /mnt/secure 0700 root root
  53.  
  54. # Directory for staging bindmounts
  55. mkdir /mnt/secure/staging 0700 root root
  56.  
  57. # Directory-target for where the secure container
  58. # imagefile directory will be bind-mounted
  59. mkdir /mnt/secure/asec 0700 root root
  60.  
  61. # Secure container public mount points.
  62. mkdir /mnt/asec 0700 root system
  63. mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
  64.  
  65. # Filesystem image public mount points.
  66. mkdir /mnt/obb 0700 root system
  67. mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
  68.  
  69. write /proc/sys/kernel/panic_on_oops 1
  70. write /proc/sys/kernel/hung_task_timeout_secs 0
  71. write /proc/cpu/alignment 4
  72. write /proc/sys/kernel/sched_latency_ns 10000000
  73. write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
  74. write /proc/sys/kernel/sched_compat_yield 1
  75. write /proc/sys/kernel/sched_child_runs_first 0
  76. write /proc/sys/kernel/randomize_va_space 2
  77. write /proc/sys/kernel/kptr_restrict 2
  78. write /proc/sys/kernel/dmesg_restrict 1
  79. write /proc/sys/vm/mmap_min_addr 32768
  80. write /proc/sys/kernel/sched_rt_runtime_us 950000
  81. write /proc/sys/kernel/sched_rt_period_us 1000000
  82.  
  83. # Create cgroup mount points for process groups
  84. mkdir /dev/cpuctl
  85. mount cgroup none /dev/cpuctl cpu
  86. chown system system /dev/cpuctl
  87. chown system system /dev/cpuctl/tasks
  88. chmod 0660 /dev/cpuctl/tasks
  89. write /dev/cpuctl/cpu.shares 1024
  90. write /dev/cpuctl/cpu.rt_runtime_us 950000
  91. write /dev/cpuctl/cpu.rt_period_us 1000000
  92.  
  93. mkdir /dev/cpuctl/apps
  94. chown system system /dev/cpuctl/apps/tasks
  95. chmod 0666 /dev/cpuctl/apps/tasks
  96. write /dev/cpuctl/apps/cpu.shares 1024
  97. write /dev/cpuctl/apps/cpu.rt_runtime_us 800000
  98. write /dev/cpuctl/apps/cpu.rt_period_us 1000000
  99.  
  100. mkdir /dev/cpuctl/apps/bg_non_interactive
  101. chown system system /dev/cpuctl/apps/bg_non_interactive/tasks
  102. chmod 0666 /dev/cpuctl/apps/bg_non_interactive/tasks
  103. # 5.0 %
  104. write /dev/cpuctl/apps/bg_non_interactive/cpu.shares 52
  105. write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_runtime_us 700000
  106. write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_period_us 1000000
  107.  
  108. # Allow everybody to read the xt_qtaguid resource tracking misc dev.
  109. # This is needed by any process that uses socket tagging.
  110. chmod 0644 /dev/xt_qtaguid
  111.  
  112. on fs
  113. # mount mtd partitions
  114. # Mount /system rw first to give the filesystem a chance to save a checkpoint
  115. mount yaffs2 mtd@system /system
  116. mount yaffs2 mtd@system /system ro remount
  117. mount yaffs2 mtd@userdata /data nosuid nodev
  118. mount yaffs2 mtd@cache /cache nosuid nodev
  119.  
  120. on post-fs
  121. # once everything is setup, no need to modify /
  122. mount rootfs rootfs / ro remount
  123.  
  124. # We chown/chmod /cache again so because mount is run as root + defaults
  125. chown system cache /cache
  126. chmod 0771 /cache
  127.  
  128. # This may have been created by the recovery system with odd permissions
  129. chown system cache /cache/recovery
  130. chmod 0770 /cache/recovery
  131.  
  132. #change permissions on vmallocinfo so we can grab it from bugreports
  133. chown root log /proc/vmallocinfo
  134. chmod 0440 /proc/vmallocinfo
  135.  
  136. #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
  137. chown root system /proc/kmsg
  138. chmod 0440 /proc/kmsg
  139. chown root system /proc/sysrq-trigger
  140. chmod 0220 /proc/sysrq-trigger
  141.  
  142. # create the lost+found directories, so as to enforce our permissions
  143. mkdir /cache/lost+found 0770 root root
  144.  
  145. on post-fs-data
  146. # We chown/chmod /data again so because mount is run as root + defaults
  147. chown system system /data
  148. chmod 0771 /data
  149.  
  150. # Create dump dir and collect dumps.
  151. # Do this before we mount cache so eventually we can use cache for
  152. # storing dumps on platforms which do not have a dedicated dump partition.
  153. mkdir /data/dontpanic 0750 root log
  154.  
  155. # Collect apanic data, free resources and re-arm trigger
  156. copy /proc/apanic_console /data/dontpanic/apanic_console
  157. chown root log /data/dontpanic/apanic_console
  158. chmod 0640 /data/dontpanic/apanic_console
  159.  
  160. copy /proc/apanic_threads /data/dontpanic/apanic_threads
  161. chown root log /data/dontpanic/apanic_threads
  162. chmod 0640 /data/dontpanic/apanic_threads
  163.  
  164. write /proc/apanic_console 1
  165.  
  166. # create basic filesystem structure
  167. mkdir /data/misc 01771 system misc
  168. mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
  169. mkdir /data/misc/bluetooth 0770 system system
  170. mkdir /data/misc/keystore 0700 keystore keystore
  171. mkdir /data/misc/keychain 0771 system system
  172. mkdir /data/misc/vpn 0770 system vpn
  173. mkdir /data/misc/systemkeys 0700 system system
  174. # give system access to wpa_supplicant.conf for backup and restore
  175. mkdir /data/misc/wifi 0770 wifi wifi
  176. chmod 0660 /data/misc/wifi/wpa_supplicant.conf
  177. mkdir /data/local 0751 root root
  178.  
  179. # For security reasons, /data/local/tmp should always be empty.
  180. # Do not place files or directories in /data/local/tmp
  181. mkdir /data/local/tmp 0771 shell shell
  182. mkdir /data/data 0771 system system
  183. mkdir /data/app-private 0771 system system
  184. mkdir /data/app-asec 0700 root root
  185. mkdir /data/app 0771 system system
  186. mkdir /data/property 0700 root root
  187. mkdir /data/ssh 0750 root shell
  188. mkdir /data/ssh/empty 0700 root root
  189.  
  190. # create dalvik-cache, so as to enforce our permissions
  191. mkdir /data/dalvik-cache 0771 system system
  192. chown system system /data/dalvik-cache
  193. chmod 0771 /data/dalvik-cache
  194. mkdir /cache/dalvik-cache 0771 system system
  195. chown system system /cache/dalvik-cache
  196. chmod 0771 /cache/dalvik-cache
  197.  
  198. # create resource-cache and double-check the perms
  199. mkdir /data/resource-cache 0771 system system
  200. chown system system /data/resource-cache
  201. chmod 0771 /data/resource-cache
  202.  
  203. # create the lost+found directories, so as to enforce our permissions
  204. mkdir /data/lost+found 0770 root root
  205.  
  206. # create directory for DRM plug-ins - give drm the read/write access to
  207. # the following directory.
  208. mkdir /data/drm 0770 drm drm
  209.  
  210. # If there is no fs-post-data action in the init.<device>.rc file, you
  211. # must uncomment this line, otherwise encrypted filesystems
  212. # won't work.
  213. # Set indication (checked by vold) that we have finished this action
  214. #setprop vold.post_fs_data_done 1
  215.  
  216. # Include extra init file
  217. import /system/etc/init.local.rc
  218.  
  219. on boot
  220. # basic network init
  221. ifup lo
  222. hostname localhost
  223. domainname localdomain
  224.  
  225. # set RLIMIT_NICE to allow priorities from 19 to -20
  226. setrlimit 13 40 40
  227.  
  228. # Memory management. Basic kernel parameters, and allow the high
  229. # level system server to be able to adjust the kernel OOM driver
  230. # parameters to match how it is managing things.
  231. write /proc/sys/vm/overcommit_memory 1
  232. write /proc/sys/vm/min_free_order_shift 4
  233. chown root system /sys/module/lowmemorykiller/parameters/adj
  234. chmod 0664 /sys/module/lowmemorykiller/parameters/adj
  235. chown root system /sys/module/lowmemorykiller/parameters/minfree
  236. chmod 0664 /sys/module/lowmemorykiller/parameters/minfree
  237.  
  238. # Tweak background writeout
  239. write /proc/sys/vm/dirty_expire_centisecs 200
  240. write /proc/sys/vm/dirty_background_ratio 5
  241.  
  242. # Permissions for System Server and daemons.
  243. chown radio system /sys/android_power/state
  244. chown radio system /sys/android_power/request_state
  245. chown radio system /sys/android_power/acquire_full_wake_lock
  246. chown radio system /sys/android_power/acquire_partial_wake_lock
  247. chown radio system /sys/android_power/release_wake_lock
  248. chown system system /sys/power/state
  249. chown system system /sys/power/wakeup_count
  250. chown radio system /sys/power/wake_lock
  251. chown radio system /sys/power/wake_unlock
  252. chmod 0660 /sys/power/state
  253. chmod 0660 /sys/power/wake_lock
  254. chmod 0660 /sys/power/wake_unlock
  255.  
  256. chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_rate
  257. chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_rate
  258. chown system system /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
  259. chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
  260. chown system system /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
  261. chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
  262. chown system system /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
  263. chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
  264. chown system system /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
  265. chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
  266. chown system system /sys/devices/system/cpu/cpufreq/interactive/boost
  267. chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boost
  268. chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse
  269. chown system system /sys/devices/system/cpu/cpufreq/interactive/input_boost
  270. chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/input_boost
  271.  
  272. # Assume SMP uses shared cpufreq policy for all CPUs
  273. chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
  274. chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
  275.  
  276. chown system system /sys/class/timed_output/vibrator/enable
  277. chown system system /sys/class/leds/keyboard-backlight/brightness
  278. chown system system /sys/class/leds/lcd-backlight/brightness
  279. chown system system /sys/class/leds/button-backlight/brightness
  280. chown system system /sys/class/leds/jogball-backlight/brightness
  281. chown system system /sys/class/leds/red/brightness
  282. chown system system /sys/class/leds/green/brightness
  283. chown system system /sys/class/leds/blue/brightness
  284. chown system system /sys/class/leds/red/device/grpfreq
  285. chown system system /sys/class/leds/red/device/grppwm
  286. chown system system /sys/class/leds/red/device/blink
  287. chown system system /sys/class/leds/red/brightness
  288. chown system system /sys/class/leds/green/brightness
  289. chown system system /sys/class/leds/blue/brightness
  290. chown system system /sys/class/leds/red/device/grpfreq
  291. chown system system /sys/class/leds/red/device/grppwm
  292. chown system system /sys/class/leds/red/device/blink
  293. chown system system /sys/class/timed_output/vibrator/enable
  294. chown system system /sys/module/sco/parameters/disable_esco
  295. chown system system /sys/kernel/ipv4/tcp_wmem_min
  296. chown system system /sys/kernel/ipv4/tcp_wmem_def
  297. chown system system /sys/kernel/ipv4/tcp_wmem_max
  298. chown system system /sys/kernel/ipv4/tcp_rmem_min
  299. chown system system /sys/kernel/ipv4/tcp_rmem_def
  300. chown system system /sys/kernel/ipv4/tcp_rmem_max
  301. chown root radio /proc/cmdline
  302.  
  303. # allow system to modify cpufreq control files
  304. chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  305. chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  306. chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
  307. chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
  308. chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
  309. chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
  310.  
  311. # Define TCP buffer sizes for various networks
  312. # ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
  313. setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
  314. setprop net.tcp.buffersize.wifi 524288,1048576,2097152,262144,524288,1048576
  315. setprop net.tcp.buffersize.lte 524288,1048576,2097152,262144,524288,1048576
  316. setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208
  317. setprop net.tcp.buffersize.hspa 4094,87380,262144,4096,16384,262144
  318. setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040
  319. setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680
  320.  
  321. # allow system to modify ksm control files
  322. chown root system /sys/kernel/mm/ksm/pages_to_scan
  323. chmod 0664 /sys/kernel/mm/ksm/pages_to_scan
  324. chown root system /sys/kernel/mm/ksm/sleep_millisecs
  325. chmod 0664 /sys/kernel/mm/ksm/sleep_millisecs
  326. chown root system /sys/kernel/mm/ksm/run
  327. chmod 0664 /sys/kernel/mm/ksm/run
  328. write /sys/kernel/mm/ksm/sleep_millisecs 1500
  329. write /sys/kernel/mm/ksm/pages_to_scan 256
  330.  
  331. # Set this property so surfaceflinger is not started by system_init
  332. setprop system_init.startsurfaceflinger 0
  333.  
  334. # Run sysinit
  335. exec /system/bin/sysinit
  336.  
  337. class_start core
  338. class_start main
  339.  
  340. on nonencrypted
  341. class_start late_start
  342.  
  343. on charger
  344. class_start charger
  345.  
  346. on property:vold.decrypt=trigger_reset_main
  347. class_reset main
  348.  
  349. on property:vold.decrypt=trigger_load_persist_props
  350. load_persist_props
  351.  
  352. on property:vold.decrypt=trigger_post_fs_data
  353. trigger post-fs-data
  354.  
  355. on property:vold.decrypt=trigger_restart_min_framework
  356. class_start main
  357.  
  358. on property:vold.decrypt=trigger_restart_framework
  359. class_start main
  360. class_start late_start
  361.  
  362. on property:vold.decrypt=trigger_shutdown_framework
  363. class_reset late_start
  364. class_reset main
  365.  
  366. ## Daemon processes to be run by init.
  367. ##
  368. service ueventd /sbin/ueventd
  369. class core
  370. critical
  371.  
  372. service console /system/bin/sh
  373. class core
  374. console
  375. disabled
  376. user shell
  377. group log
  378.  
  379. on property:ro.debuggable=1
  380. start console
  381.  
  382. # adbd is controlled via property triggers in init.<platform>.usb.rc
  383. service adbd /sbin/adbd
  384. class core
  385. disabled
  386.  
  387. # adbd on at boot in emulator
  388. on property:ro.kernel.qemu=1
  389. start adbd
  390.  
  391. service servicemanager /system/bin/servicemanager
  392. class core
  393. user system
  394. group system
  395. critical
  396. onrestart restart zygote
  397. onrestart restart media
  398. onrestart restart surfaceflinger
  399. onrestart restart drm
  400.  
  401. service vold /system/bin/vold
  402. class core
  403. socket vold stream 0660 root mount
  404. ioprio be 2
  405.  
  406. service netd /system/bin/netd
  407. class main
  408. socket netd stream 0660 root system
  409. socket dnsproxyd stream 0660 root inet
  410. socket mdns stream 0660 root system
  411.  
  412. service debuggerd /system/bin/debuggerd
  413. class main
  414.  
  415. service ril-daemon /system/bin/rild
  416. class main
  417. socket rild stream 660 root radio
  418. socket rild-debug stream 660 radio system
  419. user root
  420. group radio cache inet misc audio sdcard_rw log
  421.  
  422. service surfaceflinger /system/bin/surfaceflinger
  423. class main
  424. user system
  425. group graphics
  426. onrestart restart zygote
  427.  
  428. service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
  429. class main
  430. socket zygote stream 660 root system
  431. onrestart write /sys/android_power/request_state wake
  432. onrestart write /sys/power/state on
  433. onrestart restart media
  434. onrestart restart netd
  435.  
  436. service drm /system/bin/drmserver
  437. class main
  438. user drm
  439. group drm system inet drmrpc sdcard_r
  440.  
  441. service media /system/bin/mediaserver
  442. class main
  443. user media
  444. group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc
  445. ioprio rt 4
  446.  
  447. service bootanim /system/bin/bootanimation
  448. class main
  449. user graphics
  450. group graphics
  451. disabled
  452. oneshot
  453.  
  454. service dbus /system/bin/dbus-daemon --system --nofork
  455. class main
  456. socket dbus stream 660 bluetooth bluetooth
  457. user bluetooth
  458. group bluetooth net_bt_admin
  459.  
  460. service bluetoothd /system/bin/bluetoothd -n
  461. class main
  462. socket bluetooth stream 660 bluetooth bluetooth
  463. socket dbus_bluetooth stream 660 bluetooth bluetooth
  464. # init.rc does not yet support applying capabilities, so run as root and
  465. # let bluetoothd drop uid to bluetooth with the right linux capabilities
  466. group bluetooth net_bt_admin misc
  467. disabled
  468.  
  469. service installd /system/bin/installd
  470. class main
  471. socket installd stream 600 system system
  472.  
  473. service flash_recovery /system/etc/install-recovery.sh
  474. class main
  475. oneshot
  476.  
  477. service racoon /system/bin/racoon
  478. class main
  479. socket racoon stream 600 system system
  480. # IKE uses UDP port 500. Racoon will setuid to vpn after binding the port.
  481. group vpn net_admin inet
  482. disabled
  483. oneshot
  484.  
  485. service mtpd /system/bin/mtpd
  486. class main
  487. socket mtpd stream 600 system system
  488. user vpn
  489. group vpn net_admin inet net_raw
  490. disabled
  491. oneshot
  492.  
  493. service keystore /system/bin/keystore /data/misc/keystore
  494. class main
  495. user keystore
  496. group keystore drmrpc
  497. socket keystore stream 666
  498.  
  499. service dumpstate /system/bin/dumpstate -s
  500. class main
  501. socket dumpstate stream 0660 shell log
  502. disabled
  503. oneshot
  504.  
  505. service sshd /system/bin/start-ssh
  506. class main
  507. disabled
  508.  
  509. service mdnsd /system/bin/mdnsd
  510. class main
  511. user mdnsr
  512. group inet net_raw
  513. socket mdnsd stream 0660 mdnsr inet
  514. disabled
  515. oneshot
  516.  
  517. # adb over network
  518. on property:service.adb.tcp.port=5555
  519. stop adbd
  520. start adbd
  521. on property:service.adb.tcp.port=-1
  522. stop adbd
  523. start adbd
  524.  
  525. service lkconfig /sbin/init.d/lkconfig.sh
  526. class main
  527. oneshot
  528.  
  529. service run_parts /sbin/bb/busybox run-parts /system/etc/init.d
  530. class main
  531. oneshot
Advertisement
Add Comment
Please, Sign In to add comment