dayzdockerserver/files/bin/xml.sh
Daniel Ceregatti 788bac39a4 Add entrypoint.sh so we don't have to wait 10 seconds to down our stack.
Make scripts just run from each container's respective bin directory.
Upgrade to node 18.18.2 and nvm 0.39.5.
Remove unnecessary output.
2023-11-03 16:11:11 -07:00

43 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# A generic script that retrieves XML files from mods, either upstream in remote endpoints, or
# locally from the downloaded mod directory, or from project files.
set -eE
ID=${1}
if ! [ -f ${FILES}/mods/${ID}/xml.env ]
then
exit 0
fi
source ${FILES}/mods/${ID}/xml.env
# Iterate over the file names we can handle
for var in CFGENVIRONMENT CFGEVENTSPAWNS CFGSPAWNABLETYPES EVENTS TYPES
do
DIR="${WORKSHOP_DIR}/${ID}"
OUT="${DIR}/${var,,}.xml"
if echo ${!var} | grep -qE "^http"
then
echo "${var} is a URL, downloading to ${OUT}"
curl -so ${OUT} ${!var}
elif echo ${!var} | grep -qE "^local"
then
echo "${var} comes from mod integrations, copying to ${OUT}"
cp -v "${FILES}/mods/${ID}/${var,,}.xml" "${OUT}"
elif echo ${!var} | grep -qE "^\./"
then
echo "${var} comes from the mod as ${!var}, copying to ${OUT}"
cp -v "${DIR}/${!var}" "${OUT}"
fi
if [ -f ${OUT} ]
then
xmllint --noout ${OUT} 2> /dev/null && (
echo -e "${green}${OUT} passes XML lint test!${default}"
) || (
echo -e "${yellow}${OUT} does not pass XML lint test!${default}"
)
fi
done