Guest User

Untitled

a guest
Jun 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.71 KB | None | 0 0
  1. #!/sbin/sh
  2. # Reboot script for ICSSGS ROM
  3. # (c) 2012 by ICSSGS
  4.  
  5. set -x
  6. PATH=$PATH:/tmp:/tmp/updates
  7.  
  8. mount_part()
  9. {
  10.     if ! [ $(/tmp/busybox mount | /tmp/busybox grep "/dev/block/$2 /$1 $3" | /tmp/busybox wc -l) -eq "1" ] ; then
  11.         /tmp/busybox mkdir -p /$1
  12.         /tmp/busybox umount -l /dev/block/$2
  13.         if ! /tmp/busybox mount -t $3 /dev/block/$2 /$1 ; then
  14.             echo "$1 cannot be mounted successfully."
  15.         fi
  16.     else
  17.         /tmp/busybox umount -l /dev/block/$2
  18.         if ! /tmp/busybox mount -t $3 /dev/block/$2 /$1 ; then
  19.             echo "$1 cannot be mounted successfully."
  20.         fi
  21.     fi
  22. }
  23.  
  24. backup_efs()
  25. {
  26.     if [ -e /mnt/sdcard/backup/efs ] ; then
  27.         /tmp/busybox mv /mnt/sdcard/backup/efs /mnt/sdcard/backup/efs-$$
  28.     fi
  29.     /tmp/busybox rm -rf /mnt/sdcard/backup/efs
  30.     /tmp/busybox mkdir -p /mnt/sdcard/backup/efs
  31.     /tmp/busybox cp -a /efs/ /mnt/sdcard/backup
  32. }
  33.  
  34. restore_efs()
  35. {
  36.     /tmp/busybox umount -l /efs
  37.     /tmp/erase_image efs
  38.     mount_part efs mtdblock4 yaffs2
  39.     /tmp/busybox cp -a /mnt/sdcard/backup/efs /
  40.     /tmp/busybox chmod 0755 /efs
  41.     /tmp/busybox umount -l /efs
  42. }
  43.  
  44. #check if the device is MTD or not
  45. if [ $(/tmp/busybox mount | /tmp/busybox grep "rfs" | /tmp/busybox wc -l) -gt "0" ] ; then
  46.     #the device is not MTD, so a reboot will be needed
  47.     #mount cache and clear recovery
  48.     mount_part mnt/sdcard mmcblk0p1 vfat
  49.    
  50.     mount_part cache stl11 rfs
  51.    
  52.     if ! [ -d /cache/recovery ] ; then
  53.         /tmp/busybox mkdir /cache/recovery
  54.     else
  55.         /tmp/busybox rm -rf /cache/recovery/extendedcommand
  56.     fi
  57.    
  58.     #backup /efs
  59.     mount_part efs stl3 rfs
  60.     backup_efs
  61.    
  62.     /tmp/busybox rm -rf /mnt/sdcard/clockworkmod/.settings
  63.    
  64.     #reboot and restart flash
  65.     if [ -n "$UPDATE_PACKAGE" ] ; then
  66.         PACKAGE_LOCATION=${UPDATE_PACKAGE#/mnt}
  67.         /tmp/busybox echo "$PACKAGE_LOCATION" > /mnt/sdcard/cyanogenmod.cfg
  68.     fi
  69.  
  70.     /tmp/busybox sync
  71.     /tmp/busybox reboot now
  72. else
  73.     #the device is MTD, so check if it is CM7 or not
  74.     if /tmp/busybox test `/tmp/busybox cat /sys/class/mtd/mtd2/size` != 262144000 ; then
  75.         #the device is CM7, so a reboot will be necesary
  76.        
  77.         /tmp/busybox rm -rf /mnt/sdcard/clockworkmod/.settings
  78.        
  79.         #mount sdcard
  80.         mount_part mnt/sdcard mmcblk0p1 vfat
  81.        
  82.         mount_part system mtdblock2 yaffs2
  83.         /tmp/busybox rm -f /system/build.prop
  84.         /tmp/busybox umount -l /system
  85.        
  86.         #reboot and restart flash
  87.         if /tmp/busybox [ -n "$UPDATE_PACKAGE" ] ; then
  88.         /tmp/busybox echo "$UPDATE_PACKAGE" > /mnt/sdcard/cyanogenmod.cfg
  89.         fi
  90.  
  91.         /tmp/busybox sync
  92.         /sbin/reboot now
  93.     else
  94.         #the device is not CM7, so cleanup and restore efs
  95.         mount_part mnt/sdcard mmcblk0p1 vfat
  96.         #prevent the device from looping
  97.         /tmp/busybox rm -rf /mnt/sdcard/cyanogenmod.cfg
  98.         #restore /efs
  99.         restore_efs
  100.     fi
  101. fi
  102. /tmp/busybox umount -l /mnt/sdcard
Add Comment
Please, Sign In to add comment