update_partition 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. # Compatibility issue with older Recovery notifications
  8. if [ -x /usr/local/sbin/notif ]; then
  9. alias notif_set="notif set"
  10. fi
  11. do_preinst()
  12. {
  13. notif_set 0 " 1/4 EXTRACT FIRMWARE UPDATE..^DO NOT TURN OFF THE CONSOLE"
  14. exit 0
  15. }
  16. do_postinst()
  17. {
  18. #################
  19. # Resize Rootfs #
  20. #################
  21. notif_set 0 " 2/4 RESIZE ROOT FILESYSTEM^DO NOT TURN OFF THE CONSOLE"
  22. resize2fs ${root_part}
  23. if [ $? -ne 0 ]; then
  24. notif_set 0 " CANNOT RESIZE ROOT^FILESYSTEM"
  25. exit 1
  26. fi
  27. ##############################
  28. # SHARED PARTITION PROCESSES #
  29. ##############################
  30. notif_set 0 " 3/4 COPY FILES TO USB MOUNT^DO NOT TURN OFF THE CONSOLE"
  31. # Mount Rootfs
  32. mkdir -p ${root_mount}
  33. mount -t ext4 ${root_part} ${root_mount}
  34. if [ $? -ne 0 ]; then
  35. notif_set 0 "CANNOT MOUNT ROOT^FILESYSTEM"
  36. exit 1
  37. fi
  38. # Copy OPKs
  39. cp -r ${root_mount}/usr/local/share/OPKs/* /mnt
  40. # Copy freware games and other necessary mnt files
  41. unzip -q -o ${root_mount}/usr/local/share/mnt_files.zip -d /mnt/
  42. # Fix PCE opk name if necessary
  43. #mv /mnt/Emulators/pce_mednaefn_funkey-s.opk /mnt/Emulators/pce_mednafen_funkey-s.opk 1>/dev/null 2>&1
  44. # Unmount Rootfs
  45. umount ${root_mount}
  46. if [ $? -ne 0 ]; then
  47. notif_set 0 "CANNOT UNMOUNT ROOT^FILESYSTEM"
  48. exit 1
  49. fi
  50. # Change FunKey config files extension from .cfg to .fkcfg
  51. #SAVEIFS=$IFS
  52. #IFS=$(echo -en "\n\b")
  53. #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
  54. # for FILE in $(ls /mnt/"${FOLDER}"/*.cfg 2>/dev/null); do
  55. # mv "$FILE" "${FILE%.cfg}.fkcfg"
  56. # done
  57. #done
  58. #IFS=$SAVEIFS
  59. #####################
  60. # Erase update file #
  61. #####################
  62. for file in $(ls /mnt/FunKey-*.fwu); do
  63. notif_set 0 " 4/4 ERASE UPDATE FILE^DO NOT TURN OFF THE CONSOLE"
  64. rm -f "${file}"
  65. done
  66. exit 0
  67. }
  68. echo $0 $1
  69. case "$1" in
  70. preinst)
  71. do_preinst
  72. ;;
  73. postinst)
  74. do_postinst
  75. ;;
  76. *)
  77. exit 1
  78. ;;
  79. esac