2020-10-25 21:04:47 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Update partition script
|
|
|
|
|
|
|
|
source /usr/local/lib/utils
|
|
|
|
|
|
|
|
root_part_num=2
|
|
|
|
root_part=/dev/mmcblk0p${root_part_num}
|
|
|
|
root_mount=/tmp/rootfs
|
|
|
|
|
2021-06-07 21:54:31 +01:00
|
|
|
# Compatibility issue with older Recovery notifications
|
|
|
|
if [ -x /usr/local/sbin/notif ]; then
|
|
|
|
alias notif_set="notif set"
|
|
|
|
fi
|
|
|
|
|
2020-10-25 21:04:47 +00:00
|
|
|
do_preinst()
|
|
|
|
{
|
2021-06-07 21:54:31 +01:00
|
|
|
notif_set 0 " 1/4 EXTRACT FIRMWARE UPDATE..^DO NOT TURN OFF THE CONSOLE"
|
2020-10-25 21:04:47 +00:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
do_postinst()
|
|
|
|
{
|
2021-04-12 19:39:24 +01:00
|
|
|
|
2021-03-11 23:12:17 +00:00
|
|
|
#################
|
|
|
|
# Resize Rootfs #
|
|
|
|
#################
|
2021-06-07 21:54:31 +01:00
|
|
|
notif_set 0 " 2/4 RESIZE ROOT FILESYSTEM^DO NOT TURN OFF THE CONSOLE"
|
2020-10-31 23:49:56 +00:00
|
|
|
resize2fs ${root_part}
|
2020-10-25 21:04:47 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2021-06-07 21:54:31 +01:00
|
|
|
notif_set 0 " CANNOT RESIZE ROOT^FILESYSTEM"
|
|
|
|
exit 1
|
2020-11-12 21:30:23 +00:00
|
|
|
fi
|
2021-03-11 23:12:17 +00:00
|
|
|
|
2021-04-12 19:39:24 +01:00
|
|
|
##############################
|
|
|
|
# SHARED PARTITION PROCESSES #
|
|
|
|
##############################
|
2021-06-25 00:23:38 +01:00
|
|
|
notif_set 0 " 3/4 COPY FILES TO USB MOUNT^DO NOT TURN OFF THE CONSOLE"
|
2021-03-11 23:12:17 +00:00
|
|
|
|
|
|
|
# Mount Rootfs
|
2021-03-02 09:25:05 +00:00
|
|
|
mkdir -p ${root_mount}
|
|
|
|
mount -t ext4 ${root_part} ${root_mount}
|
|
|
|
if [ $? -ne 0 ]; then
|
2021-06-07 21:54:31 +01:00
|
|
|
notif_set 0 "CANNOT MOUNT ROOT^FILESYSTEM"
|
|
|
|
exit 1
|
2021-03-02 09:25:05 +00:00
|
|
|
fi
|
2021-03-11 23:12:17 +00:00
|
|
|
|
|
|
|
# Copy OPKs
|
2021-04-12 19:39:24 +01:00
|
|
|
cp -r ${root_mount}/usr/local/share/OPKs/* /mnt
|
2021-03-11 23:12:17 +00:00
|
|
|
|
2021-06-25 00:23:38 +01:00
|
|
|
# Copy freware games and other necessary mnt files
|
|
|
|
unzip -q -o ${root_mount}/usr/local/share/mnt_files.zip -d /mnt/
|
|
|
|
|
2021-04-05 09:33:33 +01:00
|
|
|
# Fix PCE opk name if necessary
|
2021-06-25 00:23:38 +01:00
|
|
|
#mv /mnt/Emulators/pce_mednaefn_funkey-s.opk /mnt/Emulators/pce_mednafen_funkey-s.opk 1>/dev/null 2>&1
|
2021-04-05 09:33:33 +01:00
|
|
|
|
2021-03-11 23:12:17 +00:00
|
|
|
# Unmount Rootfs
|
2021-03-02 09:25:05 +00:00
|
|
|
umount ${root_mount}
|
|
|
|
if [ $? -ne 0 ]; then
|
2021-06-07 21:54:31 +01:00
|
|
|
notif_set 0 "CANNOT UNMOUNT ROOT^FILESYSTEM"
|
|
|
|
exit 1
|
2020-12-12 18:24:32 +00:00
|
|
|
fi
|
2021-03-11 23:12:17 +00:00
|
|
|
|
2021-04-12 19:39:24 +01:00
|
|
|
# Change FunKey config files extension from .cfg to .fkcfg
|
2021-06-25 00:23:38 +01:00
|
|
|
#SAVEIFS=$IFS
|
|
|
|
#IFS=$(echo -en "\n\b")
|
|
|
|
#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
|
|
|
|
# for FILE in $(ls /mnt/"${FOLDER}"/*.cfg 2>/dev/null); do
|
|
|
|
# mv "$FILE" "${FILE%.cfg}.fkcfg"
|
|
|
|
# done
|
|
|
|
#done
|
|
|
|
#IFS=$SAVEIFS
|
2021-04-12 19:39:24 +01:00
|
|
|
|
2021-03-11 23:12:17 +00:00
|
|
|
#####################
|
|
|
|
# Erase update file #
|
|
|
|
#####################
|
2020-11-16 09:10:47 +00:00
|
|
|
for file in $(ls /mnt/FunKey-*.fwu); do
|
2021-06-07 21:54:31 +01:00
|
|
|
notif_set 0 " 4/4 ERASE UPDATE FILE^DO NOT TURN OFF THE CONSOLE"
|
|
|
|
rm -f "${file}"
|
2020-10-31 23:49:56 +00:00
|
|
|
done
|
2020-10-25 21:04:47 +00:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $0 $1
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
preinst)
|
|
|
|
do_preinst
|
|
|
|
;;
|
|
|
|
postinst)
|
|
|
|
do_postinst
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|