chris41g

Nandroid Restore Script

May 27th, 2011
527
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.37 KB | None | 0 0
  1. #!/sbin/sh -x
  2. #
  3. # This program is free software; you can redistribute it and/or modify it
  4. # under the terms of the GNU Library General Public License as published
  5. # by the Free Software Foundation; either version 2, or (at your option)
  6. # any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. # GNU General Public License for more details.
  12. #
  13. # License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
  14. #
  15. BB=/sbin/busybox;
  16. UN=/sbin/unyaffs;
  17. SYS=/system;
  18. CHE=/cache;
  19. DATA=/data;
  20. ANDSEC=/sdcard/.android_secure;
  21. DATE=`date +.%m.%d.%Y.%I:%M`;
  22. BU=/sdcard/clockworkmod/backup/$DATE;
  23. OUTFD=$(ps | grep -v "grep" | grep -o -E "update_binary(.*)" | cut -d " " -f 3);
  24. ui_print() {
  25.   if [ $OUTFD != "" ]; then
  26.     echo "ui_print ${1} " 1>&$OUTFD;
  27.     echo "ui_print " 1>&$OUTFD;
  28.   else
  29.     echo "${1}";
  30.   fi;
  31. }
  32. $BB mount /dev/block/stl10 /data;
  33. $BB mount /dev/block/mmcblk0p1 /sdcard;
  34. #exec > /sdcard/restore.log 2>&1
  35. ui_print "Checking MD5";
  36. cd $BU && $BB md5sum -c nandroid.md5 || ui_print "md5 Error" || exit;
  37. if [ -r $BU/boot.img ]; then
  38.     ui_print "Flashing Boot Image";
  39.     /sbin/flash_image boot $BU/boot.img;
  40. fi;
  41. if [ -r $BU/recovery.img ]; then
  42.     ui_print "Flashing Recovery Image";
  43.     /sbin/flash_image recovery $BU/recovery.img;
  44. fi;
  45. if [ -r $BU/system.img ]; then
  46.     ui_print "Restoring System";
  47.     $BB rm -Rf $SYS/*;
  48.     cd $SYS;
  49.     $UN $BU/system.img;
  50. fi;
  51. if [ -r $BU/data.img ]; then
  52.     ui_print "Restoring User Data";
  53.     $BB rm -Rf $DATA/*;
  54.     cd $DATA;
  55.     $UN $BU/data.img;
  56. fi;
  57. if [ -r $BU/cache.img ]; then
  58.     ui_print "Restoring Cache";
  59.     $BB rm -Rf $CHE/*;
  60.     cd $CHE;
  61.     $UN $BU/cache.img;
  62. fi;
  63. if [ -r $BU/.android_secure.img ]; then
  64.     ui_print "Restoring .android_secure";
  65.     $BB rm -Rf $ANDSEC/*;
  66.     cd $ANDSEC;
  67.     $UN $BU/.android_secure.img;
  68. fi;
  69. $BB test -d /data/dalvik-cache && ui_print "Clearing Dalvik-Cache" && $BB rm -rf /data/dalvik-cache;
  70. $BB test -d /cache/dalvik-cache && ui_print "Clearing Dalvik-Cache" && $BB rm -rf /cache/dalvik-cache;
  71. $BB test -d /data/tombstones/ && ui_print "Clearing Tombstones" && $BB rm -rf /data/tombstones/*;
  72. $BB test -d /data/lost+found && ui_print "Clearing Lost+Found" && $BB rm -rf /data/lost+found/*;
  73. ui_print "Fixing Permissions";
  74. /sbin/fix_permissions;
Advertisement
Add Comment
Please, Sign In to add comment