Guest User

Untitled

a guest
Dec 18th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ "$1" == "" ]
  4. then
  5. echo "must specify a zip to flash"
  6. exit 0
  7. fi
  8.  
  9. adb root
  10. sleep 3
  11. filename=`echo $1 | sed 's/^.*\///'`
  12. filesize=$( stat -c %s $filename )
  13.  
  14. if [ "`adb devices | grep recovery | awk '{print $2}'`" == "recovery" ]
  15. then
  16. adb shell mount /data/
  17. fi
  18.  
  19. targetdir="/data/media/"
  20.  
  21. adb shell rm /data/media/$filename > /dev/null
  22.  
  23. echo "Pushing $filename to $targetdir/$filename"
  24. coproc ADB_PUSH ( set +m
  25. adb push $1 $targetdir/$filename 2> /dev/null || \
  26. echo "Error: failed"
  27. set -m
  28. )
  29. until [ "$ADB_PUSH_PID" = "" ];do
  30. sleep 1
  31. adb shell stat -t $targetdir/$filename | \
  32. awk '{printf "\r[ %5.1f%% ] ( %s/%s )",($2/'$filesize')*100,$2/1024,'$filesize'/1024}'
  33. done
  34. echo ""
  35.  
  36. if [ "`adb devices | grep recovery | awk '{print $2}'`" == "recovery" ]
  37. then
  38. adb shell umount /data/
  39. fi
  40.  
  41. adb shell mount -o remount,rw /cache
  42. echo "install_zip(\"/data/media/$filename\");" > /tmp/recoveryscript
  43. adb push /tmp/recoveryscript /cache/recovery/extendedcommand
  44.  
  45. echo "Done!"
  46.  
  47. echo "Rebooting into recovery to flash!"
  48. adb reboot recovery
  49.  
  50. rm /tmp/recoveryscript
Add Comment
Please, Sign In to add comment