Skip to content

Commit

Permalink
Update setup_retroarch.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinebou12 authored Feb 18, 2024
1 parent 855c16e commit 507222a
Showing 1 changed file with 53 additions and 26 deletions.
79 changes: 53 additions & 26 deletions setup_retroarch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,70 @@

ROOT_WWW_PATH="$1"

# Ensure ROOT_WWW_PATH is not empty
if [ -z "$ROOT_WWW_PATH" ]; then
echo "Usage: $0 <path>"
exit 1
fi

# Navigate to the target directory
cd "${ROOT_WWW_PATH}"
cd "${ROOT_WWW_PATH}" || { echo "Failed to navigate to ${ROOT_WWW_PATH}"; exit 1; }

# Download RetroArch archive for yesterday's date
wget "https://buildbot.libretro.com/nightly/emscripten/$(date -d "yesterday" '+%Y-%m-%d')_RetroArch.7z"
ARCHIVE_NAME="$(date -d "yesterday" '+%Y-%m-%d')_RetroArch.7z"
wget "https://buildbot.libretro.com/nightly/emscripten/${ARCHIVE_NAME}" || { echo "Failed to download archive"; exit 1; }

# Extract the RetroArch archive
7z x -y "$(date -d "yesterday" '+%Y-%m-%d')_RetroArch.7z"

# Move the extracted content to the current directory and remove the temporary directory
mv retroarch/* ./
find retroarch/ -mindepth 1 -maxdepth 1 -name ".*" -exec mv {} . \;
rmdir retroarch

if 7z x -y "${ARCHIVE_NAME}"; then
if [ -d "retroarch" ]; then
cp -r retroarch/. .
rm -rf retroarch
else
echo "Extraction did not create the expected 'retroarch' directory."
fi
else
echo "Failed to extract ${ARCHIVE_NAME}"
exit 1
fi
# Remove a specific script tag from index.html if present
sed -i '/<script src="analytics.js"><\/script>/d' ./index.html

# Ensure indexer is executable
chmod +x indexer
if [ -f "./index.html" ]; then
sed -i '/<script src="analytics.js"><\/script>/d' ./index.html
else
echo "index.html not found, skipping script tag removal."
fi

# Prepare the directory structure
mkdir -p "${ROOT_WWW_PATH}/assets/cores" "${ROOT_WWW_PATH}/assets/frontend/bundle"
# Ensure indexer is executable, if it exists
if [ -f "./indexer" ]; then
chmod +x indexer
else
echo "indexer not found, skipping chmod +x."
fi

# Navigate to the frontend bundle directory
cd "${ROOT_WWW_PATH}/assets/frontend/bundle"
# No need to prepare these directories if they already exist
mkdir -p "assets/cores"
mkdir -p "assets/frontend/bundle"

# Combine bundle parts if they exist and extract the combined bundle
if ls bundle.zip.* 1> /dev/null 2>&1; then
cat bundle.zip.* > bundle.zip
7z x -y bundle.zip
# Optionally, clean up the split parts after extraction
rm -f bundle.zip.*
BUNDLE_PATH="./assets/frontend/bundle"
if ls "./assets/frontend/" 1> /dev/null 2>&1; then
if [ -f "./assets/frontend/bundle.zip.aa" ]; then

cat "./assets/frontend/bundle.zip."* > "${BUNDLE_PATH}/bundle.zip" && \
7z x -y "${BUNDLE_PATH}/bundle.zip" -o"./assets/frontend/"
else
echo "No bundle parts to combine."
fi
else
echo "No bundle parts to combine."
fi

# Generate index files
cd "${ROOT_WWW_PATH}/assets/frontend/bundle" && ../../../indexer > .index-xhr
cd "${ROOT_WWW_PATH}/assets/cores" && ../../indexer > .index-xhr
current_dir=$(pwd)
if [ -f "indexer" ]; then
cd "./assets/frontend/bundle" && echo $(pwd) && ../../../indexer > .index-xhr && echo "indexer found, generating index."
cd "${current_dir}/assets/cores" && echo $(pwd) && ../../indexer > .index-xhr && echo "indexer found, generating index."
else
echo "indexer not found, skipping index generation."
fi

# Cleanup downloaded and temporary files
rm -rf "${ROOT_WWW_PATH}/$(date -d "yesterday" '+%Y-%m-%d')_RetroArch.7z" "${ROOT_WWW_PATH}/assets/frontend/bundle.zip"
echo "Setup completed."

0 comments on commit 507222a

Please sign in to comment.