From 9513fc4d97693c1ea735142b3d7f99e34195bafd Mon Sep 17 00:00:00 2001 From: Daniel Ceregatti Date: Thu, 28 Sep 2023 15:39:13 -0700 Subject: [PATCH] Add support for custom integrations. The first is no food, which makes a new types.xml of all the food class items for use with CE, then sets nominal to 0 in all entries. Have server logs go into a logs directory, with sub-directories in there with the date to contain that run's logs. Fix XML handling output. Update bogus DayZ version. Add custom integration docs. --- files/bin/xml.sh | 4 ++-- files/custom/README.md | 36 +++++++++++++++++++++++++++++++++++- server/bin/dz | 40 +++++++++++++++++++++++++++++++++++++++- web/web.js | 2 +- 4 files changed, 77 insertions(+), 5 deletions(-) diff --git a/files/bin/xml.sh b/files/bin/xml.sh index 796ebb6..3c6f1bc 100755 --- a/files/bin/xml.sh +++ b/files/bin/xml.sh @@ -35,9 +35,9 @@ do if [ -f ${OUT} ] then xmllint --noout ${OUT} 2> /dev/null && ( - echo -e "${green}${OUT}.xml passes XML lint test!${default}" + echo -e "${green}${OUT} passes XML lint test!${default}" ) || ( - echo -e "${yellow}${OUT}.xml does not pass XML lint test!${default}" + echo -e "${yellow}${OUT} does not pass XML lint test!${default}" ) fi done diff --git a/files/custom/README.md b/files/custom/README.md index ede72a6..0b11996 100644 --- a/files/custom/README.md +++ b/files/custom/README.md @@ -2,6 +2,35 @@ ## These are the custom integrations possible with dayzdockerserver +### Lowered login/logout time + +To lower the login/logout time from the default 15 seconds. + +Go into the server container: + +```shell +docker compose exec server bash +``` + +Make a new directory in /profiles/custom called login and go into it: + +```shell +mkdir -p /profiles/custom/login +cd /profiles/custom/login +``` + +Generate a globals.xml with the changed values: + +```shell +cat > globals.xml << EOF + + + + + +EOF +``` + ### No food For a more survival-oriented experience, one can prevent food from spawning in the world, forcing players to hunt and fish for food. @@ -26,12 +55,17 @@ xmlstarlet ed \ -s / -t elem -n food \ -m "/types/type[category[contains(@name, 'food')]]" "/food" \ -d /types \ - -r /food -v /types \ + -r food -v types \ -u //nominal -v 0 \ /serverfiles/mpmissions/dayzOffline.chernarusplus/db/types.xml \ > types.xml ``` +Always lint any XML file that is created/merged: +```shell +xmllint --noout types.xml +``` + Explanation: * Start xmlstarlet in edit mode * Add a new XML node at the root named "food" diff --git a/server/bin/dz b/server/bin/dz index 0c4e3b6..170bbe9 100755 --- a/server/bin/dz +++ b/server/bin/dz @@ -127,7 +127,7 @@ report() { echo echo -e "========================================== End log ======================================${default}" # Back these files up into a new directory with the current time stamp in the name - DIR="${SERVER_PROFILE}/logs-$(date +%Y-%m-%d-%H-%M-%S)" + DIR="${SERVER_PROFILE}/logs/$(date +%Y-%m-%d-%H-%M-%S)" mkdir -p ${DIR} cd ${SERVER_PROFILE} mv -v *.log *.RPT *.mdmp ${DIR} 2> /dev/null @@ -199,6 +199,44 @@ mergexml(){ fi done done + if [ -d ${SERVER_PROFILE}/custom ] + then + # First, remove any existing files, via the custom_ prefix + rm -rf ${MPMISSIONS}/${MAP}/custom_* + for dir in $(ls ${SERVER_PROFILE}/custom 2> /dev/null) + do + FOUND=0 + C="" + for i in "CFGSPAWNABLETYPES:spawnabletypes:type" "EVENTS:events:event" "TYPES:types:type" "GLOBALS:globals:var" + do + var=$(echo ${i} | cut -d: -f1) + CHECK=$(echo ${i} | cut -d: -f2) + CHILD=$(echo ${i} | cut -d: -f3) + if [ -f "${SERVER_PROFILE}/custom/${dir}/${var,,}.xml" ] + then + if [[ ${FOUND} = 0 ]] + then + echo + echo -e "${green}Adding custom integration ${dir}${default}" + FOUND=1 + fi + mkdir -p ${MPMISSIONS}/${MAP}/custom_${dir} + echo -n "Copy " + cp -v ${SERVER_PROFILE}/custom/${dir}/${var,,}.xml ${MPMISSIONS}/${MAP}/custom_${dir}/${var,,}.xml + C+="-s / -t elem -n file -a /file -t attr -n name -v ${var,,}.xml -a /file -t attr -n type -v ${CHECK} -m /file /ce " + fi + done + if [[ ${C} != "" ]] + then + # Merge into the current mpmissions file + echo "Create new XML node -> ${MPMISSIONS}/${MAP}/cfgeconomycore.xml" + find ${MPMISSIONS}/${MAP} -name cfgeconomycore.xml -exec \ + xmlstarlet ed -L -s / -t elem -n ce \ + -a /ce -t attr -n folder -v "custom_${dir}" ${C} \ + -m /ce /economycore {} \; + fi + done + fi } # Start the server in the foreground diff --git a/web/web.js b/web/web.js index 22682a9..ccecf74 100644 --- a/web/web.js +++ b/web/web.js @@ -122,7 +122,7 @@ const config = { const getVersion = (installed) => { if(installed) { - return "1.21.bogus" + return "1.22.bogus" } return "" }