35 lines
No EOL
1 KiB
Bash
35 lines
No EOL
1 KiB
Bash
#!/bin/bash
|
|
|
|
# Function to download game files based on version
|
|
download_game() {
|
|
local version=$1
|
|
local url
|
|
local extract_path="~/.local/share/vintagestory_${version}"
|
|
|
|
# Check if version contains a "-"
|
|
if [[ $version == *"-"* ]]; then
|
|
url="https://cdn.vintagestory.at/gamefiles/unstable/vs_server_linux-x64_${version}.tar.gz"
|
|
else
|
|
url="https://cdn.virtualstory.at/gamefiles/stable/vs_server_linux-x64_${version}.tar.gz"
|
|
fi
|
|
|
|
# Check if extract path already exists and is not empty
|
|
if [ -d "$extract_path" ] && [ ! -z "$(ls -A "$extract_path")" ]; then
|
|
echo "Extract path $extract_path already exists and is not empty, skipping download."
|
|
return
|
|
fi
|
|
|
|
# Download game files
|
|
download_path="/vs_server_linux-x64_${version}"
|
|
curl -k "$url" -o "${download_path}.tar.gz"
|
|
|
|
# Extract and clean up
|
|
mkdir -pv $extract_path
|
|
cd $extract_path
|
|
tar -xvf "${download_path}.tar.gz" && rm "${download_path}"/"${version}"*.tar.gz
|
|
cd /
|
|
}
|
|
|
|
# Call the function with version as argument (e.g. "1.20.12")
|
|
|
|
download_game "$1" |