Add support for including changes to cfggameplay.json, cfgweather.xml, and init.c.

This commit is contained in:
Daniel Ceregatti 2023-11-13 20:19:27 -08:00
parent d9b5c8f293
commit 891096fb82
4 changed files with 92 additions and 22 deletions

View file

@ -14,11 +14,11 @@ This process will create several docker volumes for the following sets of files:
* mods: All mods will be stored here
* homedir: The user home directory. Each container gets its own. Where [SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD) keeps its resource files.
* profiles: A running server's profile. A server container gets its own volume.
* servermpmissions: A running -server's mpmissions directory. A server container gets its own volume.
* servermpmissions: A server's mpmissions directory. A server container gets its own volume.
These volumes can get quite large. The `serverfiles` one will require at least 2.7G of disk space for the default install. The mods one can fill up very quickly, with some map mods being as large as 10G. Make sure you have that much disk space in the location where docker stores its volumes, usually `/var/lib/docker/volumes`.
These volumes can get quite large. The `serverfiles` one will require at least 2.9G of disk space for the default install. The volume holding mods can fill up very quickly, with some map mods being as large as 10G (Deer Isle). Make sure you have that much disk space in the location where docker stores its volumes, usually `/var/lib/docker/volumes`.
This is a work in progress. It's subject to change and break often.
**This is a work in progress. It's subject to change and break often!**
## Configure and Build
@ -248,5 +248,7 @@ Caveat: Some times the server doesn't stop with control c. If that's the case, c
## TODO
* Create web management tool:
* It shells out to `dz` (for now) for all the heavy lifting.
* Create some way to send messages to players on the server using RCON.
* Implement multiple ids for mod commands.
* Implement multiple ids for mod commands. (In progress)

View file

@ -15,29 +15,51 @@ fi
source ${FILES}/mods/${ID}/xml.env
# Iterate over the file names we can handle
for var in CFGENVIRONMENT CFGEVENTSPAWNS CFGSPAWNABLETYPES EVENTS TYPES
for i in cfgenvironment.xml cfgeventspawns.xml cfggameplay.json cfgspawnabletypes.xml cfgweather.xml events.xml init.c types.xml
do
FILE=$(echo ${i} | cut -d. -f1)
TYPE=$(echo ${i} | cut -d. -f2)
UP=${FILE^^}
VAL=${!UP}
DIR="${WORKSHOP_DIR}/${ID}"
OUT="${DIR}/${var,,}.xml"
if echo ${!var} | grep -qE "^http"
OUT="${DIR}/${i}"
if echo ${VAL} | grep -qE "^http"
then
echo "${var} is a URL, downloading to ${OUT}"
curl -so ${OUT} ${!var}
elif echo ${!var} | grep -qE "^local"
echo
echo "${i} is a URL, downloading to ${OUT}"
curl -so ${OUT} ${VAL}
elif echo ${VAL} | 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 "^\./"
echo
echo "${i} comes from mod integration, copying to ${OUT}"
echo -n " "
cp -v "${FILES}/mods/${ID}/${i}" "${OUT}"
elif echo ${VAL} | grep -qE "^\./"
then
echo "${var} comes from the mod as ${!var}, copying to ${OUT}"
cp -v "${DIR}/${!var}" "${OUT}"
echo
echo "${FILE} comes from the mod as ${VAL}, copying to ${OUT}"
echo -n " "
cp -v "${DIR}/${VAL}" "${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}"
)
if [[ ${TYPE} = "xml" ]]
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}"
)
# TODO - validate against schema - https://github.com/rvost/DayZ-Central-Economy-Schema/tree/master
elif [ "${TYPE}" == "json" ]
then
jq -e . ${OUT} > /dev/null || (
echo -e " ${yellow}${OUT} does not pass JSON lint test!${default}"
) && (
echo -e " ${green}${OUT} passes JSON lint test!${default}"
)
fi
fi
done
echo

View file

@ -20,6 +20,7 @@ RUN apt-get update && apt-get -y upgrade && apt-get -y install --no-install-reco
libxml2-utils \
locales \
nano \
patch \
procps \
wget \
xmlstarlet

View file

@ -136,8 +136,15 @@ report() {
mergexml(){
echo
# First copy the pristine files from upstream
echo -e "${green}Copying upstream XML files into local mpmissions for map ${MAP}${default}":
find /mpmissions/${MAP} \( -name "cfgeconomycore.xml" -o -name "cfgeventspawns.xml" -o -name "cfgenvironment.xml" \) -exec cp -v {} ${SERVER_FILES}{} \;
echo -e "${green}Copying upstream files into local mpmissions for map ${MAP}${default}":
find /mpmissions/${MAP} \( \
-name "cfgeconomycore.xml" \
-o -name "cfgenvironment.xml" \
-o -name "cfgeventspawns.xml" \
-o -name "cfggameplay.json" \
-o -name "cfgweather.xml" \
-o -name "init.c" \
\) -exec cp -v {} ${SERVER_FILES}{} \;
# Follow https://community.bistudio.com/wiki/DayZ:Central_Economy_mission_files_modding
# First, remove any existing files, via the mod_ prefix
rm -rf ${MPMISSIONS}/${MAP}/mod_*
@ -198,7 +205,45 @@ mergexml(){
mv /tmp/y ${MPMISSIONS}/${MAP}/${var,,}.xml
fi
done
# These are merged directly into the upstream file, but are JSON
for var in "CFGGAMEPLAY"
do
if [ -f "${WORKSHOP_DIR}/${ID}/${var,,}.json" ]
then
if [[ ${FOUND} = 0 ]]
then
MODNAME=$(get_mod_name ${ID})
echo
echo -e "${green}Adding mod ${MODNAME}${default}"
FOUND=1
fi
echo "Merge JSON '${WORKSHOP_DIR}/${ID}/${var,,}.json' -> '${MPMISSIONS}/${MAP}/${var,,}.json'"
rm -f /tmp/x /tmp/y
jq -s '.[0] * .[1]' ${MPMISSIONS}/${MAP}/${var,,}.json ${WORKSHOP_DIR}/${ID}/${var,,}.json > /tmp/x
mv /tmp/x ${MPMISSIONS}/${MAP}/${var,,}.json
fi
done
# These are merged directly into the upstream file, but are C
for var in "INIT"
do
if [ -f "${WORKSHOP_DIR}/${ID}/${var,,}.c" ]
then
if [[ ${FOUND} = 0 ]]
then
MODNAME=$(get_mod_name ${ID})
echo
echo -e "${green}Adding mod ${MODNAME}${default}"
FOUND=1
fi
echo "Patch '${WORKSHOP_DIR}/${ID}/${var,,}.c(.diff)' -> '${MPMISSIONS}/${MAP}/${var,,}.c'"
patch -s -p0 ${MPMISSIONS}/${MAP}/${var,,}.c < ${WORKSHOP_DIR}/${ID}/${var,,}.c || (
echo "Patch failed!"
exit 1
)
fi
done
done
return
if [ -d ${SERVER_PROFILE}/custom ]
then
# First, remove any existing files, via the custom_ prefix