techmik

Untitled

May 18th, 2011
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. #!/tmp/busybox sh
  2. #
  3. # Universal Updater Script for Samsung Galaxy S Phones
  4. # (c) 2011 by Teamhacksung
  5. #
  6.  
  7. set -x
  8. export PATH=/:/sbin:/system/xbin:/system/bin:/tmp:$PATH
  9.  
  10. # check if we're running on a bml or mtd device
  11. if /tmp/busybox test -e /dev/block/bml7 ; then
  12. # we're running on a bml device
  13.  
  14. # make sure sdcard is mounted
  15. if ! /tmp/busybox grep -q /mnt/sdcard /proc/mounts ; then
  16. /tmp/busybox mkdir -p /mnt/sdcard
  17. /tmp/busybox umount -l /dev/block/mmcblk0p1
  18. if ! /tmp/busybox mount -t vfat /dev/block/mmcblk0p1 /mnt/sdcard ; then
  19. /tmp/busybox echo "Cannot mount sdcard."
  20. exit 1
  21. fi
  22. fi
  23.  
  24. # remove old log
  25. rm -rf /mnt/sdcard/cyanogenmod_bml.log
  26.  
  27. # everything is logged into /sdcard/cyanogenmod.log
  28. exec >> /mnt/sdcard/cyanogenmod_bml.log 2>&1
  29.  
  30. # make sure efs is mounted
  31. if ! /tmp/busybox grep -q /efs /proc/mounts ; then
  32. /tmp/busybox mkdir -p /efs
  33. /tmp/busybox umount -l /dev/block/stl3
  34. if ! /tmp/busybox mount -t rfs /dev/block/stl3 /efs ; then
  35. /tmp/busybox echo "Cannot mount efs."
  36. exit 1
  37. fi
  38. fi
  39.  
  40. # create a backup of efs
  41. /tmp/busybox rm -rf /mnt/sdcard/backup/efs
  42. /tmp/busybox mkdir -p /mnt/sdcard/backup/efs
  43. /tmp/busybox cp -R /efs/ /mnt/sdcard/backup
  44.  
  45. # write the package path to sdcard cyanogenmod.cfg
  46. if /tmp/busybox test -n "$UPDATE_PACKAGE" ; then
  47. PACKAGE_LOCATION=${UPDATE_PACKAGE#/mnt}
  48. /tmp/busybox echo "$PACKAGE_LOCATION" > /mnt/sdcard/cyanogenmod.cfg
  49. fi
  50.  
  51. # write new kernel to boot partition
  52. /tmp/flash_image boot /tmp/boot.img
  53.  
  54. /sbin/reboot now
  55. exit 0
  56.  
  57. elif /tmp/busybox test -e /dev/block/mtdblock0 ; then
  58. # we're running on a mtd device
  59.  
  60. # make sure sdcard is mounted
  61. /tmp/busybox mkdir -p /sdcard
  62.  
  63. if ! /tmp/busybox grep -q /sdcard /proc/mounts ; then
  64. /tmp/busybox umount -l /dev/block/mmcblk0p1
  65. if ! /tmp/busybox mount -t vfat /dev/block/mmcblk0p1 /sdcard ; then
  66. /tmp/busybox echo "Cannot mount sdcard."
  67. exit 1
  68. fi
  69. fi
  70.  
  71. # remove old log
  72. rm -rf /sdcard/cyanogenmod_mtd.log
  73.  
  74. # everything is logged into /sdcard/cyanogenmod.log
  75. exec >> /sdcard/cyanogenmod_mtd.log 2>&1
  76.  
  77. # if a cyanogenmod.cfg exists, then this is a first time install
  78. # let's format the volumes and restore radio and efs
  79. if ! /tmp/busybox test -e /sdcard/cyanogenmod.cfg ; then
  80. exit 1
  81. fi
  82. # remove the cyanogenmod.cfg to prevent this from looping
  83. /tmp/busybox rm -f /sdcard/cyanogenmod.cfg
  84.  
  85. # unmount, format and mount system
  86. /tmp/busybox umount -l /system
  87. /tmp/erase_image system
  88. /tmp/busybox mount -t yaffs2 /dev/block/mtdblock2 /system
  89.  
  90. # unmount and format cache
  91. /tmp/busybox umount -l /cache
  92. /tmp/erase_image cache
  93.  
  94. # unmount and format data
  95. tmp/make_ext4fs -b 4096 -g 32768 -i 8192 -I 256 -a /data /dev/block/mmcblk0p2
  96.  
  97. # unmount and format datadata
  98. /tmp/busybox umount -l /datadata
  99. /tmp/erase_image datadata
  100.  
  101. # flash radio image
  102. /tmp/erase_image radio
  103. /tmp/flash_image radio /tmp/modem.bin
  104.  
  105. # restore efs backup
  106. if /tmp/busybox test -e /sdcard/backup/efs/nv_data.bin ; then
  107. /tmp/busybox umount -l /efs
  108. /tmp/erase_image efs
  109. /tmp/busybox mkdir -p /efs
  110.  
  111. if ! /tmp/busybox grep -q /efs /proc/mounts ; then
  112. if ! /tmp/busybox mount -t yaffs2 /dev/block/mtdblock4 /efs ; then
  113. /tmp/busybox echo "Cannot mount efs."
  114. exit 1
  115. fi
  116. fi
  117.  
  118. /tmp/busybox cp -R /sdcard/backup/efs /
  119. /tmp/busybox umount -l /efs
  120. else
  121. /tmp/busybox echo "Cannot restore efs."
  122. fi
  123.  
  124. # flash boot image
  125. /tmp/bml_over_mtd.sh boot 72 reservoir 2004 /tmp/boot.img
  126.  
  127. exit 0
  128. fi
Advertisement
Add Comment
Please, Sign In to add comment