47 lines
1.9 KiB
Bash
47 lines
1.9 KiB
Bash
#!/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.mjs"
|
|
MODULE_BACKEND_JS="/data/Data/modules/plutonium/server/${FOUNDRY_VERSION:0:3}.x/plutonium-backend.mjs"
|
|
MODULE_DIR="/data/Data/modules"
|
|
MODULE_URL="https://github.com/TheGiddyLimit/plutonium-next/raw/master/plutonium-foundry10.zip"
|
|
MODULE_DOC_URL="https://wiki.tercept.net/en/Plutonium/Plutonium_Installation"
|
|
WORKDIR=$(mktemp -d)
|
|
ZIP_FILE="${WORKDIR}/plutonium.zip"
|
|
|
|
log "Installing Plutonium module and backend."
|
|
log "See: ${MODULE_DOC_URL}"
|
|
if [ ! -f $MODULE_BACKEND_JS ]; then
|
|
log "Downloading Plutonium module."
|
|
curl -L --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.mjs to use plutonium-backend."
|
|
sed -z --file=- --in-place=.orig ${MAIN_JS} << SED_SCRIPT
|
|
s/\(init\.default({[^}]\+})\)\
|
|
/await \1;\n(await import(".\/plutonium-backend.mjs")).Plutonium.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}
|
|
|