geofferey

[BASH] Init.d & 2nd-init.d Enabler (Android)

Dec 18th, 2014
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 19.02 KB | None | 0 0
  1. #!/system/bin/sh
  2. #Script to enable init.d/2nd-init.d by Ryuinferno, _alexndr & Geofferey @ XDA
  3. #Warning! May eat your cat!
  4.  
  5. CREATORS="Ryuinferno,  _alexndr & Geofferey @ XDA"
  6.  
  7. echo "Checking for the presence of sysinit in /system/bin..."
  8. sleep 1
  9.     if [ -z "`cat /system/bin/sysinit | grep "run-parts"`" ]; then
  10.         echo "No init.d support found"
  11.           export INIT=init.d
  12.           export SYSINIT=sysinit
  13.     else
  14.           echo ""
  15.           echo "Found init.d support already"
  16.         export INIT=2nd-init.d
  17.           export SYSINIT=sysinit2
  18. fi
  19.  
  20. selection=
  21.  until [ "$selection" = "*" ]; do
  22.  echo ""
  23.  echo "Universal init.d & 2nd-init.d Enabler "
  24.  echo ""
  25.  echo "Scripted By: $CREATORS"
  26.  echo ""
  27.  echo "Install Method"
  28.  echo "1 - Enable via recovery-install.sh"
  29.  echo "2 - Enable via init.local.rc"
  30.  echo "3 - Enable via init.qcom.post_boot.sh"
  31.  echo ""
  32.  echo -n "Make your choice: "
  33.  read selection
  34.  echo ""
  35.  
  36. case $selection in
  37.  
  38.  
  39. 1) error_msg(){
  40. echo "You do not need this mod..."
  41. sleep 1
  42. echo "If you are reapplying, please delete these files if present:"
  43. echo "/system/bin/$SYSINIT"
  44. sleep 1
  45. echo "/system/etc/install-recovery.sh"
  46. sleep 1
  47. echo "/system/etc/install-recovery-2.sh"
  48. sleep 1
  49. echo "And run again..."
  50. sleep 1
  51. echo "If $INIT is still not working, read the FAQ part in my thread..."
  52. sleep 1
  53. echo "Aborting..."
  54. mount -o remount,ro -t auto /system
  55. echo ""
  56. echo "Ryuinferno & Geofferey @ XDA"
  57. exit 1
  58. }
  59.  
  60. echo "$INIT Enabler by Ryuinferno & Geofferey @ XDA"
  61. echo ""
  62. sleep 1
  63.  
  64. id=`id`;
  65. id=`echo ${id#*=}`;
  66. id=`echo ${id%%\(*}`;
  67. id=`echo ${id%% *}`
  68. if [ "$id" != "0" ] && [ "$id" != "root" ]; then
  69.     echo "Script NOT running as root!"
  70.     sleep 1
  71.     echo "Superuser access not granted!"
  72.     sleep 1
  73.     echo "Please type 'su' first before running this script..."
  74.     exit 1
  75. else
  76.     echo "Hello Supaa User! :P"
  77.     echo ""
  78.     sleep 1
  79. fi
  80.  
  81. if [ ! "'which busybox'" ]; then
  82.     echo "busybox NOT INSTALLED!"
  83.     sleep 1
  84.     echo "Please install busybox first!"
  85.     exit 1
  86. else
  87.     echo "busybox found!"
  88.     sleep 1
  89. fi
  90.  
  91. bbb=0
  92.  
  93. if [ ! "`which grep`" ]; then
  94.     bbb=1
  95.     echo "grep applet NOT FOUND!"
  96.     sleep 1
  97.     else
  98.     echo "Awesome! grep found! :D"
  99.     sleep 1
  100. fi
  101.  
  102. if [ ! "`which run-parts`" ]; then
  103.     bbb=1
  104.     echo "run-parts applet NOT FOUND!"
  105.     sleep 1
  106.     else
  107.     echo "Good! run-parts found! :)"
  108.     echo ""
  109.     sleep 1
  110. fi
  111.  
  112. if [ $bbb -eq 1 ] ; then
  113.     echo ""
  114.     echo "Required applets are NOT FOUND!"
  115.     echo ""
  116.     sleep 1
  117.     echo "Please reinstall busybox!"
  118.     exit 1
  119. fi
  120.  
  121. echo "Great! Let's proceed..."
  122. echo ""
  123. sleep 1
  124. echo "Press enter to continue..."
  125. read enterKey
  126.  
  127. clear
  128. sleep 1
  129. echo "Mounting system as rewritable..."
  130. mount -o remount,rw -t auto /system
  131.  
  132. sleep 1
  133. echo ""
  134. echo "Checking for the presence of $SYSINIT in /system/bin..."
  135. sleep 1
  136. if [ -e /system/bin/$SYSINIT ]; then
  137.     echo "$SYSINIT found..."
  138.     if [ -z "`cat /system/bin/$SYSINIT | grep "$INIT"`" ]; then
  139.         echo "Adding lines to $SYSINIT..."
  140.         echo "" >> /system/bin/$SYSINIT
  141.         echo "# $INIT support" >> /system/bin/$SYSINIT
  142.         echo "" >> /system/bin/$SYSINIT
  143.         echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/$SYSINIT
  144.         echo "run-parts /system/etc/$INIT" >> /system/bin/$SYSINIT
  145.         echo "" >> /system/bin/$SYSINIT
  146.     else
  147.         echo ""
  148.         echo "Your $SYSINIT should already be running the scripts in $INIT folder at boot..."
  149.         error_msg
  150.     fi
  151. else
  152.     echo "$SYSINIT not found, creating file..."
  153.     echo "#!/system/bin/sh" > /system/bin/$SYSINIT
  154.     echo "# $INIT support" >> /system/bin/$SYSINIT
  155.     echo "" >> /system/bin/$SYSINIT
  156.     echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/$SYSINIT
  157.     echo "run-parts /system/etc/$INIT" >> /system/bin/$SYSINIT
  158.     echo "" >> /system/bin/$SYSINIT
  159. fi
  160.  
  161. sleep 1
  162. echo "Setting correct permissions and ownership for $SYSINIT..."
  163. chmod 755 /system/bin/$SYSINIT
  164. chown 0.2000 /system/bin/$SYSINIT
  165.  
  166. sleep 1
  167. echo ""
  168. echo "Checking for the presence of install-recovery.sh..."
  169. sleep 1
  170. if [ -f /system/etc/install-recovery.sh ] && [ -z "`cat /system/etc/install-recovery.sh | grep "daemon"`" ]; then
  171.     if [ ! -z "`cat /system/etc/install-recovery.sh | grep "$INIT"`" ];then
  172.         echo "Your install-recovery.sh seems to be already modified for $INIT..."
  173.         error_msg
  174.     fi
  175.     echo "install-recovery.sh found, renaming it as install-recovery-2.sh..."
  176.     mv /system/etc/install-recovery.sh /system/etc/install-recovery-2.sh
  177.     echo "Recreating install-recovery.sh..."
  178.     echo "#!/system/bin/sh" > /system/etc/install-recovery.sh
  179.     echo "# $INIT support" >> /system/etc/install-recovery.sh
  180.     echo "" >> /system/etc/install-recovery.sh
  181.     echo "/system/bin/$SYSINIT" >> /system/etc/install-recovery.sh
  182.     echo "" >> /system/etc/install-recovery.sh
  183.     echo "# excecuting extra commands" >> /system/etc/install-recovery.sh
  184.     echo "/system/etc/install-recovery-2.sh" >> /system/etc/install-recovery.sh
  185.     echo "" >> /system/etc/install-recovery.sh
  186. elif [ -f /system/etc/install-recovery.sh ] && [ ! -z "`cat /system/etc/install-recovery.sh | grep "daemon"`" ]; then
  187.     if [ -f /system/etc/install-recovery-2.sh ] && [ ! -z "`cat /system/etc/install-recovery-2.sh | grep "$SYSINIT"`" ];then
  188.         echo "Your install-recovery-2.sh seems to be already modified for $INIT..."
  189.         error_msg
  190.     fi
  191.     echo "install-recovery.sh is used for superuser, using install-recovery-2.sh instead..."
  192.     if [ -f /system/etc/install-recovery-2.sh ]; then
  193.         echo "" >> /system/etc/install-recovery-2.sh
  194.         echo "# $INIT support" >> /system/etc/install-recovery-2.sh
  195.         echo "/system/bin/$SYSINIT" >> /system/etc/install-recovery-2.sh
  196.         echo "" >> /system/etc/install-recovery-2.sh
  197.     else
  198.         echo "#!/system/bin/sh" > /system/etc/install-recovery-2.sh
  199.         echo "# $INIT support" >> /system/etc/install-recovery-2.sh
  200.         echo "" >> /system/etc/install-recovery-2.sh
  201.         echo "/system/bin/$SYSINIT" >> /system/etc/install-recovery-2.sh
  202.         echo "" >> /system/etc/install-recovery-2.sh
  203.     fi
  204.     if [ -z "`cat /system/etc/install-recovery.sh | grep "install-recovery-2.sh"`" ]; then
  205.         echo "" >> /system/etc/install-recovery.sh
  206.         echo "# extra commands" >> /system/etc/install-recovery.sh
  207.         echo "/system/etc/install-recovery-2.sh" >> /system/etc/install-recovery.sh
  208.         echo "" >> /system/etc/install-recovery.sh
  209.     fi
  210. else
  211.     echo "install-recovery.sh not found, creating it..."
  212.     echo "#!/system/bin/sh" > /system/etc/install-recovery.sh
  213.     echo "# $INIT support" >> /system/etc/install-recovery.sh
  214.     echo "" >> /system/etc/install-recovery.sh
  215.     echo "/system/bin/$SYSINIT" >> /system/etc/install-recovery.sh
  216.     echo "" >> /system/etc/install-recovery.sh
  217. fi
  218.  
  219. sleep 1
  220. echo "Setting the correct permissions and ownership for install-recovery.sh..."
  221. echo "Also for install-recovery-2.sh if it exists..."
  222. chmod 755 /system/etc/install-recovery.sh
  223. chown 0.0 /system/etc/install-recovery.sh
  224. if [ -f /system/etc/install-recovery-2.sh ]; then
  225.     chmod 755 /system/etc/install-recovery-2.sh
  226.     chown 0.0 /system/etc/install-recovery-2.sh
  227. fi
  228.  
  229. sleep 1
  230. echo ""
  231. echo "Checking for the presence of the $INIT folder..."
  232. sleep 1
  233. if [ -d /system/etc/$INIT ]; then
  234.     echo "$INIT folder found..."
  235. else
  236.     echo "$INIT folder not found, creating the folder..."
  237.     mkdir /system/etc/$INIT
  238. fi
  239.  
  240. sleep 1
  241. echo ""
  242. echo "Creating basic init.d scripts..."
  243. echo "#!/system/bin/sh" > /system/etc/$INIT/08setperm
  244. echo "#set correct permissions to /system/etc/$INIT folder" >> /system/etc/$INIT/08setperm
  245. echo "" >> /system/etc/$INIT/08setperm
  246. echo "mount -o remount,rw -t auto /system" >> /system/etc/$INIT/08setperm
  247. echo "chmod -R 777 /system/etc/$INIT" >> /system/etc/$INIT/08setperm
  248. echo "mount -o remount,ro -t auto /system" >> /system/etc/$INIT/08setperm
  249. echo "" >> /system/etc/$INIT/08setperm
  250.  
  251. echo "#!/system/bin/sh" > /system/etc/$INIT/00test
  252. echo "#$INIT test" >> /system/etc/$INIT/00test
  253. echo "" >> /system/etc/$INIT/00test
  254. echo "if [ -f /data/Test.log ]; then" >> /system/etc/$INIT/00test
  255. echo "rm /data/Test.log" >> /system/etc/$INIT/00test
  256. echo "fi" >> /system/etc/$INIT/00test
  257. echo "" >> /system/etc/$INIT/00test
  258. echo 'echo "$INIT is working !!!" >> /data/Test.log' >> /system/etc/$INIT/00test
  259. echo 'echo "excecuted on $(date +"%d-%m-%Y %r" )" >> /data/Test.log' >> /system/etc/$INIT/00test
  260. echo "" >> /system/etc/$INIT/00test
  261.  
  262. sleep 1
  263. echo "Setting correct permissions and ownership for $INIT folder and scipts..."
  264. chmod 777 /system/etc/$INIT
  265. chmod 777 /system/etc/$INIT/08setperm
  266. chmod 777 /system/etc/$INIT/00test
  267. chown 0.0 /system/etc/$INIT
  268. chown 0.0 /system/etc/$INIT/08setperm
  269. chown 0.0 /system/etc/$INIT/00test
  270.  
  271. sleep 1
  272. echo ""
  273. echo "Mounting system as read-only..."
  274. mount -o remount,ro -t auto /system
  275. sleep 1
  276. echo ""
  277. echo "Done!!!"
  278. sleep 1
  279. echo "Please reboot at least twice before checking /data..."
  280. sleep 1
  281. echo "If $INIT is working, you will see a Test.log in /data..."
  282. sleep 1
  283. echo ""
  284. echo "Enjoy!!! =)"
  285. echo "Ryuinferno & Geofferey @ XDA 2013/14"
  286. exit;;
  287.  
  288. 2) error_msg(){
  289. echo "You do not need this mod..."
  290. sleep 1
  291. echo "If you are reapplying, please delete these files if present:"
  292. echo "/system/bin/$SYSINIT"
  293. sleep 1
  294. echo "/system/etc/init.local.rc"
  295. sleep 1
  296. echo "/system/etc/init.local-2.rc"
  297. sleep 1
  298. echo "And run again..."
  299. sleep 1
  300. echo "If $INIT is still not working, read the FAQ part in my thread..."
  301. sleep 1
  302. echo "Aborting..."
  303. mount -o remount,ro -t auto /system
  304. echo ""
  305. echo "Ryuinferno & Geofferey @ XDA"
  306. exit 1
  307. }
  308.  
  309. echo "$INIT Enabler by Ryuinferno & Geofferey @ XDA"
  310. echo ""
  311. sleep 1
  312.  
  313. id=`id`;
  314. id=`echo ${id#*=}`;
  315. id=`echo ${id%%\(*}`;
  316. id=`echo ${id%% *}`
  317. if [ "$id" != "0" ] && [ "$id" != "root" ]; then
  318.     echo "Script NOT running as root!"
  319.     sleep 1
  320.     echo "Superuser access not granted!"
  321.     sleep 1
  322.     echo "Please type 'su' first before running this script..."
  323.     exit 1
  324. else
  325.     echo "Hello Supaa User! :P"
  326.     echo ""
  327.     sleep 1
  328. fi
  329.  
  330. if [ ! "'which busybox'" ]; then
  331.     echo "busybox NOT INSTALLED!"
  332.     sleep 1
  333.     echo "Please install busybox first!"
  334.     exit 1
  335. else
  336.     echo "busybox found!"
  337.     sleep 1
  338. fi
  339.  
  340. bbb=0
  341.  
  342. if [ ! "`which grep`" ]; then
  343.     bbb=1
  344.     echo "grep applet NOT FOUND!"
  345.     sleep 1
  346.     else
  347.     echo "Awesome! grep found! :D"
  348.     sleep 1
  349. fi
  350.  
  351. if [ ! "`which run-parts`" ]; then
  352.     bbb=1
  353.     echo "run-parts applet NOT FOUND!"
  354.     sleep 1
  355.     else
  356.     echo "Good! run-parts found! :)"
  357.     echo ""
  358.     sleep 1
  359. fi
  360.  
  361. if [ $bbb -eq 1 ] ; then
  362.     echo ""
  363.     echo "Required applets are NOT FOUND!"
  364.     echo ""
  365.     sleep 1
  366.     echo "Please reinstall busybox!"
  367.     exit 1
  368. fi
  369.  
  370. echo "Great! Let's proceed..."
  371. echo ""
  372. sleep 1
  373. echo "Press enter to continue..."
  374. read enterKey
  375.  
  376. clear
  377. sleep 1
  378. echo "Mounting system as rewritable..."
  379. mount -o remount,rw -t auto /system
  380.  
  381. sleep 1
  382. echo ""
  383. echo "Checking for the presence of $SYSINIT in /system/bin..."
  384. sleep 1
  385. if [ -e /system/bin/$SYSINIT ]; then
  386.     echo "$SYSINIT found..."
  387.     if [ -z "`cat /system/bin/$SYSINIT | grep "$INIT"`" ]; then
  388.         echo "Adding lines to $SYSINIT..."
  389.         echo "" >> /system/bin/$SYSINIT
  390.         echo "# $INIT support" >> /system/bin/$SYSINIT
  391.         echo "" >> /system/bin/$SYSINIT
  392.         echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/$SYSINIT
  393.         echo "run-parts /system/etc/$INIT" >> /system/bin/$SYSINIT
  394.         echo "" >> /system/bin/$SYSINIT
  395.     else
  396.         echo ""
  397.         echo "Your $SYSINIT should already be running the scripts in $INIT folder at boot..."
  398.         error_msg
  399.     fi
  400. else
  401.     echo "$SYSINIT not found, creating file..."
  402.     echo "#!/system/bin/sh" > /system/bin/$SYSINIT
  403.     echo "# $INIT support" >> /system/bin/$SYSINIT
  404.     echo "" >> /system/bin/$SYSINIT
  405.     echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/$SYSINIT
  406.     echo "run-parts /system/etc/$INIT" >> /system/bin/$SYSINIT
  407.     echo "" >> /system/bin/$SYSINIT
  408. fi
  409.  
  410. sleep 1
  411. echo "Setting correct permissions and ownership for $SYSINIT..."
  412. chmod 755 /system/bin/$SYSINIT
  413. chown 0.2000 /system/bin/$SYSINIT
  414.  
  415. sleep 1
  416. echo ""
  417. echo "Checking for the presence of init.local.rc..."
  418. sleep 1
  419. if [ -f /system/etc/init.local.rc ] && [ -z "`cat /system/etc/init.local.rc | grep "daemon"`" ]; then
  420.     if [ ! -z "`cat /system/etc/init.local.rc | grep "$INIT"`" ];then
  421.         echo "Your init.local.rc seems to be already modified for $INIT..."
  422.         error_msg
  423.     fi
  424.     echo "init.local.rc found, renaming it as init.local-2.rc..."
  425.     mv /system/etc/init.local.rc /system/etc/init.local-2.rc
  426.     echo "Recreating init.local.rc..."
  427.     echo "# $INIT Support" >> /system/etc/init.local.rc
  428.     echo "" >> /system/etc/init.local.rc
  429.     echo "service $SYSINIT /system/bin/$SYSINIT" >> /system/etc/init.local.rc
  430.     echo "    user root" >> /system/etc/init.local.rc
  431.      echo "    group root" >> /system/etc/init.local.rc
  432.      echo "    oneshot" >> /system/etc/init.local.rc
  433.      echo "" >> /system/etc/init.local.rc
  434.     echo "# excecuting extra commands" >> /system/etc/init.local.rc
  435.     echo " service into.local-2.rc /system/etc/init.local-2.rc" >> /system/etc/init.local.rc
  436.       echo "    user root"  >> /system/etc/init.local.rc
  437.       echo "    group root"  >> /system/etc/init.local.rc
  438.       echo "    oneshot"  >> /system/etc/init.local.rc
  439.      echo "" >> /system/etc/init.local.rc
  440.  
  441. elif [ -f /system/etc/init.local.rc ] && [ ! -z "`cat /system/etc/init.local.rc | grep "daemon"`" ]; then
  442.     if [ -f /system/etc/init.local-2.rc ] && [ ! -z "`cat /system/etc/init.local-2.rc | grep "$INIT"`" ];then
  443.         echo "Your init.local-2.rc seems to be already modified for $INIT..."
  444.         error_msg
  445.     fi
  446.     echo "init.local.rc is used for superuser, using init.local-2.rc instead..."
  447.     if [ -f /system/etc/init.local-2.rc ]; then
  448.         echo "" >> /system/etc/init.local-2.rc
  449.         echo "# $INIT support" >> /system/etc/init.local-2.rc
  450.         echo "service $SYSINIT /system/bin/$SYSINIT" >> /system/etc/init.local-2.rc
  451.           echo "    user root"  >> /system/etc/init.local-2.rc
  452.           echo "    group root"  >> /system/etc/init.local-2.rc
  453.           echo "    oneshot"  >> /system/etc/init.local-2.rc
  454.         echo "" >> /system/etc/init.local-2.rc
  455.     else
  456.         echo "# $INIT support" >> /system/etc/init.local-2.rc
  457.         echo "service $SYSINIT /system/bin/$SYSINIT" >> /system/etc/init.local-2.rc
  458.           echo "    user root"  >> /system/etc/init.local-2.rc
  459.           echo "    group root"  >> /system/etc/init.local-2.rc
  460.           echo "    oneshot"  >> /system/etc/init.local-2.rc
  461.         echo "" >> /system/etc/init.local-2.rc
  462.     fi
  463.     if [ -z "`cat /system/etc/init.local.rc | grep "init.local-2.rc"`" ]; then
  464.         echo "" >> /system/etc/init.local.rc
  465.         echo "# extra commands" >> /system/etc/init.local.rc
  466.           echo ""
  467.         echo "service init.local.rc /system/etc/init.local.rc" >> /system/etc/init.local.rc
  468.           echo "    user root" >> /system/etc/init.local.rc
  469.           echo "    group root" >> /system/etc/init.local.rc
  470.           echo "    oneshot" >> /system/etc/init.local.rc
  471.         echo "" >> /system/etc/init.local.rc
  472.     fi
  473. else
  474.     echo "init.local.rc not found, creating it..."
  475.     echo "# $INIT Support" >> /system/etc/init.local.rc
  476.     echo "" >> /system/etc/init.local.rc
  477.     echo "service $SYSINIT /system/bin/$SYSINIT" >> /system/etc/init.local.rc
  478.     echo "    user root" >> /system/etc/init.local.rc
  479.      echo "    group root" >> /system/etc/init.local.rc
  480.      echo "    oneshot" >> /system/etc/init.local.rc
  481.      echo "" >> /system/etc/init.local.rc
  482. fi
  483.  
  484. sleep 1
  485. echo "Setting the correct permissions and ownership for install-recovery.sh..."
  486. echo "Also for install-recovery-2.sh if it exists..."
  487. chmod 755 /system/etc/init.local.rc
  488. chown 0.0 /system/etc/init.local.rc
  489. if [ -f /system/etc/init.local-2.rc ]; then
  490.     chmod 755 /system/etc/init.local-2.rc
  491.     chown 0.0 /system/etc/init.local-2.rc
  492. fi
  493.  
  494. sleep 1
  495. echo ""
  496. echo "Checking for the presence of the $INIT folder..."
  497. sleep 1
  498. if [ -d /system/etc/$INIT ]; then
  499.     echo "$INIT folder found..."
  500. else
  501.     echo "$INIT folder not found, creating the folder..."
  502.     mkdir /system/etc/$INIT
  503. fi
  504.  
  505. sleep 1
  506. echo ""
  507. echo "Creating basic init.d scripts..."
  508. echo "#!/system/bin/sh" > /system/etc/$INIT/08setperm
  509. echo "#set correct permissions to /system/etc/$INIT folder" >> /system/etc/$INIT/08setperm
  510. echo "" >> /system/etc/$INIT/08setperm
  511. echo "mount -o remount,rw -t auto /system" >> /system/etc/$INIT/08setperm
  512. echo "chmod -R 777 /system/etc/$INIT" >> /system/etc/$INIT/08setperm
  513. echo "mount -o remount,ro -t auto /system" >> /system/etc/$INIT/08setperm
  514. echo "" >> /system/etc/$INIT/08setperm
  515.  
  516. echo "#!/system/bin/sh" > /system/etc/$INIT/00test
  517. echo "#$INIT test" >> /system/etc/$INIT/00test
  518. echo "" >> /system/etc/$INIT/00test
  519. echo "if [ -f /data/Test.log ]; then" >> /system/etc/$INIT/00test
  520. echo "rm /data/Test.log" >> /system/etc/$INIT/00test
  521. echo "fi" >> /system/etc/$INIT/00test
  522. echo "" >> /system/etc/$INIT/00test
  523. echo 'echo "$INIT is working !!!" >> /data/Test.log' >> /system/etc/$INIT/00test
  524. echo 'echo "excecuted on $(date +"%d-%m-%Y %r" )" >> /data/Test.log' >> /system/etc/$INIT/00test
  525. echo "" >> /system/etc/$INIT/00test
  526.  
  527. sleep 1
  528. echo "Setting correct permissions and ownership for $INIT folder and scipts..."
  529. chmod 777 /system/etc/$INIT
  530. chmod 777 /system/etc/$INIT/08setperm
  531. chmod 777 /system/etc/$INIT/00test
  532. chown 0.0 /system/etc/$INIT
  533. chown 0.0 /system/etc/$INIT/08setperm
  534. chown 0.0 /system/etc/$INIT/00test
  535.  
  536. sleep 1
  537. echo ""
  538. echo "Mounting system as read-only..."
  539. mount -o remount,ro -t auto /system
  540. sleep 1
  541. echo ""
  542. echo "Done!!!"
  543. sleep 1
  544. echo "Please reboot at least twice before checking /data..."
  545. sleep 1
  546. echo "If $INIT is working, you will see a Test.log in /data..."
  547. sleep 1
  548. echo ""
  549. echo "Enjoy!!! =)"
  550. echo "Ryuinferno & Geofferey @ XDA 2013"
  551. exit;;
  552.  
  553. 3) if [ -z "`cat /system/etc/init.qcom.post_boot.sh | grep "run-parts"`" ] ; then
  554.     echo "" >> /system/etc/init.qcom.post_boot.sh
  555.     echo "# $INIT support" >> /system/etc/init.qcom.post_boot.sh
  556.     echo "run-parts /system/etc/$INIT" >> /system/etc/init.qcom.post_boot.sh
  557.     echo "" >> /system/etc/init.qcom.post_boot.sh
  558. fi
  559.  
  560. if [ ! -d /system/etc/$INIT ] ; then
  561.     mkdir /system/etc/$INIT
  562. fi
  563.  
  564. echo "#!/system/bin/sh" > /system/etc/$INIT/00test
  565. echo "# $INIT test" >> /system/etc/$INIT/00test
  566. echo "" >> /system/etc/$INIT/00test
  567. echo "if [ -f /data/Test.log ] ; then" >> /system/etc/$INIT/00test
  568. echo "    rm /data/Test.log" >> /system/etc/$INIT/00test
  569. echo "fi" >> /system/etc/$INIT/00test
  570. echo "" >> /system/etc/$INIT/00test
  571. echo 'echo "$INIT is working !!!" >> /data/Test.log' >> /system/etc/$INIT/00test
  572. echo 'echo "excecuted on $(date +"%d-%m-%Y %r" )" >> /data/Test.log' >> /system/etc/$INIT/00test
  573. echo "" >> /system/etc/$INIT/00test
  574.  
  575. echo "#!/system/bin/sh" > /system/etc/$INIT/08setperm
  576. echo "# Set correct permissions to $INIT scripts" >> /system/etc/$INIT/08setperm
  577. echo "" >> /system/etc/$INIT/08setperm
  578. echo "mount -o remount,rw /system" >> /system/etc/$INIT/08setperm
  579. echo "chmod 777 /system/etc/$INIT/*" >> /system/etc/$INIT/08setperm
  580. echo "mount -o remount,ro /system" >> /system/etc/$INIT/08setperm
  581. echo "" >> /system/etc/$INIT/08setperm
  582.  
  583. chown 0:0 /system/etc/init.qcom.post_boot.sh
  584. chmod 644 /system/etc/init.qcom.post_boot.sh
  585. chcon u:object_r:system_file:s0 /system/etc/init.qcom.post_boot.sh
  586.  
  587. chown 0:0 /system/etc/$INIT
  588. chmod 777 /system/etc/$INIT
  589. chcon u:object_r:system_file:s0 /system/etc/$INIT
  590.  
  591. chown 0:0 /system/etc/$INIT/*
  592. chmod 777 /system/etc/$INIT/*
  593. chcon u:object_r:system_file:s0 /system/etc/$INIT/*
  594.  
  595. sync;;
  596.  
  597. esac
  598. done
Advertisement
Add Comment
Please, Sign In to add comment