```
#!/bin/bash
set -e
# Setup directories
DOWNLOAD_DIR="$HOME/Downloads/MKWii_Setup"
mkdir -p "$DOWNLOAD_DIR"
cd "$DOWNLOAD_DIR"
echo "=== Mario Kart Wii Retro Rewind Installer & Updater ==="
echo "Working directory: $DOWNLOAD_DIR"
# 1. Fetch latest WiiCompiled AppImage release from GitHub API
echo "Checking GitHub for the latest WiiCompiled release..."
LATEST_TAG=$(curl -s https://api.github.com/repos/patchzyy/Wiicompiled/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$LATEST_TAG" ]; then
echo "Warning: Failed to fetch the latest tag from GitHub. Defaulting to local version check."
else
echo "Latest version on GitHub: $LATEST_TAG"
fi
VERSION_FILE="installed_version.txt"
INSTALLED_TAG=""
if [ -f "$VERSION_FILE" ]; then
INSTALLED_TAG=$(cat "$VERSION_FILE")
fi
APPIMAGE="WiiCompiled-Setup-x86_64.AppImage"
# Download AppImage if missing or if a newer GitHub release exists
if [ ! -f "$APPIMAGE" ] || [ "$LATEST_TAG" != "$INSTALLED_TAG" ]; then
echo "Downloading latest WiiCompiled AppImage ($LATEST_TAG)..."
APPIMAGE_URL="https://github.com/patchzyy/Wiicompiled/releases/download/${LATEST_TAG}/WiiCompiled-Setup-x86_64.AppImage";
curl -L -f -o "$APPIMAGE" "$APPIMAGE_URL"
chmod +x "$APPIMAGE"
echo "$LATEST_TAG" > "$VERSION_FILE"
else
echo "WiiCompiled AppImage is already up to date ($INSTALLED_TAG)."
fi
# 2. Smart check & download for Retro Rewind Zip
ZIP_FILE="RetroRewind.zip"
ZIP_URL="https://update.rwfc.net/RetroRewind/zip/RetroRewind.zip";
# Function to test if the zip file is valid
is_valid_zip() {
[ -f "$1" ] && unzip -tq "$1" >/dev/null 2>&1
}
# Remove corrupted zip if previous run failed
if [ -f "$ZIP_FILE" ] && ! is_valid_zip "$ZIP_FILE"; then
echo "Detected corrupted $ZIP_FILE. Removing..."
rm -f "$ZIP_FILE"
fi
if [ -f "$ZIP_FILE" ]; then
echo "Checking server if a newer Retro Rewind patch zip exists..."
curl -L -s -f -z "$ZIP_FILE" -o "$ZIP_FILE" "$ZIP_URL"
else
echo "Downloading Retro Rewind patch..."
curl -L -f -o "$ZIP_FILE" "$ZIP_URL"
fi
# Final check before extracting
if ! is_valid_zip "$ZIP_FILE"; then
echo "Error: Downloaded $ZIP_FILE is invalid or incomplete. Retrying full download..."
rm -f "$ZIP_FILE"
curl -L -f -o "$ZIP_FILE" "$ZIP_URL"
fi
# Extract or sync extracted patch contents
echo "Syncing patch files..."
unzip -uoq "$ZIP_FILE"
# 3. Download MKWii ROM if missing
ROM_FILE="RMCP01.wbfs"
if [ ! -f "$ROM_FILE" ]; then
echo "Downloading Mario Kart Wii ROM..."
curl -L -f -o "$ROM_FILE" "https://archive.org/download/mario-kart-wii-pal/RMCP01.wbfs";
else
echo "$ROM_FILE already exists, skipping download."
fi
# 4. Execute Installation / Update Command
echo "=== Running WiiCompiled Setup ==="
./"$APPIMAGE" --game "$DOWNLOAD_DIR/$ROM_FILE" install --profile base --retro-dir "$DOWNLOAD_DIR/RetroRewind6" --download-retro-wfc-payload
echo "=== Setup Complete! ==="
```
quotingMario Kart Wii with 200+ tracks and 60+ characters, with free online play.
nevent1q…u6kp
![]()
First download your prerequisites
Wiicompiled installer
https://github.com/patchzyy/Wiicompiled/releases/download/v0.2.31/WiiCompiled-Setup-x86_64.AppImage
Retro rewind patch is here - extra tracks & online functions.
https://update.rwfc.net/RetroRewind/zip/RetroRewind.zip
And a ROM - original MKWii ROM
https://archive.org/download/mario-kart-wii-pal/RMCP01.wbfs
Once you have all these run this command:
```
./WiiCompiled-Setup-x86_64.AppImage --game "path to ROM" install --profile base --retro-dir "patch folder" --download-retro-wfc-payload
```
Note: The patch folder is the one named RetroRewind6 once you unzip it's source file.
This command will take a while, and when it's done you'll have a shortcut in your menu.
#retrogaming #gamestr

