Advertisement
Guest User

Untitled

a guest
Dec 1st, 2011
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.89 KB | None | 0 0
  1. #!/system/bin/sh
  2.  
  3. PATH=/sbin:/system/bin:/system/xbin
  4.  
  5. # Run original binary
  6. /system/bin/mot_boot_mode.bin "$@"
  7.  
  8. # Get USB mode (if fail, boot USB enumeration mode)
  9. USBMODE=$(getprop ro.usb_mode)
  10.  
  11. # Write date to log
  12. RUNDATE=`date`
  13.  
  14. # Write uid/gid to log
  15. RUNAS=`id`
  16.  
  17. # Set old and new init.rc locations
  18. OLDINIT=/init.rc
  19. NEWINITRC=/system/etc/rootfs/init.rc
  20.  
  21. # Get md5 sums for old and new init.rc
  22. OLDMD5=`cat $OLDINIT | md5sum`
  23. NEWMD5=`cat $NEWINIT | md5sum`
  24.  
  25. # Set additional root files locations
  26. NEWMAPPHONE=/system/etc/rootfs/init.olympus.rc
  27. NEWPHONEUEVENTD=/system/etc/rootfs/ueventd.olympus.rc
  28. NEWPROP=/system/etc/rootfs/default.prop
  29. NEWINIT=/system/etc/rootfs/init
  30. NEWUVENTD=/system/etc/rootfs/ueventd.rc
  31. # Check log dir
  32. if [ ! -d /data/2nd-init ]; then
  33.     mkdir /data/2nd-init
  34. fi
  35.  
  36. echo "Run date: $RUNDATE." >> /data/2nd-init/log
  37. echo "Running as: $RUNAS." >> /data/2nd-init/log
  38. echo "Usb mode is: $USBMODE." >> /data/2nd-init/log
  39.  
  40. # Run 2nd-init if not in debug mode
  41. if [ "$USBMODE" != "debug" ]; then
  42.     # Compare md5 hash to determine useful copy
  43.     if [ "$OLDMD5" != "$NEWMD5" ]; then
  44.         # Remount rootfs read/write to copy new files
  45.         mount -o remount,rw rootfs / >> /data/2nd-init/log 2>&1
  46.         mount -o remount,rw /system/
  47.         mv /sbin/adbd /sbin/adbd.old
  48.         setprop ctl.stop runtime
  49.         setprop ctl.zygote
  50.         setprop persist.service.adb.enable 1
  51.         # Copy new root files
  52.     cp -p /system/bin/fixboot.sh /sbin
  53.     cp -p /system/bin/hijack.killall /sbin
  54.     cp -p /system/xbin/busybox /sbin
  55.     cp -p /system/etc/rootfs/* /.
  56.     cp -p /system/etc/rootfs/sbin/* /sbin
  57.         #Setup BusyBox
  58.         cd /sbin
  59.         ln -s busybox [
  60.         ln -s busybox [[
  61.         ln -s busybox ash
  62.         ln -s busybox awk
  63.         ln -s busybox basename
  64.         ln -s busybox bbconfig
  65.         ln -s busybox bunzip2
  66.         ln -s busybox bzcat
  67.         ln -s busybox bzip2
  68.         ln -s busybox cal
  69.         ln -s busybox cat
  70.         ln -s busybox catv
  71.         ln -s busybox chattr
  72.         ln -s busybox chgrp
  73.         ln -s busybox chmod
  74.         ln -s busybox chown
  75.         ln -s busybox chroot
  76.         ln -s busybox cksum
  77.         ln -s busybox clear
  78.         ln -s busybox cmp
  79.         ln -s busybox cp
  80.         ln -s busybox cpio
  81.         ln -s busybox cut
  82.         ln -s busybox date
  83.         ln -s busybox dc
  84.         ln -s busybox dd
  85.         ln -s busybox depmod
  86.         ln -s busybox devmem
  87.         ln -s busybox df
  88.         ln -s busybox diff
  89.         ln -s busybox dirname
  90.         ln -s busybox dmesg
  91.         ln -s busybox dos2unix
  92.         ln -s busybox du
  93.         ln -s busybox echo
  94.         ln -s busybox egrep
  95.         ln -s busybox env
  96.         ln -s busybox expand
  97.         ln -s busybox expr
  98.         ln -s busybox false
  99.         ln -s busybox fdisk
  100.         ln -s busybox fgrep
  101.         ln -s busybox find
  102.         ln -s busybox fold
  103.         ln -s busybox free
  104.         ln -s busybox freeramdisk
  105.         ln -s busybox fuser
  106.         ln -s busybox getopt
  107.         ln -s busybox grep
  108.         ln -s busybox groups
  109.         ln -s busybox gunzip
  110.         ln -s busybox gzip
  111.         ln -s busybox head
  112.         ln -s busybox hexdump
  113.         ln -s busybox id
  114.         ln -s busybox insmod
  115.         ln -s busybox install
  116.         ln -s busybox kill
  117.         ln -s busybox killall
  118.         ln -s busybox killall5
  119.         ln -s busybox length
  120.         ln -s busybox less
  121.         ln -s busybox ln
  122.         ln -s busybox losetup
  123.         ln -s busybox ls
  124.         ln -s busybox lsattr
  125.         ln -s busybox lsmod
  126.         ln -s busybox lspci
  127.         ln -s busybox lsusb
  128.         ln -s busybox lzcat
  129.         ln -s busybox lzop
  130.         ln -s busybox lzopcat
  131.         ln -s busybox makedevs
  132.         ln -s busybox md5sum
  133.         ln -s busybox mkdir
  134.         ln -s busybox mkfifo
  135.         ln -s busybox mkfs.ext2
  136.         ln -s busybox mknod
  137.         ln -s busybox mkswap
  138.         ln -s busybox mktemp
  139.         ln -s busybox modinfo
  140.         ln -s busybox modprobe
  141.         ln -s busybox more
  142.         ln -s busybox mount
  143.         ln -s busybox mountpoint
  144.         ln -s busybox mv
  145.         ln -s busybox nanddump
  146.         ln -s busybox nandwrite
  147.         ln -s busybox nice
  148.         ln -s busybox nohup
  149.         ln -s busybox od
  150.         ln -s busybox patch
  151.         ln -s busybox pgrep
  152.         ln -s busybox pidof
  153.         ln -s busybox pkill
  154.         ln -s busybox printenv
  155.         ln -s busybox printf
  156.         ln -s busybox ps
  157.         ln -s busybox pstree
  158.         ln -s busybox pwd
  159.         ln -s busybox rdev
  160.         ln -s busybox readlink
  161.         ln -s busybox realpath
  162.         ln -s busybox renice
  163.         ln -s busybox reset
  164.         ln -s busybox resize
  165.         ln -s busybox rev
  166.         ln -s busybox rm
  167.         ln -s busybox rmdir
  168.         ln -s busybox rmmod
  169.         ln -s busybox run-parts
  170.         ln -s busybox sed
  171.         ln -s busybox seq
  172.         ln -s busybox setconsole
  173.         ln -s busybox setserial
  174.         ln -s busybox setsid
  175.         ln -s busybox sh
  176.         ln -s busybox sha1sum
  177.         ln -s busybox sha256sum
  178.         ln -s busybox sha512sum
  179.         ln -s busybox sleep
  180.         ln -s busybox sort
  181.         ln -s busybox split
  182.         ln -s busybox stat
  183.         ln -s busybox strings
  184.         ln -s busybox stty
  185.         ln -s busybox swapoff
  186.         ln -s busybox swapon
  187.         ln -s busybox sync
  188.         ln -s busybox sysctl
  189.         ln -s busybox tac
  190.         ln -s busybox tail
  191.         ln -s busybox tar
  192.         ln -s busybox tee
  193.         ln -s busybox test
  194.         ln -s busybox time
  195.         ln -s busybox top
  196.         ln -s busybox touch
  197.         ln -s busybox tr
  198.         ln -s busybox true
  199.         ln -s busybox tty
  200.         ln -s busybox umount
  201.         ln -s busybox uname
  202.         ln -s busybox unexpand
  203.         ln -s busybox uniq
  204.         ln -s busybox unix2dos
  205.         ln -s busybox unlzma
  206.         ln -s busybox unlzop
  207.         ln -s busybox unxz
  208.         ln -s busybox unzip
  209.         ln -s busybox uptime
  210.         ln -s busybox usleep
  211.         ln -s busybox uudecode
  212.         ln -s busybox uuencode
  213.         ln -s busybox watch
  214.         ln -s busybox wc
  215.         ln -s busybox which
  216.         ln -s busybox whoami
  217.         ln -s busybox xargs
  218.         ln -s busybox xzcat
  219.         ln -s busybox yes
  220.         ln -s busybox zcat
  221.         cd /
  222.  
  223.     #log file structs
  224.     ls -l / >> /data/2nd-init/rootstruct.txt
  225.     ls -l /sbin >> /data/2nd-init/sbinstruct.txt
  226.     ls -l /system/etc/rootfs >> /data/2nd-init/rootfsstruct.txt
  227.         #Run kill all
  228.         /sbin/hijack.killall >> /data/2nd-init/ka.log
  229.        
  230.         # Set dual-core processor affinity
  231.         taskset -p -c 0 1
  232.  
  233.         # Sync buffer and write
  234.         sync
  235.  
  236.         # Set task to CPU 0 and run 2nd-init
  237.         taskset -c 0 /system/bin/2nd-init >> /data/2nd-init/log 2>&1
  238.  
  239.         echo "2nd-init completed successfully." >> /data/2nd-init/log
  240.     fi
  241. fi
  242.  
  243. # Bump log for next time
  244. echo "" >> /data/2nd-init/log
  245.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement