init.rc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. on fs
  2. sysclktz 0
  3. loglevel 3
  4. # setup the global environment
  5. export PATH /bin:/sbin:/usr/sbin:/usr/bin:/base/bin:/base/sbin:/opt/bin
  6. export GCONV_PATH /lib/gconv
  7. export DISPLAY :0.0
  8. symlink /startup/bin /bin
  9. symlink /startup/sbin /sbin
  10. mkdir /tmp
  11. mount tmpfs tmpfs /tmp
  12. mkdir /tmp/run
  13. mkdir /tmp/lock
  14. chmod 1777 /tmp/lock
  15. mkdir /var
  16. symlink /tmp /var/tmp
  17. symlink /tmp/run /var/run
  18. symlink /tmp/lock /var/lock
  19. mkdir /base
  20. loadimg mtd@base /base
  21. mkdir /data
  22. copy /proc/mtd /startup/mtd
  23. chmod 0444 /startup/mtd
  24. check_and_mount_data
  25. on early-boot
  26. # create POSIX shared memory folder
  27. mkdir /dev/shm
  28. chmod 0777 /dev/shm
  29. mount tmpfs tmpfs /dev/shm
  30. # restrict file permission under /usr/bin
  31. chmod 750 /usr/bin/modemd
  32. chmod 750 /usr/bin/pedd
  33. chmod 750 /usr/bin/ipservice
  34. chown root MAINAPP /usr/bin/crashd
  35. chmod 750 /usr/bin/crashd
  36. chown root root /usr/bin/devinfo
  37. chmod 755 /usr/bin/devinfo
  38. chown root MAINAPP /usr/bin/installer
  39. chmod 750 /usr/bin/installer
  40. chmod 750 /usr/bin/keyman
  41. # logcat, let it 755
  42. chown root MAINAPP /usr/bin/runapp
  43. chmod 750 /usr/bin/runapp
  44. chmod 750 /usr/bin/servicemanager
  45. chown root MAINAPP /usr/bin/tm
  46. chmod 750 /usr/bin/tm
  47. chown root MAINAPP /usr/bin/systemservice
  48. chmod 750 /usr/bin/systemservice
  49. chown root MAINAPP /usr/bin/ts_calibrate
  50. chmod 750 /usr/bin/ts_calibrate
  51. chown root MAINAPP /usr/bin/xcbd
  52. chmod 750 /usr/bin/xcbd
  53. # ./captoi sys_ptrace
  54. setcap 0x00080000 /bin/gdbserver
  55. # ./captoi dac_override setgid setuid setfcap chown
  56. setcap 0x800000c3 /usr/bin/installer
  57. # ./captoi setgid setuid
  58. setcap 0x000000c0 /usr/bin/runapp
  59. # ./captoi setgid setuid
  60. setcap 0x000000c0 /bin/xlogin
  61. # ./captoi net_admin net_raw sys_boot sys_time sys_admin
  62. setcap 0x02603000 /usr/bin/tm
  63. # ./captoi sys_admin sys_ptrace
  64. setcap 0x00280000 /usr/bin/crashd
  65. # ./captoi net_admin net_raw sys_boot sys_time sys_admin
  66. setcap 0x02603000 /usr/bin/systemservice
  67. # ./captoi sys_boot sys_time
  68. setcap 0x02400000 /usr/bin/xcbd
  69. mkdir /data/tombstones
  70. chmod 770 /data/tombstones
  71. chown MAINAPP MAINAPP /data/tombstones
  72. mkdir /data/security
  73. chmod 600 /data/security
  74. chown root root /data/security
  75. symlink /base/lib /lib
  76. symlink /data/etc /etc
  77. symlink /data/opt /opt
  78. symlink /lib/gconv /usr/lib/gconv
  79. write /proc/sys/kernel/randomize_va_space 2
  80. write /proc/sys/net/ipv4/tcp_keepalive_time 30
  81. write /proc/sys/net/ipv4/tcp_keepalive_intvl 15
  82. write /proc/sys/net/ipv4/tcp_keepalive_probes 5
  83. setprop ro.pukmode 2
  84. on boot
  85. # basic network init
  86. ifup lo
  87. hostname localhost
  88. domainname localdomain
  89. # mount usbfs
  90. mkdir /dev/bus/usb
  91. mount usbfs none /dev/bus/usb devmode=0666
  92. #u disk mount
  93. mkdir /mnt
  94. mount tmpfs tmpfs /mnt noatime noexec nosuid size=16k
  95. chown MAINAPP MAINAPP /mnt
  96. # set RLIMIT_NICE to allow priorities from 19 to -20
  97. # RLIMIT_NICE 13
  98. setrlimit 13 40 40
  99. # RLIMIT_STACK 3
  100. setrlimit 3 2097152 2097152
  101. class_start core
  102. if property:ro.fac.prolin_debug_level=0 rm /startup/bin/*
  103. if property:ro.fac.prolin_debug_level=0 rm /startup/sbin/*
  104. if property:ro.fac.prolin_debug_level=0 umount /proc
  105. if property:ro.fac.prolin_debug_level=0 rm /startup/modules/*
  106. if property:ro.fac.prolin_debug_level=0 rmdir /startup/modules/
  107. if property:ro.fac.prolin_debug_level=0 rm /startup/*.rc
  108. if property:ro.fac.prolin_debug_level=0 rm /startup/*.sh
  109. if property:ro.fac.prolin_debug_level=0 rm /startup/*.prop
  110. if property:ro.fac.prolin_debug_level=0 rm /startup/firmware/lcd_*.rle
  111. if property:ro.fac.prolin_debug_level=0 rm startup/firmware/lcd.watermark
  112. if property:ro.fac.prolin_debug_level=0 rm startup/firmware/lcd_readme.txt
  113. if property:ro.fac.prolin_debug_level=1 rm /startup/modules/*
  114. if property:ro.fac.prolin_debug_level=1 rmdir /startup/modules/
  115. if property:ro.fac.prolin_debug_level=1 rm /startup/*.rc
  116. if property:ro.fac.prolin_debug_level=1 rm /startup/*.sh
  117. if property:ro.fac.prolin_debug_level=1 rm /startup/*.prop
  118. wait /tmp/.BINDER_SERVICE_MANAGER_DONE
  119. rm /tmp/.BINDER_SERVICE_MANAGER_DONE
  120. class_start default
  121. ## Daemon processes to be run by init.
  122. service ueventd /startup/ueventd
  123. critical
  124. service console-root /bin/sh
  125. console
  126. disabled
  127. user root
  128. group root
  129. service console-MAINAPP /bin/sh
  130. console
  131. disabled
  132. user MAINAPP
  133. group MAINAPP
  134. on property:persist.sys.console.enable=1
  135. if property:ro.console=1 start console-MAINAPP
  136. if property:ro.console=2 start console-root
  137. on property:persist.sys.console.enable=0
  138. if property:ro.console=1 stop console-MAINAPP
  139. if property:ro.console=2 stop console-root