Last active
January 15, 2024 19:46
-
-
Save James-Firth/8180252aada26719813fbd4aa5399648 to your computer and use it in GitHub Desktop.
FoundryVTT Updater - A quick script to pull the latest foundry image for docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Docker Foundry Updater | |
# This script is used to download the Foundry ZIP file so it can be picked up by the Foundry container | |
# By felddy (felddy/foundryvtt:release) | |
# USAGE | |
# ./foundry_update.sh TIMED_URL (PATH_TO_CONTAINER_CACHE_FOLDER) | |
# Save the current working directory and move to the file's location, makes relative paths easier to manage | |
working_dir=$(pwd -P) | |
parent_path=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P ) | |
cd "$parent_path" | |
# Grab user input | |
download_url=${1} | |
download_path=${2} | |
# You MUST have a download url | |
if [[ $download_url == "" ]]; then | |
echo "CANCELLED." | |
echo "usage: ./foundry_update.sh PATH_TO_DOWNLOAD_ZIP" | |
echo "" | |
fi | |
# TODO: Check folder actually exists | |
download_dir=$download_path | |
if [[ $download_path != "" ]]; then | |
if [[ ! -d $download_path ]]; then | |
echo "$download_path does NOT exist." | |
exit 1; | |
fi | |
else | |
download_dir=$working_dir | |
fi | |
# Grab the filename from the URL then cut everything after the ? and make it lowercase | |
# Then combine it with the directory we're download to | |
filename="$download_dir/$(basename "$download_url" | cut -f1 -d "?" | tr '[:upper:]' '[:lower:]')" | |
echo " [ Foundry Updater ] " | |
echo "Downloading to $filename" | |
echo "" | |
# Could use wget but this has the most minimal UI | |
curl --progress-bar -o $filename $download_url | |
echo "File Downloaded to $filename" | |
echo "Changing ownership to the foundry docker container" | |
chown 100420:100420 $filename | |
# TODO: CHANGE THIS TO YOUR USER:GROUP used by the docker container | |
echo "Check if Foundry is up. You can now restart the Foundry container if needed" | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment