If the archive is not found, detect a tar error, and remove the temporary files.
This commit is contained in:
parent
217cfc2b4d
commit
43cfb617b6
1 changed files with 13 additions and 3 deletions
|
@ -10,7 +10,7 @@ download_game() {
|
|||
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"
|
||||
url="https://cdn.vintagestory.at/gamefiles/stable/vs_server_linux-x64_${version}.tar.gz"
|
||||
fi
|
||||
|
||||
# Check if extract path already exists and is not empty
|
||||
|
@ -26,8 +26,18 @@ download_game() {
|
|||
# Extract and clean up
|
||||
mkdir -pv $extract_path
|
||||
cd $extract_path
|
||||
tar -xvf "${download_path}.tar.gz" && rm "${download_path}"/"${version}"*.tar.gz
|
||||
tar -xvf "${download_path}.tar.gz" && rm "${download_path}.tar.gz"
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
cd /
|
||||
echo "Successfully downloaded and extracted $version to $extract_path"
|
||||
else
|
||||
rm -rf "$download_path"
|
||||
rm -rf "$extract_path"
|
||||
echo "Game version was not found. Something went wrong. Cleaning up artifacts..."
|
||||
cd /
|
||||
fi
|
||||
}
|
||||
|
||||
# Call the function with version as argument (e.g. "1.20.12")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue