Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/sbin/sh
- # Reboot script for ICSSGS ROM
- # (c) 2012 by ICSSGS
- set -x
- PATH=$PATH:/tmp:/tmp/updates
- mount_part()
- {
- if ! [ $(/tmp/busybox mount | /tmp/busybox grep "/dev/block/$2 /$1 $3" | /tmp/busybox wc -l) -eq "1" ] ; then
- /tmp/busybox mkdir -p /$1
- /tmp/busybox umount -l /dev/block/$2
- if ! /tmp/busybox mount -t $3 /dev/block/$2 /$1 ; then
- echo "$1 cannot be mounted successfully."
- fi
- else
- /tmp/busybox umount -l /dev/block/$2
- if ! /tmp/busybox mount -t $3 /dev/block/$2 /$1 ; then
- echo "$1 cannot be mounted successfully."
- fi
- fi
- }
- backup_efs()
- {
- if [ -e /mnt/sdcard/backup/efs ] ; then
- /tmp/busybox mv /mnt/sdcard/backup/efs /mnt/sdcard/backup/efs-$$
- fi
- /tmp/busybox rm -rf /mnt/sdcard/backup/efs
- /tmp/busybox mkdir -p /mnt/sdcard/backup/efs
- /tmp/busybox cp -a /efs/ /mnt/sdcard/backup
- }
- restore_efs()
- {
- /tmp/busybox umount -l /efs
- /tmp/erase_image efs
- mount_part efs mtdblock4 yaffs2
- /tmp/busybox cp -a /mnt/sdcard/backup/efs /
- /tmp/busybox chmod 0755 /efs
- /tmp/busybox umount -l /efs
- }
- #check if the device is MTD or not
- if [ $(/tmp/busybox mount | /tmp/busybox grep "rfs" | /tmp/busybox wc -l) -gt "0" ] ; then
- #the device is not MTD, so a reboot will be needed
- #mount cache and clear recovery
- mount_part mnt/sdcard mmcblk0p1 vfat
- mount_part cache stl11 rfs
- if ! [ -d /cache/recovery ] ; then
- /tmp/busybox mkdir /cache/recovery
- else
- /tmp/busybox rm -rf /cache/recovery/extendedcommand
- fi
- #backup /efs
- mount_part efs stl3 rfs
- backup_efs
- /tmp/busybox rm -rf /mnt/sdcard/clockworkmod/.settings
- #reboot and restart flash
- if [ -n "$UPDATE_PACKAGE" ] ; then
- PACKAGE_LOCATION=${UPDATE_PACKAGE#/mnt}
- /tmp/busybox echo "$PACKAGE_LOCATION" > /mnt/sdcard/cyanogenmod.cfg
- fi
- /tmp/busybox sync
- /tmp/busybox reboot now
- else
- #the device is MTD, so check if it is CM7 or not
- if /tmp/busybox test `/tmp/busybox cat /sys/class/mtd/mtd2/size` != 262144000 ; then
- #the device is CM7, so a reboot will be necesary
- /tmp/busybox rm -rf /mnt/sdcard/clockworkmod/.settings
- #mount sdcard
- mount_part mnt/sdcard mmcblk0p1 vfat
- mount_part system mtdblock2 yaffs2
- /tmp/busybox rm -f /system/build.prop
- /tmp/busybox umount -l /system
- #reboot and restart flash
- if /tmp/busybox [ -n "$UPDATE_PACKAGE" ] ; then
- /tmp/busybox echo "$UPDATE_PACKAGE" > /mnt/sdcard/cyanogenmod.cfg
- fi
- /tmp/busybox sync
- /sbin/reboot now
- else
- #the device is not CM7, so cleanup and restore efs
- mount_part mnt/sdcard mmcblk0p1 vfat
- #prevent the device from looping
- /tmp/busybox rm -rf /mnt/sdcard/cyanogenmod.cfg
- #restore /efs
- restore_efs
- fi
- fi
- /tmp/busybox umount -l /mnt/sdcard
Add Comment
Please, Sign In to add comment