|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# OpenTaiko Installation Script - Linux version |
| 4 | +# Does not require OpenTaiko Hub |
| 5 | + |
| 6 | +# Dependency check |
| 7 | +dependencies=(curl jq unzip git pgrep) |
| 8 | +missing=() |
| 9 | + |
| 10 | +for cmd in "${dependencies[@]}"; do |
| 11 | + if ! command -v "$cmd" &> /dev/null; then |
| 12 | + missing+=("$cmd") |
| 13 | + fi |
| 14 | +done |
| 15 | + |
| 16 | +if [ ${#missing[@]} -ne 0 ]; then |
| 17 | + echo "Error: The following programs are not installed: ${missing[*]}" |
| 18 | + echo "Please install them using your package manager (e.g., sudo apt install ${missing[*]})" |
| 19 | + exit 1 |
| 20 | +fi |
| 21 | + |
| 22 | +echo "Starting OpenTaiko installation..." |
| 23 | + |
| 24 | +current_dir=$(pwd) |
| 25 | + |
| 26 | +# Constants |
| 27 | +cache_dir="$current_dir/cache" |
| 28 | +desktop_folder="$HOME/.local/share/applications" |
| 29 | +archive_filename="OpenTaiko.Linux.x64.zip" |
| 30 | +installation_folder="$current_dir/OpenTaiko" |
| 31 | +git_repo="0auBSQ/OpenTaiko" |
| 32 | + |
| 33 | +# Create cache directory |
| 34 | +mkdir -p "$cache_dir" |
| 35 | + |
| 36 | +# Get latest release tag via GitHub API |
| 37 | +echo "Fetching latest release tag for $git_repo..." |
| 38 | +latest_tag=$(curl -s "https://api.github.com/repos/$git_repo/releases/latest" | jq -r '.tag_name') |
| 39 | + |
| 40 | +if [ -z "$latest_tag" ] || [ "$latest_tag" = "null" ]; then |
| 41 | + echo "Failed to fetch the latest version tag." |
| 42 | + exit 1 |
| 43 | +fi |
| 44 | + |
| 45 | +echo "Latest version: $latest_tag" |
| 46 | + |
| 47 | +# Create and move to installation_folder |
| 48 | +mkdir -p "$installation_folder" |
| 49 | +cd "$installation_folder" || exit 1 |
| 50 | + |
| 51 | +# Check if we already have this version cached |
| 52 | +cached_file="$cache_dir/$latest_tag-$archive_filename" |
| 53 | +if [ -f "$cached_file" ]; then |
| 54 | + echo "Using cached version: $cached_file" |
| 55 | + cp "$cached_file" "$archive_filename" |
| 56 | +else |
| 57 | + # Download using curl with redirect support |
| 58 | + download_url="https://github.com/$git_repo/releases/download/$latest_tag/$archive_filename" |
| 59 | + echo "Downloading from: $download_url" |
| 60 | + curl -L -o "$archive_filename" "$download_url" || { echo "Download failed."; exit 1; } |
| 61 | + |
| 62 | + # Cache the download |
| 63 | + echo "Caching download for future use..." |
| 64 | + cp "$archive_filename" "$cached_file" |
| 65 | +fi |
| 66 | + |
| 67 | +echo "Unzipping..." |
| 68 | +unzip -o "$archive_filename" |
| 69 | +rm -f "$archive_filename" |
| 70 | + |
| 71 | +# Navigate to publish |
| 72 | +cd "publish" || exit 1 |
| 73 | + |
| 74 | +# === Update/clone soundtrack repository === |
| 75 | +cached_soundtrack="$cache_dir/OpenTaiko-Soundtrack" |
| 76 | +if [ -d "$cached_soundtrack" ]; then |
| 77 | + echo "Updating cached soundtrack repository..." |
| 78 | + cd "$cached_soundtrack" && git pull && cd - || exit 1 |
| 79 | +else |
| 80 | + echo "Cloning soundtrack repository to cache..." |
| 81 | + git clone https://github.com/OpenTaiko/OpenTaiko-Soundtrack "$cached_soundtrack" |
| 82 | +fi |
| 83 | + |
| 84 | +# Merge soundtrack into publish/Songs |
| 85 | +mkdir -p "Songs" |
| 86 | +cp -rf "$cached_soundtrack/"* "Songs/" |
| 87 | + |
| 88 | +# === Update/clone skins repository === |
| 89 | +cached_skins="$cache_dir/OpenTaiko-Skins" |
| 90 | +if [ -d "$cached_skins" ]; then |
| 91 | + echo "Updating cached skins repository..." |
| 92 | + cd "$cached_skins" && git pull && cd - || exit 1 |
| 93 | +else |
| 94 | + echo "Cloning skins repository to cache..." |
| 95 | + git clone https://github.com/OpenTaiko/OpenTaiko-Skins "$cached_skins" |
| 96 | +fi |
| 97 | + |
| 98 | +# Merge skins directly into publish |
| 99 | +cp -rf "$cached_skins/"* "./" |
| 100 | + |
| 101 | +# Make OpenTaiko binary executable |
| 102 | +chmod +x "OpenTaiko" |
| 103 | + |
| 104 | +# Create launcher script with YOUR custom Vulkan/Environment logic |
| 105 | +launcher="$installation_folder/start_opentaiko.sh" |
| 106 | +cat << EOF > "$launcher" |
| 107 | +#!/bin/bash |
| 108 | +# 1. Clear environment to let the game choose its backend |
| 109 | +unset SDL_VIDEODRIVER |
| 110 | +unset StoreValue |
| 111 | +
|
| 112 | +# 2. Set essential paths and force Vulkan |
| 113 | +export DIR="$installation_folder/publish" |
| 114 | +export LD_LIBRARY_PATH="\$DIR:\$LD_LIBRARY_PATH" |
| 115 | +export ANGLE_DEFAULT_PLATFORM=vulkan |
| 116 | +
|
| 117 | +# 3. Launch from the correct directory |
| 118 | +cd "\$DIR" |
| 119 | +./OpenTaiko |
| 120 | +EOF |
| 121 | +chmod +x "$launcher" |
| 122 | + |
| 123 | +# Create desktop entry for launching |
| 124 | +mkdir -p "$desktop_folder" |
| 125 | +cat << EOF > "$desktop_folder/start_opentaiko.desktop" |
| 126 | +[Desktop Entry] |
| 127 | +Name=Start OpenTaiko |
| 128 | +Exec=$installation_folder/start_opentaiko.sh |
| 129 | +Path=$installation_folder/publish |
| 130 | +Icon=$installation_folder/publish/OpenTaiko.ico |
| 131 | +Terminal=false |
| 132 | +Type=Application |
| 133 | +Categories=Game; |
| 134 | +EOF |
| 135 | + |
| 136 | +# Create update script |
| 137 | +update_script="$installation_folder/update_opentaiko.sh" |
| 138 | +cat << EOF > "$update_script" |
| 139 | +#!/bin/bash |
| 140 | +if pgrep -x "OpenTaiko" > /dev/null; then |
| 141 | + echo "Waiting for OpenTaiko to close..." |
| 142 | + while pgrep -x "OpenTaiko" > /dev/null; do sleep 1; done |
| 143 | +fi |
| 144 | +
|
| 145 | +echo "Updating OpenTaiko repositories..." |
| 146 | +cd "$cache_dir/OpenTaiko-Soundtrack" && git pull |
| 147 | +cp -rf "$cache_dir/OpenTaiko-Soundtrack/"* "$installation_folder/publish/Songs/" |
| 148 | +cd "$cache_dir/OpenTaiko-Skins" && git pull |
| 149 | +cp -rf "$cache_dir/OpenTaiko-Skins/"* "$installation_folder/publish/" |
| 150 | +
|
| 151 | +echo "Update complete!" |
| 152 | +EOF |
| 153 | +chmod +x "$update_script" |
| 154 | + |
| 155 | +# Create desktop entry for updating |
| 156 | +cat << EOF > "$desktop_folder/update_opentaiko.desktop" |
| 157 | +[Desktop Entry] |
| 158 | +Name=Update OpenTaiko |
| 159 | +Exec=$installation_folder/update_opentaiko.sh |
| 160 | +Path=$installation_folder |
| 161 | +Icon=$installation_folder/publish/OpenTaiko.ico |
| 162 | +Terminal=true |
| 163 | +Type=Application |
| 164 | +Categories=Game; |
| 165 | +EOF |
| 166 | + |
| 167 | +echo "OpenTaiko installation complete!" |
| 168 | +echo "Your custom Vulkan launcher has been created at: $launcher" |
| 169 | +echo "You can launch your game either from that file or use an standard application launcher" |
0 commit comments