Fixed handling of spaces in paths

This commit is contained in:
CosmicScale 2024-12-16 16:05:42 +00:00
parent 5a67e6015b
commit 60c73a13b7
2 changed files with 204 additions and 204 deletions

View File

@ -3,14 +3,14 @@
echo -e "\e[8;40;100t"
# Set paths
TOOLKIT_PATH=$(pwd)
TOOLKIT_PATH=$"(pwd)"
ASSETS_DIR="${TOOLKIT_PATH}/assets"
INSTALL_LOG="${TOOLKIT_PATH}/PSBBN-installer.log"
clear
echo "####################################################################">> ${INSTALL_LOG};
date >> ${INSTALL_LOG}
echo "####################################################################">> "${INSTALL_LOG}";
date >> "${INSTALL_LOG}"
# Choose the PS2 storage device
while true; do
@ -24,21 +24,21 @@ while true; do
echo " ";
echo " Written by CosmicScale"
echo
echo | tee -a ${INSTALL_LOG}
lsblk -p -o MODEL,NAME,SIZE,LABEL,MOUNTPOINT | tee -a ${INSTALL_LOG}
echo | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
lsblk -p -o MODEL,NAME,SIZE,LABEL,MOUNTPOINT | tee -a "${INSTALL_LOG}"
echo | tee -a "${INSTALL_LOG}"
read -p "Choose your PS2 HDD from the list above (e.g., /dev/sdx): " DEVICE
# Validate input
if [[ $DEVICE =~ ^/dev/sd[a-z]$ ]]; then
echo
echo -e "Are you sure you want to write to ${DEVICE}?" | tee -a ${INSTALL_LOG}
echo -e "Are you sure you want to write to ${DEVICE}?" | tee -a "${INSTALL_LOG}"
read -p "This will erase all data on the drive. (yes/no): " CONFIRM
if [[ $CONFIRM == "yes" ]]; then
break
else
echo "Aborted." | tee -a ${INSTALL_LOG}
echo "Aborted." | tee -a "${INSTALL_LOG}"
read -p "Press any key to exit..."
exit 1
fi
@ -49,14 +49,14 @@ done
mounted_volumes=$(lsblk -ln -o MOUNTPOINT "$DEVICE" | grep -v "^$")
# Iterate through each mounted volume and unmount it
echo | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "Unmounting volumes associated with $DEVICE..."
for mount_point in $mounted_volumes; do
echo "Unmounting $mount_point..." | tee -a ${INSTALL_LOG}
echo "Unmounting $mount_point..." | tee -a "${INSTALL_LOG}"
if sudo umount "$mount_point"; then
echo "Successfully unmounted $mount_point." | tee -a ${INSTALL_LOG}
echo "Successfully unmounted $mount_point." | tee -a "${INSTALL_LOG}"
else
echo "Failed to unmount $mount_point. Please unmount manually." | tee -a ${INSTALL_LOG}
echo "Failed to unmount $mount_point. Please unmount manually." | tee -a "${INSTALL_LOG}"
read -p "Press any key to exit..."
exit 1
fi
@ -66,12 +66,12 @@ echo "All volumes unmounted for $DEVICE."
# URL of the webpage
URL="https://archive.org/download/psbbn-definitive-english-patch-v2"
echo | tee -a ${INSTALL_LOG}
echo "Checking for latest version of the PSBBN Definitive English patch..." | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "Checking for latest version of the PSBBN Definitive English patch..." | tee -a "${INSTALL_LOG}"
# Download the HTML of the page
HTML_FILE=$(mktemp)
wget -O "$HTML_FILE" "$URL" >> ${INSTALL_LOG} 2>&1
wget -O "$HTML_FILE" "$URL" >> "${INSTALL_LOG}" 2>&1
# Extract .gz links and dates into a combined list
COMBINED_LIST=$(grep -oP '(?<=<td><a href=")[^"]+\.gz' "$HTML_FILE" | \
@ -84,14 +84,14 @@ LATEST=$(echo "$COMBINED_LIST" | sort -r | head -n 1 | cut -d' ' -f2)
if [ -z "$LATEST" ]; then
echo "Cound not find latest version."
# If $LATEST is empty, check for psbbn-definitive-image*.gz file
IMAGE_FILE=$(ls ${ASSETS_DIR}/psbbn-definitive-image*.gz 2>/dev/null)
IMAGE_FILE=$(ls "${ASSETS_DIR}"/psbbn-definitive-image*.gz 2>/dev/null)
if [ -n "$IMAGE_FILE" ]; then
# If image file exists, set LATEST to the image file name
LATEST=$(basename "$IMAGE_FILE")
echo "Found local file: ${LATEST}" | tee -a ${INSTALL_LOG}
echo "Found local file: ${LATEST}" | tee -a "${INSTALL_LOG}"
else
rm "$HTML_FILE"
echo "Failed to download PSBBN image file. Aborting." | tee -a ${INSTALL_LOG}
echo "Failed to download PSBBN image file. Aborting." | tee -a "${INSTALL_LOG}"
read -p "Press any key to exit..."
exit 1
fi
@ -102,27 +102,27 @@ fi
# Check for and delete older 'psbbn-definitive-image*.gz' files
for file in "${ASSETS_DIR}"/psbbn-definitive-image*.gz; do
if [[ -f "$file" && "$(basename "$file")" != "$LATEST" ]]; then
echo "Deleting old file: $file" | tee -a ${INSTALL_LOG}
echo "Deleting old file: $file" | tee -a "${INSTALL_LOG}"
rm "$file"
fi
done
# Check if the file exists in ${ASSETS_DIR}
if [[ -f "${ASSETS_DIR}/${LATEST}" && ! -f "${ASSETS_DIR}/${LATEST}.st" ]]; then
echo "File ${LATEST} already exists in ${ASSETS_DIR}. Skipping download." | tee -a ${INSTALL_LOG}
echo "File ${LATEST} already exists in ${ASSETS_DIR}. Skipping download." | tee -a "${INSTALL_LOG}"
else
# Construct the full URL for the .gz file and download it
ZIP_URL="$URL/$LATEST"
# Proceed with download
echo "Downloading ${LATEST}..." | tee -a ${INSTALL_LOG}
echo "Downloading ${LATEST}..." | tee -a "${INSTALL_LOG}"
axel -n 8 -a "$ZIP_URL" -o "${ASSETS_DIR}"
# Check if the file was downloaded successfully
if [[ -f "${ASSETS_DIR}/${LATEST}" && ! -f "${ASSETS_DIR}/${LATEST}.st" ]]; then
echo "Download completed: ${LATEST}" | tee -a ${INSTALL_LOG}
echo "Download completed: ${LATEST}" | tee -a "${INSTALL_LOG}"
else
rm "$HTML_FILE"
echo "Download failed for ${LATEST}. Please check your internet connection and try again." | tee -a ${INSTALL_LOG}
echo "Download failed for ${LATEST}. Please check your internet connection and try again." | tee -a "${INSTALL_LOG}"
read -p "Press any key to exit..."
exit 1
fi
@ -131,54 +131,54 @@ else
rm "$HTML_FILE"
fi
echo | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "Checking for POPS binaries..."
# Check POPS files exist
if [[ -f "${ASSETS_DIR}/POPS-binaries-main/POPS.ELF" && -f "${ASSETS_DIR}/POPS-binaries-main/IOPRP252.IMG" ]]; then
echo "Both POPS.ELF and IOPRP252.IMG exist in ${ASSETS_DIR}. Skipping download." | tee -a ${INSTALL_LOG}
echo "Both POPS.ELF and IOPRP252.IMG exist in ${ASSETS_DIR}. Skipping download." | tee -a "${INSTALL_LOG}"
else
echo "One or both files are missing in ${ASSETS_DIR}." | tee -a ${INSTALL_LOG}
echo "One or both files are missing in ${ASSETS_DIR}." | tee -a "${INSTALL_LOG}"
# Check if POPS-binaries-main.zip exists
if [[ -f "${ASSETS_DIR}/POPS-binaries-main.zip" && ! -f "${ASSETS_DIR}/POPS-binaries-main.zip.st" ]]; then
echo | tee -a ${INSTALL_LOG}
echo "POPS-binaries-main.zip found in ${ASSETS_DIR}. Extracting..." | tee -a ${INSTALL_LOG}
unzip -o ${ASSETS_DIR}/POPS-binaries-main.zip -d ${ASSETS_DIR} >> ${INSTALL_LOG} 2>&1
echo | tee -a "${INSTALL_LOG}"
echo "POPS-binaries-main.zip found in ${ASSETS_DIR}. Extracting..." | tee -a "${INSTALL_LOG}"
unzip -o "${ASSETS_DIR}/POPS-binaries-main.zip" -d "${ASSETS_DIR}" >> "${INSTALL_LOG}" 2>&1
else
echo | tee -a ${INSTALL_LOG}
echo "Downloading POPS binaries..." | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "Downloading POPS binaries..." | tee -a "${INSTALL_LOG}"
axel -a https://archive.org/download/pops-binaries-PS2/POPS-binaries-main.zip -o "${ASSETS_DIR}"
unzip -o ${ASSETS_DIR}/POPS-binaries-main.zip -d ${ASSETS_DIR} >> ${INSTALL_LOG} 2>&1
unzip -o "${ASSETS_DIR}/POPS-binaries-main.zip" -d "${ASSETS_DIR}" >> "${INSTALL_LOG}" 2>&1
fi
# Check if both POPS.ELF and IOPRP252.IMG exist after extraction
if [[ -f "${ASSETS_DIR}/POPS-binaries-main/POPS.ELF" && -f "${ASSETS_DIR}/POPS-binaries-main/IOPRP252.IMG" ]]; then
echo | tee -a ${INSTALL_LOG}
echo "POPS binaries successfully extracted." | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "POPS binaries successfully extracted." | tee -a "${INSTALL_LOG}"
else
echo | tee -a ${INSTALL_LOG}
echo "Error: One or both files (POPS.ELF, IOPRP252.IMG) are missing after extraction." | tee -a ${INSTALL_LOG}
read -p "You can install POPS manually later. Press any key to continue..." | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "Error: One or both files (POPS.ELF, IOPRP252.IMG) are missing after extraction." | tee -a "${INSTALL_LOG}"
read -p "You can install POPS manually later. Press any key to continue..." | tee -a "${INSTALL_LOG}"
fi
fi
PSBBN_IMAGE="${ASSETS_DIR}/${LATEST}"
# Write the PSBBN image
echo | tee -a ${INSTALL_LOG}
echo "Writing the PSBBN image to ${DEVICE}..." | tee -a ${INSTALL_LOG}
if gunzip -c ${PSBBN_IMAGE} | sudo dd of=${DEVICE} bs=4M status=progress 2>&1 | tee -a ${INSTALL_LOG} ; then
echo | tee -a "${INSTALL_LOG}"
echo "Writing the PSBBN image to ${DEVICE}..." | tee -a "${INSTALL_LOG}"
if gunzip -c ${PSBBN_IMAGE} | sudo dd of=${DEVICE} bs=4M status=progress 2>&1 | tee -a "${INSTALL_LOG}" ; then
sync
echo
echo "Verifying installation..."
if sudo ${TOOLKIT_PATH}/helper/HDL\ Dump.elf toc "${DEVICE}" | grep -q '__common'; then
echo "Verification successful. PSBBN image installed successfully." | tee -a ${INSTALL_LOG}
if sudo "${TOOLKIT_PATH}"/helper/HDL\ Dump.elf toc "${DEVICE}" | grep -q '__common'; then
echo "Verification successful. PSBBN image installed successfully." | tee -a "${INSTALL_LOG}"
else
echo "Error: Verification failed on ${DEVICE}." | tee -a ${INSTALL_LOG}
echo "Error: Verification failed on ${DEVICE}." | tee -a "${INSTALL_LOG}"
read -p "Press any key to exit..."
exit 1
fi
else
echo "Error: Failed to write the image to ${DEVICE}." | tee -a ${INSTALL_LOG}
echo "Error: Failed to write the image to ${DEVICE}." | tee -a "${INSTALL_LOG}"
read -p "Press any key to exit..."
exit 1
fi
@ -187,11 +187,11 @@ fi
function function_space() {
output=$(sudo ${TOOLKIT_PATH}/helper/HDL\ Dump.elf toc ${DEVICE} 2>&1)
output=$(sudo "${TOOLKIT_PATH}"/helper/HDL\ Dump.elf toc ${DEVICE} 2>&1)
# Check for the word "aborting" in the output
if echo "$output" | grep -q "aborting"; then
echo "${DEVICE}: APA partition is broken; aborting." | tee -a ${INSTALL_LOG}
echo "${DEVICE}: APA partition is broken; aborting." | tee -a "${INSTALL_LOG}"
read -p "Press any key to exit..."
exit 1
fi
@ -212,7 +212,7 @@ PP=$(((available - 18560) / 128))
# Loop until the user enters a valid number of partitions
while true; do
echo | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo " #########################################################################################"
echo " # 'OPL Launcher' partitions are used to launch games from the 'Game Channel.' #"
echo " # Consider how many games you want to install, and plan for future expansion. #"
@ -231,7 +231,7 @@ while true; do
if [[ "$PARTITION_COUNT" =~ ^[0-9]+$ ]] && [ "$PARTITION_COUNT" -ge 1 ] && [ "$PARTITION_COUNT" -le $PP ]; then
break # Exit the loop if the input is valid
else
echo "Invalid input. Please enter a number between 1 and $PP." | tee -a ${INSTALL_LOG}
echo "Invalid input. Please enter a number between 1 and $PP." | tee -a "${INSTALL_LOG}"
fi
done
@ -239,24 +239,24 @@ GB=$(((available + 2048 - 10368 - (PARTITION_COUNT * 128)) / 1024))
# Prompt user for partition size for music, validate input, and keep asking until valid input is provided
while true; do
echo | tee -a ${INSTALL_LOG}
echo "What size would you like the \"Music\" partition to be?" | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "What size would you like the \"Music\" partition to be?" | tee -a "${INSTALL_LOG}"
echo "Remaining space will be allocated to the __.POPS partition for PS1 games"
echo "Minimum 10 GB, Available space: $GB GB" | tee -a ${INSTALL_LOG}
echo "Minimum 10 GB, Available space: $GB GB" | tee -a "${INSTALL_LOG}"
read -p "Enter partition size (in GB): " gb_size
# Check if the input is a valid number
if [[ ! "$gb_size" =~ ^[0-9]+$ ]]; then
echo "Invalid input. Please enter a valid number." | tee -a ${INSTALL_LOG}
echo "Invalid input. Please enter a valid number." | tee -a "${INSTALL_LOG}"
continue
fi
# Check if the value is within the valid range
if (( gb_size >= 10 && gb_size <= GB )); then
echo "Valid partition size: $gb_size GB" | tee -a ${INSTALL_LOG}
echo "Valid partition size: $gb_size GB" | tee -a "${INSTALL_LOG}"
break # Exit the loop if the input is valid
else
echo "Invalid size. Please enter a value between 10 and $GB GB." | tee -a ${INSTALL_LOG}
echo "Invalid size. Please enter a value between 10 and $GB GB." | tee -a "${INSTALL_LOG}"
fi
done
@ -264,21 +264,21 @@ music_partition=$((gb_size * 1024 - 2048))
pops_partition=$((available - (PARTITION_COUNT * 128) - music_partition -128))
GB=$((pops_partition / 1024))
echo | tee -a ${INSTALL_LOG}
echo "$GB GB alocated for __.POPS partition." | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "$GB GB alocated for __.POPS partition." | tee -a "${INSTALL_LOG}"
COMMANDS="device ${DEVICE}\n"
COMMANDS+="mkpart __linux.8 ${music_partition}M REISER\n"
COMMANDS+="mkpart __.POPS ${pops_partition}M PFS\n"
COMMANDS+="mkpart +OPL 128M PFS\nexit"
echo -e "$COMMANDS" | sudo "${TOOLKIT_PATH}/helper/PFS Shell.elf" >> ${INSTALL_LOG} 2>&1
echo -e "$COMMANDS" | sudo "${TOOLKIT_PATH}/helper/PFS Shell.elf" >> "${INSTALL_LOG}" 2>&1
# Call the function to retrieve available space
function_space
echo | tee -a ${INSTALL_LOG}
echo "Creating $PARTITION_COUNT \"OPL Launcher\" partitions..." | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "Creating $PARTITION_COUNT \"OPL Launcher\" partitions..." | tee -a "${INSTALL_LOG}"
# Set starting partition number
START_PARTITION_NUMBER=1
@ -290,8 +290,8 @@ successful_count=0
for ((i = 0; i < PARTITION_COUNT; i++)); do
# Check if available space is at least 128 MB
if [ "$available" -lt 128 ]; then
echo | tee -a ${INSTALL_LOG}
echo "Insufficient space for another partition." | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "Insufficient space for another partition." | tee -a "${INSTALL_LOG}"
break
fi
@ -305,7 +305,7 @@ for ((i = 0; i < PARTITION_COUNT; i++)); do
COMMAND="device ${DEVICE}\nmkpart ${PARTITION_LABEL} 128M PFS\nexit"
# Run the partition creation command in PFS Shell
echo -e "$COMMAND" | sudo "${TOOLKIT_PATH}/helper/PFS Shell.elf" >> ${INSTALL_LOG} 2>&1
echo -e "$COMMAND" | sudo "${TOOLKIT_PATH}/helper/PFS Shell.elf" >> "${INSTALL_LOG}" 2>&1
# Increment the count of successfully created partitions
((successful_count++))
@ -315,22 +315,22 @@ for ((i = 0; i < PARTITION_COUNT; i++)); do
done
# Display the total number of partitions created successfully
echo | tee -a ${INSTALL_LOG}
echo "$successful_count \"OPL Launcher\" partitions created successfully." | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "$successful_count \"OPL Launcher\" partitions created successfully." | tee -a "${INSTALL_LOG}"
echo | tee -a ${INSTALL_LOG}
echo "Modifying partition headers..." | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "Modifying partition headers..." | tee -a "${INSTALL_LOG}"
cd "${TOOLKIT_PATH}/assets/"
# After partitions are created, modify the header for each partition
for ((i = START_PARTITION_NUMBER; i < START_PARTITION_NUMBER + PARTITION_COUNT; i++)); do
PARTITION_LABEL=$(printf "PP.%03d" "$i")
sudo "${TOOLKIT_PATH}/helper/HDL Dump.elf" modify_header "${DEVICE}" "${PARTITION_LABEL}" >> ${INSTALL_LOG} 2>&1
sudo "${TOOLKIT_PATH}/helper/HDL Dump.elf" modify_header "${DEVICE}" "${PARTITION_LABEL}" >> "${INSTALL_LOG}" 2>&1
done
echo | tee -a ${INSTALL_LOG}
echo "Making \"res\" folders..." | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "Making \"res\" folders..." | tee -a "${INSTALL_LOG}"
# make 'res' directory on all PP partitions
COMMANDS="device ${DEVICE}\n"
@ -343,10 +343,10 @@ done
COMMANDS+="exit"
# Pipe all commands to PFS Shell for mounting, copying, and unmounting
echo -e "$COMMANDS" | sudo "${TOOLKIT_PATH}/helper/PFS Shell.elf" >> ${INSTALL_LOG} 2>&1
echo -e "$COMMANDS" | sudo "${TOOLKIT_PATH}/helper/PFS Shell.elf" >> "${INSTALL_LOG}" 2>&1
echo | tee -a ${INSTALL_LOG}
echo "Installing POPS and OPL..." | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "Installing POPS and OPL..." | tee -a "${INSTALL_LOG}"
# Copy POPS files and OPL to relevent partitions
COMMANDS="device ${DEVICE}\n"
@ -367,7 +367,7 @@ COMMANDS+="umount\n"
COMMANDS+="exit"
# Pipe all commands to PFS Shell for mounting, copying, and unmounting
echo -e "$COMMANDS" | sudo "${TOOLKIT_PATH}/helper/PFS Shell.elf" >> ${INSTALL_LOG} 2>&1
echo -e "$COMMANDS" | sudo "${TOOLKIT_PATH}/helper/PFS Shell.elf" >> "${INSTALL_LOG}" 2>&1
cd "${TOOLKIT_PATH}"
@ -377,7 +377,7 @@ cd "${TOOLKIT_PATH}"
function function_disk_size_check() {
LBA_MAX=$(sudo blockdev --getsize ${DEVICE})
if [ ${LBA_MAX} -gt 4294967296 ]; then
echo -e "ERROR: Disk size exceeding 2TiB. Formatting aborted." | tee -a ${INSTALL_LOG}
echo -e "ERROR: Disk size exceeding 2TiB. Formatting aborted." | tee -a "${INSTALL_LOG}"
function_exit
fi
}
@ -385,7 +385,7 @@ function function_disk_size_check() {
function function_apajail_magic_number() {
echo ${MAGIC_NUMBER} | xxd -r -p > /tmp/apajail_magic_number.bin
sudo dd if=/tmp/apajail_magic_number.bin of=${DEVICE} bs=8 count=1 seek=28 conv=notrunc >> ${INSTALL_LOG} 2>&1
sudo dd if=/tmp/apajail_magic_number.bin of=${DEVICE} bs=8 count=1 seek=28 conv=notrunc >> "${INSTALL_LOG}" 2>&1
}
function function_make_ps2_dirs() {
@ -411,9 +411,9 @@ function function_make_ps2_dirs() {
}
function function_apa_checksum_fix() {
sudo dd if=${DEVICE} of=/tmp/apa_header_full.bin bs=512 count=2 >> ${INSTALL_LOG} 2>&1
sudo dd if=${DEVICE} of=/tmp/apa_header_full.bin bs=512 count=2 >> "${INSTALL_LOG}" 2>&1
"${TOOLKIT_PATH}/helper/PS2 APA Header Checksum Fixer.elf" /tmp/apa_header_full.bin | sed -n 8p | awk '{print $6}' | xxd -r -p > /tmp/apa_header_checksum.bin
sudo dd if=/tmp/apa_header_checksum.bin of=${DEVICE} conv=notrunc >> ${INSTALL_LOG} 2>&1
sudo dd if=/tmp/apa_header_checksum.bin of=${DEVICE} conv=notrunc >> "${INSTALL_LOG}" 2>&1
}
function function_clear_temp() {
@ -429,8 +429,8 @@ function function_clear_temp() {
sudo rm /tmp/gpt_2nd.xz &> /dev/null
}
echo | tee -a ${INSTALL_LOG}
echo "Running APA-Jail by Berion..." | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
echo "Running APA-Jail by Berion..." | tee -a "${INSTALL_LOG}"
# Hashed out for testing. Larger drive support most likley possible when using a restored disc image from a smaller drive
# function_disk_size_check
@ -451,28 +451,28 @@ if [ "$(echo ${DEVICE} | grep -o /dev/loop)" = "/dev/loop" ]; then
sudo mkfs.ext2 -L "RECOVERY" ${DEVICE}2
sudo mkfs.exfat -c 32K -L "OPL" ${DEVICE}3
fi
} >> ${INSTALL_LOG} 2>&1
} >> "${INSTALL_LOG}" 2>&1
PARTITION_NUMBER=3
function_make_ps2_dirs
# Finalising recovery:
if [ ! -d "${TOOLKIT_PATH}/storage/hdd/recovery" ]; then
mkdir -p ${TOOLKIT_PATH}/storage/hdd/recovery
mkdir -p "${TOOLKIT_PATH}/storage/hdd/recovery"
fi
if [ "$(echo ${DEVICE} | grep -o /dev/loop)" = "/dev/loop" ]; then
sudo mount ${DEVICE}p2 ${TOOLKIT_PATH}/storage/hdd/recovery
else sudo mount ${DEVICE}2 ${TOOLKIT_PATH}/storage/hdd/recovery
sudo mount ${DEVICE}p2 "${TOOLKIT_PATH}/storage/hdd/recovery"
else sudo mount ${DEVICE}2 "${TOOLKIT_PATH}/storage/hdd/recovery"
fi
sudo dd if=${DEVICE} bs=128M count=1 status=noxfer 2>> ${INSTALL_LOG} | xz -z > /tmp/apa_index.xz 2>> ${INSTALL_LOG}
sudo cp /tmp/apa_index.xz ${TOOLKIT_PATH}/storage/hdd/recovery
sudo dd if=${DEVICE} bs=128M count=1 status=noxfer 2>> "${INSTALL_LOG}" | xz -z > /tmp/apa_index.xz 2>> "${INSTALL_LOG}"
sudo cp /tmp/apa_index.xz "${TOOLKIT_PATH}/storage/hdd/recovery"
LBA_MAX=$(sudo blockdev --getsize ${DEVICE})
LBA_GPT_BUP=$(echo $(($LBA_MAX-33)))
sudo dd if=${DEVICE} skip=${LBA_GPT_BUP} bs=512 count=33 status=noxfer 2>> ${INSTALL_LOG} | xz -z > /tmp/gpt_2nd.xz 2>> ${INSTALL_LOG}
sudo cp /tmp/gpt_2nd.xz ${TOOLKIT_PATH}/storage/hdd/recovery
sudo dd if=${DEVICE} skip=${LBA_GPT_BUP} bs=512 count=33 status=noxfer 2>> "${INSTALL_LOG}" | xz -z > /tmp/gpt_2nd.xz 2>> "${INSTALL_LOG}"
sudo cp /tmp/gpt_2nd.xz "${TOOLKIT_PATH}/storage/hdd/recovery"
sync
sudo umount -l ${TOOLKIT_PATH}/storage/hdd/recovery
rmdir ${TOOLKIT_PATH}/storage/hdd/recovery
sudo umount -l "${TOOLKIT_PATH}/storage/hdd/recovery"
rmdir "${TOOLKIT_PATH}/storage/hdd/recovery"
function_apa_checksum_fix
@ -488,32 +488,32 @@ unset PARTITION_NUMBER
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# Run the command and capture output
output=$(sudo ${TOOLKIT_PATH}/helper/HDL\ Dump.elf toc ${DEVICE} 2>&1)
output=$(sudo "${TOOLKIT_PATH}"/helper/HDL\ Dump.elf toc ${DEVICE} 2>&1)
# Check for the word "aborting" in the output
if echo "$output" | grep -q "aborting"; then
echo "Error: APA partition is broken on ${DEVICE}. Install failed." | tee -a ${INSTALL_LOG}
echo "Error: APA partition is broken on ${DEVICE}. Install failed." | tee -a "${INSTALL_LOG}"
read -p "Press any key to exit..."
exit 1
fi
if sudo ${TOOLKIT_PATH}/helper/HDL\ Dump.elf toc "${DEVICE}" | grep -q '__.POPS' && \
sudo ${TOOLKIT_PATH}/helper/HDL\ Dump.elf toc "${DEVICE}" | grep -q '__linux.8' && \
sudo ${TOOLKIT_PATH}/helper/HDL\ Dump.elf toc "${DEVICE}" | grep -q "PP.${PARTITION_COUNT}" && \
sudo ${TOOLKIT_PATH}/helper/HDL\ Dump.elf toc "${DEVICE}" | grep -q '+OPL'; then
echo "All partitions were created successfully." | tee -a ${INSTALL_LOG}
if sudo "${TOOLKIT_PATH}"/helper/HDL\ Dump.elf toc "${DEVICE}" | grep -q '__.POPS' && \
sudo "${TOOLKIT_PATH}"/helper/HDL\ Dump.elf toc "${DEVICE}" | grep -q '__linux.8' && \
sudo "${TOOLKIT_PATH}"/helper/HDL\ Dump.elf toc "${DEVICE}" | grep -q "PP.${PARTITION_COUNT}" && \
sudo "${TOOLKIT_PATH}"/helper/HDL\ Dump.elf toc "${DEVICE}" | grep -q '+OPL'; then
echo "All partitions were created successfully." | tee -a "${INSTALL_LOG}"
else
echo "Error: Some partitions are missing on ${DEVICE}." | tee -a ${INSTALL_LOG}
echo "Error: Some partitions are missing on ${DEVICE}." | tee -a "${INSTALL_LOG}"
read -p "Press any key to exit..."
exit 1
fi
# Check if 'OPL' is found in the 'lsblk' output and if it matches the device
if ! lsblk -p -o NAME,LABEL | grep -q "${DEVICE}3"; then
echo "Error: APA-Jail failed on ${DEVICE}." | tee -a ${INSTALL_LOG}
echo "Error: APA-Jail failed on ${DEVICE}." | tee -a "${INSTALL_LOG}"
read -p "Press any key to exit..."
exit 1
fi
echo | tee -a ${INSTALL_LOG}
read -p "PSBBN successfully installed. Press any key to exit. " | tee -a ${INSTALL_LOG}
echo | tee -a "${INSTALL_LOG}"
read -p "PSBBN successfully installed. Press any key to exit. " | tee -a "${INSTALL_LOG}"

View File

@ -3,7 +3,7 @@
echo -e "\e[8;40;100t"
# Set paths
TOOLKIT_PATH=$(pwd)
TOOLKIT_PATH="$(pwd)"
ICONS_DIR="${TOOLKIT_PATH}/icons"
ARTWORK_DIR="${ICONS_DIR}/art"
POPSTARTER_DIR="${TOOLKIT_PATH}/assets/POPSTARTER.ELF"
@ -17,16 +17,16 @@ GAMES_PATH="${TOOLKIT_PATH}/games"
POPS_FOLDER="${GAMES_PATH}/POPS"
ALL_GAMES="${GAMES_PATH}/master.list"
cd ${TOOLKIT_PATH}
cd "${TOOLKIT_PATH}"
clear
date >> ${LOG_FILE}
date >> "${LOG_FILE}"
# Choose the PS2 storage device
while true; do
clear
echo "####################################################################">> ${LOG_FILE};
echo "####################################################################">> "${LOG_FILE}";
echo " _____ _____ _ _ _ ";
echo " | __ \ |_ _| | | | | | ";
echo " | | \/ __ _ _ __ ___ ___ | | _ __ ___| |_ __ _| | | ___ ___ ";
@ -35,16 +35,16 @@ echo " | |_\ \ (_| | | | | | | __/ _| || | | \__ \ || (_| | |
echo " \____/\__,_|_| |_| |_|\___| \___/_| |_|___/\__\__,_|_|_|\___|_| ";
echo " ";
echo " Written by CosmicScale"
echo | tee -a ${LOG_FILE}
lsblk -p -o MODEL,NAME,SIZE,LABEL,MOUNTPOINT | tee -a ${LOG_FILE}
echo | tee -a ${LOG_FILE}
echo | tee -a "${LOG_FILE}"
lsblk -p -o MODEL,NAME,SIZE,LABEL,MOUNTPOINT | tee -a "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
read -p "Choose your PS2 HDD from list above e.g. /dev/sdx): " DEVICE
# Validate input
if [[ $DEVICE =~ ^/dev/sd[a-z]$ ]]; then
echo
echo -e "Selected drive: \"${DEVICE}\"" | tee -a ${LOG_FILE}
echo -e "Selected drive: \"${DEVICE}\"" | tee -a "${LOG_FILE}"
break
fi
done
@ -71,13 +71,13 @@ echo "All volumes unmounted for $DEVICE."| tee -a ${INSTALL_LOG}
# Validate the GAMES_PATH
if [[ ! -d "$GAMES_PATH" ]]; then
echo
echo "Error: GAMES_PATH is not a valid directory: $GAMES_PATH" | tee -a ${LOG_FILE}
echo "Error: GAMES_PATH is not a valid directory: $GAMES_PATH" | tee -a "${LOG_FILE}"
read -p "Press any key to exit..."
exit 1
fi
echo | tee -a ${LOG_FILE}
echo "GAMES_PATH is valid: $GAMES_PATH" | tee -a ${LOG_FILE}
echo | tee -a "${LOG_FILE}"
echo "GAMES_PATH is valid: $GAMES_PATH" | tee -a "${LOG_FILE}"
# Check if the file exists
if [ -f "./venv/bin/activate" ]; then
@ -99,49 +99,49 @@ if [ $? -ne 0 ]; then
fi
# Create games list of PS1 and PS2 games to be installed
echo | tee -a ${LOG_FILE}
echo "Creating PS1 games list..."| tee -a ${LOG_FILE}
python3 ./helper/list-builder-ps1.py ${GAMES_PATH} | tee -a ${LOG_FILE}
echo "Creating PS2 games list..."| tee -a ${LOG_FILE}
python3 ./helper/list-builder-ps2.py ${GAMES_PATH} | tee -a ${LOG_FILE}
echo | tee -a "${LOG_FILE}"
echo "Creating PS1 games list..."| tee -a "${LOG_FILE}"
python3 ./helper/list-builder-ps1.py "${GAMES_PATH}" | tee -a "${LOG_FILE}"
echo "Creating PS2 games list..."| tee -a "${LOG_FILE}"
python3 ./helper/list-builder-ps2.py "${GAMES_PATH}" | tee -a "${LOG_FILE}"
# Deactivate the virtual environment
deactivate
# Create master list combining PS1 and PS2 games to a single list
if [[ ! -f "${GAMES_PATH}/ps1.list" && ! -f "${GAMES_PATH}/ps2.list" ]]; then
echo "No games found to install."| tee -a "${LOG_FILE}"
echo "No games found to install."| tee -a ""${LOG_FILE}""
read -p "Press any key to exit..."
exit 1
elif [[ ! -f "${GAMES_PATH}/ps1.list" ]]; then
cat "${GAMES_PATH}/ps2.list" > "${GAMES_PATH}/master.list" 2>> "${LOG_FILE}"
cat "${GAMES_PATH}/ps2.list" > "${GAMES_PATH}/master.list" 2>> ""${LOG_FILE}""
else
cat "${GAMES_PATH}/ps1.list" > "${GAMES_PATH}/master.list" 2>> "${LOG_FILE}"
cat "${GAMES_PATH}/ps2.list" >> "${GAMES_PATH}/master.list" 2>> "${LOG_FILE}"
cat "${GAMES_PATH}/ps1.list" > "${GAMES_PATH}/master.list" 2>> ""${LOG_FILE}""
cat "${GAMES_PATH}/ps2.list" >> "${GAMES_PATH}/master.list" 2>> ""${LOG_FILE}""
fi
echo | tee -a ${LOG_FILE}
echo "Games list successfully created"| tee -a ${LOG_FILE}
echo | tee -a "${LOG_FILE}"
echo "Games list successfully created"| tee -a "${LOG_FILE}"
# Count the number of games to be installed
count=$(grep -c '^[^[:space:]]' ${ALL_GAMES})
echo "Number of games to install: $count" | tee -a ${LOG_FILE}
count=$(grep -c '^[^[:space:]]' "${ALL_GAMES}")
echo "Number of games to install: $count" | tee -a "${LOG_FILE}"
# Count the number of 'OPL Launcher' partitions available
partition_count=$(sudo ${TOOLKIT_PATH}/helper/HDL\ Dump.elf toc $DEVICE | grep -o 'PP\.[0-9]\+' | grep -v '^$' | wc -l)
partition_count=$(sudo "${TOOLKIT_PATH}"/helper/HDL\ Dump.elf toc $DEVICE | grep -o 'PP\.[0-9]\+' | grep -v '^$' | wc -l)
echo "Number of PP partitions: $partition_count" | tee -a ${LOG_FILE}
echo "Number of PP partitions: $partition_count" | tee -a "${LOG_FILE}"
# Check if the count exceeds the partition count
if [ "$count" -gt "$partition_count" ]; then
echo
echo "Error: Number of games ($count) exceeds the available partitions ($partition_count)." | tee -a "${LOG_FILE}"
echo "Error: Number of games ($count) exceeds the available partitions ($partition_count)." | tee -a ""${LOG_FILE}""
read -p "Press any key to exit..."
exit 1
fi
# Get the list of partition names
partitions=$(sudo ${TOOLKIT_PATH}/helper/HDL\ Dump.elf toc $DEVICE | grep -o 'PP\.[0-9]*')
partitions=$(sudo "${TOOLKIT_PATH}"/helper/HDL\ Dump.elf toc $DEVICE | grep -o 'PP\.[0-9]*')
missing_partitions=()
@ -154,11 +154,11 @@ for i in $(seq -f "%03g" 1 "$partition_count"); do
done
if [ ${#missing_partitions[@]} -eq 0 ]; then
echo "All partitions (PP.001 to PP.${partition_count}) are present." | tee -a ${LOG_FILE}
echo "All partitions (PP.001 to PP.${partition_count}) are present." | tee -a "${LOG_FILE}"
else
echo "Missing partitions:" | tee -a ${LOG_FILE}
echo "Missing partitions:" | tee -a "${LOG_FILE}"
for partition in "${missing_partitions[@]}"; do
echo "$partition" | tee -a ${LOG_FILE}
echo "$partition" | tee -a "${LOG_FILE}"
read -p "Press any key to exit..."
exit 1
done
@ -168,16 +168,16 @@ fi
START_PARTITION_NUMBER=$(echo "$partitions" | grep -o 'PP\.[0-9]*' | sort -V | tail -n 1 | sed 's/PP\.//')
START_PARTITION_NUMBER=$((START_PARTITION_NUMBER))
echo | tee -a ${LOG_FILE}
echo | tee -a "${LOG_FILE}"
echo "Ready to install games. Press any key to continue..."
read -n 1 -s
echo | tee -a ${LOG_FILE}
echo "Preparing to sync PS1 games..." | tee -a ${LOG_FILE}
echo | tee -a ${LOG_FILE}
echo | tee -a "${LOG_FILE}"
echo "Preparing to sync PS1 games..." | tee -a "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
# Step 1: Create matching .ELF files for .VCD files
echo "Creating matching .ELF files for .VCDs..." | tee -a ${LOG_FILE}
echo "Creating matching .ELF files for .VCDs..." | tee -a "${LOG_FILE}"
for vcd_file in "$POPS_FOLDER"/*.VCD; do
if [ -f "$vcd_file" ]; then
# Extract the base name (without extension) from the .VCD file
@ -186,16 +186,16 @@ for vcd_file in "$POPS_FOLDER"/*.VCD; do
elf_file="$POPS_FOLDER/$base_name.ELF"
# Copy and rename POPSTARTER.ELF to match the .VCD file
if [ ! -f "$elf_file" ]; then
echo "Creating $elf_file..." | tee -a ${LOG_FILE}
echo "Creating $elf_file..." | tee -a "${LOG_FILE}"
cp "$POPSTARTER_DIR" "$elf_file"
fi
fi
done
echo "Matching .ELF files created successfully." | tee -a ${LOG_FILE}
echo | tee -a ${LOG_FILE}
echo "Matching .ELF files created successfully." | tee -a "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
# Step 2: Delete .ELF files without matching .VCD files
echo "Removing orphan .ELF files..." | tee -a ${LOG_FILE}
echo "Removing orphan .ELF files..." | tee -a "${LOG_FILE}"
for elf_file in "$POPS_FOLDER"/*.ELF; do
if [ -f "$elf_file" ]; then
# Extract the base name (without extension) from the .ELF file
@ -203,16 +203,16 @@ for elf_file in "$POPS_FOLDER"/*.ELF; do
# Check if a corresponding .VCD file exists
vcd_file="$POPS_FOLDER/$base_name.VCD"
if [ ! -f "$vcd_file" ]; then
echo "Deleting orphan $elf_file..." | tee -a ${LOG_FILE}
echo "Deleting orphan $elf_file..." | tee -a "${LOG_FILE}"
rm "$elf_file"
fi
fi
done
echo "Orphan .ELF files removed successfully." | tee -a ${LOG_FILE}
echo | tee -a ${LOG_FILE}
echo "Orphan .ELF files removed successfully." | tee -a "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
# Generate the local file list directly in a variable
local_files=$(ls -1 $POPS_FOLDER | sort)
local_files=$(ls -1 "$POPS_FOLDER" | sort)
# Build the commands for PFS Shell
COMMANDS="device ${DEVICE}\n"
@ -228,15 +228,15 @@ ps2_files=$(echo -e "$COMMANDS" | sudo "${TOOLKIT_PATH}/helper/PFS Shell.elf" 2>
files_only_in_local=$(comm -23 <(echo "$local_files") <(echo "$ps2_files"))
files_only_in_ps2=$(comm -13 <(echo "$local_files") <(echo "$ps2_files"))
echo "Files to delete:" | tee -a ${LOG_FILE}
echo "$files_only_in_ps2" | tee -a ${LOG_FILE}
echo | tee -a ${LOG_FILE}
echo "Files to copy:" | tee -a ${LOG_FILE}
echo "$files_only_in_local" | tee -a ${LOG_FILE}
echo | tee -a ${LOG_FILE}
echo "Files to delete:" | tee -a "${LOG_FILE}"
echo "$files_only_in_ps2" | tee -a "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
echo "Files to copy:" | tee -a "${LOG_FILE}"
echo "$files_only_in_local" | tee -a "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
# Syncing PS1 games
cd $POPS_FOLDER
cd "$POPS_FOLDER"
combined_commands="device ${DEVICE}\n"
combined_commands+="mount __.POPS\n"
@ -246,66 +246,66 @@ if [ -n "$files_only_in_ps2" ]; then
combined_commands+="rm \"$file\"\n"
done <<< "$files_only_in_ps2"
else
echo "No files to delete." | tee -a ${LOG_FILE}
echo "No files to delete." | tee -a "${LOG_FILE}"
fi
echo | tee -a ${LOG_FILE}
echo | tee -a "${LOG_FILE}"
# Add put commands for files_only_in_local
if [ -n "$files_only_in_local" ]; then
while IFS= read -r file; do
combined_commands+="put \"$file\"\n"
done <<< "$files_only_in_local"
else
echo "No files to copy." | tee -a ${LOG_FILE}
echo "No files to copy." | tee -a "${LOG_FILE}"
fi
combined_commands+="umount\n"
combined_commands+="exit"
# Execute the combined commands with PFS Shell
echo "Syncing PS1 games to HDD..." | tee -a ${LOG_FILE}
echo | tee -a ${LOG_FILE}
echo -e "$combined_commands" | sudo "${TOOLKIT_PATH}/helper/PFS Shell.elf" >> ${LOG_FILE} 2>&1
echo | tee -a ${LOG_FILE}
echo "PS1 games synced sucessfully." | tee -a ${LOG_FILE}
echo | tee -a ${LOG_FILE}
echo "Syncing PS1 games to HDD..." | tee -a "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
echo -e "$combined_commands" | sudo "${TOOLKIT_PATH}/helper/PFS Shell.elf" >> "${LOG_FILE}" 2>&1
echo | tee -a "${LOG_FILE}"
echo "PS1 games synced sucessfully." | tee -a "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
cd ${TOOLKIT_PATH}
cd "${TOOLKIT_PATH}"
# Syncing PS2 games
echo "Mounting OPL partition" | tee -a ${LOG_FILE}
mkdir ${TOOLKIT_PATH}/OPL 2>> "${LOG_FILE}"
sudo mount ${DEVICE}3 ${TOOLKIT_PATH}/OPL
echo | tee -a ${LOG_FILE}
echo "Syncing PS2 games..." | tee -a ${LOG_FILE}
sudo rsync -r --progress --ignore-existing --delete ${GAMES_PATH}/CD/ ${TOOLKIT_PATH}/OPL/CD/ | tee -a ${LOG_FILE}
sudo rsync -r --progress --ignore-existing --delete ${GAMES_PATH}/DVD/ ${TOOLKIT_PATH}/OPL/DVD/ | tee -a ${LOG_FILE}
echo | tee -a ${LOG_FILE}
echo "PS2 games sucessfully synced" | tee -a ${LOG_FILE}
echo | tee -a ${LOG_FILE}
echo "Unmounting OPL partition..." | tee -a ${LOG_FILE}
sudo umount ${TOOLKIT_PATH}/OPL
echo | tee -a ${LOG_FILE}
echo "Mounting OPL partition" | tee -a "${LOG_FILE}"
mkdir "${TOOLKIT_PATH}"/OPL 2>> "${LOG_FILE}"
sudo mount ${DEVICE}3 "${TOOLKIT_PATH}"/OPL
echo | tee -a "${LOG_FILE}"
echo "Syncing PS2 games..." | tee -a "${LOG_FILE}"
sudo rsync -r --progress --ignore-existing --delete "${GAMES_PATH}/CD/" "${TOOLKIT_PATH}"/OPL/CD/ | tee -a "${LOG_FILE}"
sudo rsync -r --progress --ignore-existing --delete "${GAMES_PATH}/DVD/" "${TOOLKIT_PATH}"/OPL/DVD/ | tee -a "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
echo "PS2 games sucessfully synced" | tee -a "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
echo "Unmounting OPL partition..." | tee -a "${LOG_FILE}"
sudo umount "${TOOLKIT_PATH}"/OPL
echo | tee -a "${LOG_FILE}"
mkdir -p "${ARTWORK_DIR}/tmp" 2>> "${LOG_FILE}"
echo | tee -a ${LOG_FILE}
echo "Downloading artwork..." | tee -a ${LOG_FILE}
echo | tee -a "${LOG_FILE}"
echo "Downloading artwork..." | tee -a "${LOG_FILE}"
# First loop: Run the art downloader script for each game_id if artwork doesn't already exist
while IFS='|' read -r game_title game_id publisher disc_type file_name; do
# Check if the artwork file already exists
png_file="${ARTWORK_DIR}/${game_id}.png"
if [[ -f "$png_file" ]]; then
echo "Artwork for game ID $game_id already exists. Skipping download." | tee -a ${LOG_FILE}
echo "Artwork for game ID $game_id already exists. Skipping download." | tee -a "${LOG_FILE}"
else
# If the file doesn't exist, run the art downloader
echo "Running art downloader for game ID: $game_id" | tee -a ${LOG_FILE}
node ${TOOLKIT_PATH}/helper/art_downloader.js "$game_id" | tee -a ${LOG_FILE}
echo "Running art downloader for game ID: $game_id" | tee -a "${LOG_FILE}"
node "${TOOLKIT_PATH}"/helper/art_downloader.js "$game_id" | tee -a "${LOG_FILE}"
fi
done < "$ALL_GAMES"
echo | tee -a ${LOG_FILE}
echo "Converting artwork..." | tee -a ${LOG_FILE}
echo | tee -a "${LOG_FILE}"
echo "Converting artwork..." | tee -a "${LOG_FILE}"
# Define input directory
input_dir="${ARTWORK_DIR}/tmp"
@ -320,21 +320,21 @@ if compgen -G "${input_dir}/*" > /dev/null; then
output="${ARTWORK_DIR}/${base_name}.png"
# Convert each file to .png with resizing and 8-bit depth
convert "$file" -resize 256x256 -depth 8 -dither FloydSteinberg -colors 256 "$output" | tee -a ${LOG_FILE}
convert "$file" -resize 256x256 -depth 8 -dither FloydSteinberg -colors 256 "$output" | tee -a "${LOG_FILE}"
done
rm "${input_dir}"/*
else
echo "No files to process in ${input_dir}" | tee -a ${LOG_FILE}
echo "No files to process in ${input_dir}" | tee -a "${LOG_FILE}"
fi
echo | tee -a ${LOG_FILE}
echo "Creating game assets..." | tee -a ${LOG_FILE}
echo | tee -a "${LOG_FILE}"
echo "Creating game assets..." | tee -a "${LOG_FILE}"
# Read the file line by line
while IFS='|' read -r game_title game_id publisher disc_type file_name; do
# Create a sub-folder named after the game_id
game_dir="$ICONS_DIR/$game_id"
mkdir -p "$game_dir" | tee -a ${LOG_FILE}
mkdir -p "$game_dir" | tee -a "${LOG_FILE}"
# Generate the launcher.cfg file
launcher_cfg_filename="$game_dir/launcher.cfg"
@ -343,7 +343,7 @@ file_name=$file_name
title_id=$game_id
disc_type=$disc_type
EOL
echo "Created info.sys: $launcher_cfg_filename" | tee -a ${LOG_FILE}
echo "Created info.sys: $launcher_cfg_filename" | tee -a "${LOG_FILE}"
# Generate the info.sys file
info_sys_filename="$game_dir/info.sys"
@ -370,33 +370,33 @@ violence_flag = 0
content_type = 255
content_subtype = 0
EOL
echo "Created info.sys: $info_sys_filename" | tee -a ${LOG_FILE}
echo "Created info.sys: $info_sys_filename" | tee -a "${LOG_FILE}"
# Copy the matching .png file and rename it to jkt_001.png
png_file="${TOOLKIT_PATH}/icons/art/${game_id}.png"
if [[ -f "$png_file" ]]; then
cp "$png_file" "$game_dir/jkt_001.png"
echo "Artwork found for $game_title" | tee -a ${LOG_FILE}
echo "Artwork found for $game_title" | tee -a "${LOG_FILE}"
else
if [[ "$disc_type" == "POPS" ]]; then
cp "${TOOLKIT_PATH}/icons/art/ps1.png" "$game_dir/jkt_001.png"
echo "Artwork not found for $game_title. Using default PS1 image" | tee -a ${LOG_FILE}
echo "$game_id $game_title" >> ${MISSING_ART}
echo "Artwork not found for $game_title. Using default PS1 image" | tee -a "${LOG_FILE}"
echo "$game_id $game_title" >> "${MISSING_ART}"
else
cp "${TOOLKIT_PATH}/icons/art/ps2.png" "$game_dir/jkt_001.png"
echo "Artwork not found for $game_title. Using default PS2 image" | tee -a ${LOG_FILE}
echo "$game_id $game_title" >> ${MISSING_ART}
echo "Artwork not found for $game_title. Using default PS2 image" | tee -a "${LOG_FILE}"
echo "$game_id $game_title" >> "${MISSING_ART}"
fi
fi
done < "$ALL_GAMES"
echo | tee -a ${LOG_FILE}
echo "All .cfg, info.sys, and .png files have been created in their respective sub-folders." | tee -a ${LOG_FILE}
echo | tee -a ${LOG_FILE}
echo "Installing game assets..." | tee -a ${LOG_FILE}
echo | tee -a "${LOG_FILE}"
echo "All .cfg, info.sys, and .png files have been created in their respective sub-folders." | tee -a "${LOG_FILE}"
echo | tee -a "${LOG_FILE}"
echo "Installing game assets..." | tee -a "${LOG_FILE}"
cd ${ICONS_DIR}
cd "${ICONS_DIR}"
# Build the mount/copy/unmount commands for all partitions
COMMANDS="device ${DEVICE}\n"
@ -443,17 +443,17 @@ done
COMMANDS+="exit"
# Pipe all commands to PFS Shell for mounting, copying, and unmounting
echo -e "$COMMANDS" | sudo "${TOOLKIT_PATH}/helper/PFS Shell.elf" >> ${LOG_FILE} 2>&1
echo -e "$COMMANDS" | sudo "${TOOLKIT_PATH}/helper/PFS Shell.elf" >> "${LOG_FILE}" 2>&1
echo | tee -a ${LOG_FILE}
echo "Cleaning up..." | tee -a ${LOG_FILE}
echo | tee -a "${LOG_FILE}"
echo "Cleaning up..." | tee -a "${LOG_FILE}"
# Loop through all items in the target directory
for item in "$ICONS_DIR"/*; do
# Check if the item is a directory and not the 'art' folder
if [ -d "$item" ] && [ "$(basename "$item")" != "art" ]; then
rm -rf "$item" >> ${LOG_FILE} 2>&1
rm -rf "$item" >> "${LOG_FILE}" 2>&1
fi
done
@ -461,7 +461,7 @@ rm "${TOOLKIT_PATH}/package.json" &> /dev/null
rm "${TOOLKIT_PATH}/package-lock.json" &> /dev/null
echo | tee -a ${LOG_FILE}
echo "Game installer script complete" | tee -a ${LOG_FILE}
echo | tee -a "${LOG_FILE}"
echo "Game installer script complete" | tee -a "${LOG_FILE}"
echo
read -p "Press any key to continue..."