update_partition 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/sh
  2. # Update partition script
  3. source /usr/local/lib/utils
  4. root_part_num=2
  5. root_part=/dev/mmcblk0p${root_part_num}
  6. root_mount=/tmp/rootfs
  7. do_preinst()
  8. {
  9. notif " 1/4 EXTRACT FIRMWARE UPDATE..^DO NOT TURN OFF THE CONSOLE"
  10. exit 0
  11. }
  12. do_postinst()
  13. {
  14. #################
  15. # Resize Rootfs #
  16. #################
  17. notif " 2/4 RESIZE ROOT FILESYSTEM^DO NOT TURN OFF THE CONSOLE"
  18. resize2fs ${root_part}
  19. if [ $? -ne 0 ]; then
  20. notif " CANNOT RESIZE ROOT^FILESYSTEM"
  21. exit 1
  22. fi
  23. ##############################
  24. # SHARED PARTITION PROCESSES #
  25. ##############################
  26. notif " 3/4 COPY OPKS TO USB MOUNT^DO NOT TURN OFF THE CONSOLE"
  27. # Mount Rootfs
  28. mkdir -p ${root_mount}
  29. mount -t ext4 ${root_part} ${root_mount}
  30. if [ $? -ne 0 ]; then
  31. notif "CANNOT MOUNT ROOT^FILESYSTEM"
  32. exit 1
  33. fi
  34. # Copy OPKs
  35. cp -r ${root_mount}/usr/local/share/OPKs/* /mnt
  36. # Fix PCE opk name if necessary
  37. mv /mnt/Emulators/pce_mednaefn_funkey-s.opk /mnt/Emulators/pce_mednafen_funkey-s.opk 1>/dev/null 2>&1
  38. # Unmount Rootfs
  39. umount ${root_mount}
  40. if [ $? -ne 0 ]; then
  41. notif "CANNOT UNMOUNT ROOT^FILESYSTEM"
  42. exit 1
  43. fi
  44. # Change FunKey config files extension from .cfg to .fkcfg
  45. SAVEIFS=$IFS
  46. IFS=$(echo -en "\n\b")
  47. for FOLDER in "Atari lynx" "Game Boy" "Game Boy Advance" "Game Boy Color" "Game Gear" "Neo Geo Pocket" "NES" "PCE-TurboGrafx" "PS1" "Sega Genesis" "Sega Master System" "SNES" "WonderSwan"; do
  48. for FILE in $(ls /mnt/"${FOLDER}"/*.cfg 2>/dev/null); do
  49. mv "$FILE" "${FILE%.cfg}.fkcfg"
  50. done
  51. done
  52. IFS=$SAVEIFS
  53. #####################
  54. # Erase update file #
  55. #####################
  56. for file in $(ls /mnt/FunKey-*.fwu); do
  57. notif " 4/4 ERASE UPDATE FILE^DO NOT TURN OFF THE CONSOLE"
  58. rm -f "${file}"
  59. done
  60. exit 0
  61. }
  62. echo $0 $1
  63. case "$1" in
  64. preinst)
  65. do_preinst
  66. ;;
  67. postinst)
  68. do_postinst
  69. ;;
  70. *)
  71. exit 1
  72. ;;
  73. esac