Skip to content

Instantly share code, notes, and snippets.

@yddlef

yddlef/README.md Secret

Last active Apr 9, 2021
Embed
What would you like to do?
Plutonium patch script for the felddy/foundryvtt container.

Plutonium backend support for felddy/foundryvtt

The Docker container can be patched to support Plutonium by setting the CONTAINER_PATCH_URLS environment variable to contain URL the of the plutonium.sh file below.

CONTAINER_PATCH_URLS=https://gist.githubusercontent.com/yddlef/df54ee1bbca93095a71d75cd15e216eb/raw/plutonium.sh

docker-compose usage

Create the following directory structure containing the docker-compose.yml below.

└── foundry
    ├── data
    └── docker-compose.yml

While in the foundry directiory, start up the container with the command: docker-compose up --detach

See the project README for additional configuration details.

version: "3.8"
services:
foundry:
image: felddy/foundryvtt:release
hostname: my_foundry_host
init: true
restart: "unless-stopped"
volumes:
- type: bind
source: ./data
target: /data
environment:
- CONTAINER_CACHE=/data/container_cache
- CONTAINER_PATCH_URLS=
https://gist.githubusercontent.com/yddlef/df54ee1bbca93095a71d75cd15e216eb/raw/plutonium.sh
- FOUNDRY_PASSWORD=<your_password>
- FOUNDRY_USERNAME=<your_username>
- FOUNDRY_ADMIN_KEY=atr0p0s
ports:
- target: "30000"
published: "30000"
protocol: tcp
mode: host
#!/bin/sh
# This patch script is for use with the felddy/foundryvtt Docker container.
# See: https://github.com/felddy/foundryvtt-docker#readme
# Installs the Plutonium module if it is not yet installed, and then patches the
# Foundry server to call the Plutonium backend.
MAIN_JS="${FOUNDRY_HOME}/resources/app/main.js"
MODULE_BACKEND_JS="/data/Data/modules/plutonium/server/${FOUNDRY_VERSION:0:3}.x/plutonium-backend.js"
MODULE_DIR="/data/Data/modules"
MODULE_URL="https://get.5e.tools/plutonium/plutonium.zip"
MODULE_DOC_URL="https://wiki.5e.tools/index.php/FoundryTool_Install"
SUPPORTED_VERSIONS="0.6.5 0.6.6 0.7.1 0.7.2 0.7.3 0.7.4 0.7.5 0.7.6 0.7.7 0.7.8 0.7.9"
WORKDIR=$(mktemp -d)
ZIP_FILE="${WORKDIR}/plutonium.zip"
log "Installing Plutonium module and backend."
log "See: ${MODULE_DOC_URL}"
if [ -z "${SUPPORTED_VERSIONS##*$FOUNDRY_VERSION*}" ] ; then
log "This patch has been tested with Foundry Virtual Tabletop ${FOUNDRY_VERSION}"
else
log_warn "This patch has not been tested with Foundry Virtual Tabletop ${FOUNDRY_VERSION}"
fi
if [ ! -f $MODULE_BACKEND_JS ]; then
log "Downloading Plutonium module."
curl --output "${ZIP_FILE}" "${MODULE_URL}" 2>&1 | tr "\r" "\n"
log "Ensuring module directory exists."
mkdir -p "${MODULE_DIR}"
log "Installing Plutonium module."
unzip -o "${ZIP_FILE}" -d "${MODULE_DIR}"
fi
log "Installing Plutonium backend."
cp "${MODULE_BACKEND_JS}" "${FOUNDRY_HOME}/resources/app/"
log "Patching main.js to use plutonium-backend."
sed --file=- --in-place=.orig ${MAIN_JS} << SED_SCRIPT
s/^\(require(\"init\").*\);\
/\1.then(() => {require(\"plutonium-backend\").init();});/g\
w plutonium_patchlog.txt
SED_SCRIPT
if [ -s plutonium_patchlog.txt ]; then
log "Plutonium backend patch was applied successfully."
log "Plutonium art and media tools will be enabled."
else
log_error "Plutonium backend patch could not be applied."
log_error "main.js did not contain the expected source lines."
log_warn "Foundry Virtual Tabletop will still operate without the art and media tools enabled."
log_warn "Update this patch file to a version that supports Foundry Virtual Tabletop ${FOUNDRY_VERSION}."
fi
log "Cleaning up."
rm -r ${WORKDIR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment