From f6aa92d945e308d2097c90ca91b3cc91cea8e199 Mon Sep 17 00:00:00 2001 From: Daniel Ceregatti Date: Thu, 28 Mar 2024 08:06:19 -0700 Subject: [PATCH] Implement key copying as a factor of starting the server. Only copy extra files from mod integrations, not ones that are handled already. Add 'all' for deactivation argument to allow a quick reset of the mods. Restore generic server name in the config example. Update docs. --- README.md | 8 ++++++-- files/bin/dz-common | 12 ------------ files/serverDZ.cfg | 2 +- server/bin/dz | 40 +++++++++++++++++++++++++++++++++++----- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 02cd794..4e13b07 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,11 @@ A Linux [DayZ](https://dayz.com) server in a [Docker](https://docs.docker.com/) The main goal is to provide a turnkey DayZ server with mod support that can be spun up with as little as a machine running Linux with Docker and Docker Compose installed. -**This is a work in progress!** +# Caveats + +* Some mods are known to crash the server on startup: + * [DayZ Expansion AI](https://steamcommunity.com/sharedfiles/filedetails/?id=2792982069) + * [Red Falcon Flight System Heliz](https://steamcommunity.com/workshop/filedetails/?id=2692979668) ## Configure and Build @@ -52,7 +56,7 @@ The base server files must be installed before the server can be run: docker compose run --rm web dz install ``` -This will download about 2.7G of files. +This will download about 2.9G of files. ## Run diff --git a/files/bin/dz-common b/files/bin/dz-common index c75ca5c..2fa8606 100755 --- a/files/bin/dz-common +++ b/files/bin/dz-common @@ -158,15 +158,3 @@ get_mod_command_line(){ mod_command_line='-mod='${mod_command_line::-1} fi } - -# Copy mod keys -copy_keys(){ - if [[ ${1} = 1 ]] - then - echo -n "Copying key file(s): " - find ${WORKSHOP_DIR}/${2} -name "*.bikey" -exec cp -v {} "${SERVER_FILES}/keys/" \; - else - echo -n "Removing key file(s): " - find ${WORKSHOP_DIR}/${2} -name "*.bikey" -execdir rm -vf "${SERVER_FILES}/keys/{}" \; - fi -} diff --git a/files/serverDZ.cfg b/files/serverDZ.cfg index 771e8d5..bf39dcf 100644 --- a/files/serverDZ.cfg +++ b/files/serverDZ.cfg @@ -1,4 +1,4 @@ -hostname = "DayZ on Linux for Linux"; // Server name +hostname = "Something other than Server Name"; // Server name password = ""; // Password to connect to the server passwordAdmin = ""; // Password to become a server admin diff --git a/server/bin/dz b/server/bin/dz index 939fb90..7f8ddd2 100755 --- a/server/bin/dz +++ b/server/bin/dz @@ -136,7 +136,10 @@ report() { mergexml(){ echo - # First copy the pristine files from upstream + + # Bring all base files into the working directories. + + # Copy the pristine files from upstream echo -e "${green}Copying upstream files into local mpmissions for map ${MAP}${default}": find /mpmissions/${MAP} \( \ -name "cfgeconomycore.xml" \ @@ -148,6 +151,23 @@ mergexml(){ -o -name "init.c" \ \) -exec cp -v {} ${SERVER_FILES}{} \; + echo + + # Remove previously copied keys and restore the default key + echo -e "${green}Resetting keys${default}" + mv ${SERVER_FILES}/keys/dayz.bikey /tmp + rm -rf ${SERVER_FILES}/keys/* + mv /tmp/dayz.bikey ${SERVER_FILES}/keys + + # Copy all active mod keys + for link in $(ls -tdr ${SERVER_PROFILE}/@* 2> /dev/null) + do + ID=$(readlink ${link} | awk -F/ '{print $NF}') + MODNAME=$(get_mod_name ${ID}) + echo -n "Copying key file(s) for mod ${MODNAME}: " + find ${WORKSHOP_DIR}/${ID} -name "*.bikey" -exec cp -v {} "${SERVER_FILES}/keys/" \; + done + # Follow https://community.bistudio.com/wiki/DayZ:Central_Economy_mission_files_modding # Remove any existing files, via the mod_ and custom_ prefixes rm -rf ${MPMISSIONS}/${MAP}/mod_* @@ -329,8 +349,11 @@ mergexml(){ mkdir -p ${MPMISSIONS}/${MAP}/custom_${dir} for file in $(ls ${SERVER_PROFILE}/custom/${dir} 2> /dev/null) do - echo -n "Copy " - cp -av ${SERVER_PROFILE}/custom/${dir}/${file} ${MPMISSIONS}/${MAP}/custom_${dir} + if ! [ -f ${MPMISSIONS}/${MAP}/custom_${dir}/${file} ] + then + echo -n "Additional Copy " + cp -av ${SERVER_PROFILE}/custom/${dir}/${file} ${MPMISSIONS}/${MAP}/custom_${dir} + fi done fi done @@ -447,8 +470,16 @@ activate(){ WW="de" COLOR="${red}" fi + # Check if the first argument is the word 'all' + if [[ ${1} = 'all' ]] + then + Q=$(ls -la ${SERVER_PROFILE}/@* | wc -l) + M=$(seq ${Q} | tac) + else + M="${@}" + fi # Loop over the rest of the argument(s) - for i in ${@} + for i in ${M} do # Get the mod id and name ID=$(get_mod_id ${i} ${W}) @@ -466,7 +497,6 @@ activate(){ else echo -e "Mod id ${ID} - ${COLOR}${MODNAME}${default} - is already ${WW}active" fi - copy_keys ${W} ${ID} echo -e "Mod id ${ID} - ${COLOR}${MODNAME}${default} ${WW}activated" popd > /dev/null done