dayzdockerserver/files/bin/xml.sh
Daniel Ceregatti 212da43d0a Add support for processing local XML files, as some times mods include them.
Add DayZ Bicycle XML integration.
Update docs.
2023-09-05 17:35:17 -07:00

34 lines
872 B
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
set -eE
ID=${1}
source ${FILES}/mods/${ID}/xml.env
# Iterate over the file names we can handle
for var in 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 "^\./"
then
echo "${var} is local, copying to ${OUT}"
cp -v "${DIR}/${!var}" "${OUT}"
fi
if [ -f ${OUT} ]
then
xmllint --noout ${OUT} 2> /dev/null || {
echo -e "${red}${var,,}.xml does not pass XML lint test!${default}"
} && {
echo -e "${green}${var,,}.xml passes XML lint test!${default}"
}
fi
done