Add cfgeventspawns.xml integration!

Add quirk to handle upstream XMLs not having the correct nodes.
Add initial map install based on the map in the config.
Add package to allow for XML merging in the server container.
Add an environment variable that prevents the server from starting, to test mod XML integration at server start.
Back up logs into dedicated directories based on the date when the server exits.
Improve logic for copying XML files into mpmissions.
Fix status output formatting.
Get map name from the config at script start in the server script.
Refactor XML env scripts so they don't have a hashbang.
Refactor one mod's integration with the new file naming convention.
This commit is contained in:
Daniel Ceregatti 2023-09-09 11:02:24 -07:00
parent 67cbb8319f
commit b1448d8860
9 changed files with 114 additions and 102 deletions

View file

@ -1,3 +1 @@
#!/usr/bin/env bash
TYPES=./info/bbp_types.xml TYPES=./info/bbp_types.xml

View file

@ -1,9 +1,7 @@
#!/usr/bin/env bash
CFGSPAWNABLETYPES=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Event%20Spawn%20Config/RFFSHelis_cfgspawnabletypes.xml CFGSPAWNABLETYPES=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Event%20Spawn%20Config/RFFSHelis_cfgspawnabletypes.xml
#CFGEVENTSPAWNS=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Event%20Spawn%20Config/Banov/RFFSHelis_cfgeventspawns.xml #CFGEVENTSPAWNS=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Event%20Spawn%20Config/Banov/RFFSHelis_cfgeventspawns.xml
CFGEVENTSPAWNS=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Event%20Spawn%20Config/Chernarus/RFFSHelis_cfgeventspawns.xml #CFGEVENTSPAWNS=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Event%20Spawn%20Config/Chernarus/RFFSHelis_cfgeventspawns.xml
#CFGEVENTSPAWNS=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Event%20Spawn%20Config/DeerIsle/RFFSHelis_cfgeventspawns.xml CFGEVENTSPAWNS=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Event%20Spawn%20Config/DeerIsle/RFFSHelis_cfgeventspawns.xml
#CFGEVENTSPAWNS=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Event%20Spawn%20Config/Namalsk/RFFSHelis_cfgeventspawns.xml #CFGEVENTSPAWNS=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Event%20Spawn%20Config/Namalsk/RFFSHelis_cfgeventspawns.xml
EVENTS=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Event%20Spawn%20Config/RFFSHelis_events.xml EVENTS=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Event%20Spawn%20Config/RFFSHelis_events.xml
TYPES=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Types.XML/RFFSHelis_Types.xml TYPES=https://raw.githubusercontent.com/RedFalconKen/RedFalconFlightSystem-Heliz/main/Config%20Files/Types.XML/RFFSHelis_Types.xml

View file

@ -1 +0,0 @@
TYPES=extras/types/rag_baseitems.xml

View file

@ -0,0 +1 @@
TYPES=./extras/types/rag_baseitems.xml

View file

@ -1,5 +1,3 @@
#!/usr/bin/env bash
CFGSPAWNABLETYPES=https://raw.githubusercontent.com/RedFalconKen/RedFalconWatercraft/main/Config%20Files/Event%20Spawn%20Config/cfgspawnabletypes.xml CFGSPAWNABLETYPES=https://raw.githubusercontent.com/RedFalconKen/RedFalconWatercraft/main/Config%20Files/Event%20Spawn%20Config/cfgspawnabletypes.xml
CFGEVENTSPAWNS=https://github.com/RedFalconKen/RedFalconWatercraft/blob/main/Config%20Files/Event%20Spawn%20Config/DeerIsle/cfgeventspawns.xml CFGEVENTSPAWNS=https://github.com/RedFalconKen/RedFalconWatercraft/blob/main/Config%20Files/Event%20Spawn%20Config/DeerIsle/cfgeventspawns.xml
EVENTS=https://raw.githubusercontent.com/RedFalconKen/RedFalconWatercraft/main/Config%20Files/Event%20Spawn%20Config/events.xml EVENTS=https://raw.githubusercontent.com/RedFalconKen/RedFalconWatercraft/main/Config%20Files/Event%20Spawn%20Config/events.xml

View file

@ -1,5 +1,3 @@
#!/usr/bin/env bash
CFGSPAWNABLETYPES=./spawnabletypes.xml CFGSPAWNABLETYPES=./spawnabletypes.xml
CFGEVENTSPAWNS=./cfgeventspawns_chernarus.xml CFGEVENTSPAWNS=./cfgeventspawns_chernarus.xml
#EVENTS=events.xml #EVENTS=events.xml

View file

@ -13,6 +13,7 @@ RUN apt-get update && apt-get -y upgrade && apt-get -y install --no-install-reco
curl \ curl \
ca-certificates \ ca-certificates \
git \ git \
gwenhywfar-tools \
jq \ jq \
libsdl2-2.0-0 \ libsdl2-2.0-0 \
libcap2 \ libcap2 \

View file

@ -110,6 +110,10 @@ EOF
# Make sure to clean up and report on exit, as these files remain in the container's volume # Make sure to clean up and report on exit, as these files remain in the container's volume
report() { report() {
if [[ ${DONT_START} != "" ]]
then
exit 0
fi
rm -f /tmp/mod_command_line /tmp/parameters rm -f /tmp/mod_command_line /tmp/parameters
echo echo
echo -e "${yellow}========================================== error.log ==========================================" echo -e "${yellow}========================================== error.log =========================================="
@ -122,106 +126,112 @@ report() {
find "${SERVER_PROFILE}" -name "*.RPT" -exec ls -la {} \; -exec tail -n 30 {} \; -exec rm -f {} \; find "${SERVER_PROFILE}" -name "*.RPT" -exec ls -la {} \; -exec tail -n 30 {} \; -exec rm -f {} \;
echo echo
echo -e "========================================== End log ======================================${default}" 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)"
mkdir -p ${DIR}
cd ${SERVER_PROFILE}
mv -v *.log *.RPT *.mdmp ${DIR} 2> /dev/null
} }
mergexml(){ mergexml(){
# First copy the pristine files from upstream echo
for i in cfgeconomycore.xml #cfgeventspawns.xml # First copy the pristine files from upstream
do echo -e "${green}Copying upstream XML files into local mpmissions for map ${MAP}${default}":
echo "Copying pristine version of ${i} into local mpmission ${MAP}..." find /mpmissions/${MAP} \( -name "cfgeconomycore.xml" -o -name "cfgeventspawns.xml" \) -exec cp -v {} ${SERVER_FILES}{} \;
for dir in $(ls -d ${MPMISSIONS}/*) # Follow https://community.bistudio.com/wiki/DayZ:Central_Economy_mission_files_modding
do # First, remove any existing files, via the mod_ prefix
if [[ ${dir} != ${MAP} ]] rm -rf ${MPMISSIONS}/${MAP}/mod_*
then for link in $(ls -tdr ${SERVER_PROFILE}/@* 2> /dev/null)
continue do
fi ID=$(readlink ${link} | awk -F/ '{print $NF}')
find /mpmissions/$(basename ${dir}) -name ${i} -exec cp -v {} ${SERVER_FILES}{} \; # Going to have to maintain a matrix of file names -> root node -> child node permutations
done C=""
done FOUND=0
for i in "CFGSPAWNABLETYPES:spawnabletypes:type" "EVENTS:events:event" "TYPES:types:type"
# Follow https://community.bistudio.com/wiki/DayZ:Central_Economy_mission_files_modding and make a single XML do
# file for the ones that can go into it. var=$(echo ${i} | cut -d: -f1)
for link in $(ls -tdr ${SERVER_PROFILE}/@* 2> /dev/null) CHECK=$(echo ${i} | cut -d: -f2)
do CHILD=$(echo ${i} | cut -d: -f3)
ID=$(readlink ${link} | awk -F/ '{print $NF}') if [ -f "${WORKSHOP_DIR}/${ID}/${var,,}.xml" ]
# Going to have to maintain a matrix of file names -> root node -> child node permutations then
C="" if [[ ${FOUND} = 0 ]]
FOUND=0 then
for i in "CFGSPAWNABLETYPES:spawnabletypes:type" "EVENTS:events:event" "TYPES:types:type" MODNAME=$(get_mod_name ${ID})
do echo
var=$(echo ${i} | cut -d: -f1) echo -e "${green}Adding mod ${MODNAME}${default}"
CHECK=$(echo ${i} | cut -d: -f2) FOUND=1
CHILD=$(echo ${i} | cut -d: -f3) fi
if [ -f "${WORKSHOP_DIR}/${ID}/${var,,}.xml" ] echo -n "Copy "
then mkdir -p ${MPMISSIONS}/${MAP}/mod_${ID}
if [[ ${FOUND} = 0 ]] cp -v ${WORKSHOP_DIR}/${ID}/${var,,}.xml ${MPMISSIONS}/${MAP}/mod_${ID}/${var,,}.xml
then 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 "
MODNAME=$(get_mod_name ${ID}) fi
echo " Adding mod ${MODNAME}" done
FOUND=1 if [[ ${C} != "" ]]
fi then
echo -n " " # Merge into the current mpmissions file
for dir in $(ls ${MPMISSIONS}) echo "Create new XML node <ce folder=\"mod_${ID}\"> -> ${MPMISSIONS}/${MAP}/cfgeconomycore.xml"
do find ${MPMISSIONS}/${MAP} -name cfgeconomycore.xml -exec \
# Only copy for the current map xmlstarlet ed -L -s / -t elem -n ce \
if [[ ${dir} != ${MAP} ]] -a /ce -t attr -n folder -v "mod_${ID}" ${C} \
then -m /ce /economycore {} \;
continue fi
fi # These are merged directly into the upstream file
rm -rf ${MPMISSIONS}/${dir}/${ID} for i in "CFGEVENTSPAWNS:eventposdef:event"
mkdir -p ${MPMISSIONS}/${dir}/${ID} do
cp -v ${WORKSHOP_DIR}/${ID}/${var,,}.xml ${MPMISSIONS}/${dir}/${ID}/${var,,}.xml var=$(echo ${i} | cut -d: -f1)
done CHECK=$(echo ${i} | cut -d: -f2)
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 " CHILD=$(echo ${i} | cut -d: -f3)
fi if [ -f "${WORKSHOP_DIR}/${ID}/${var,,}.xml" ]
done then
if [[ ${C} != "" ]] echo "Merge XML ${WORKSHOP_DIR}/${ID}/${var,,}.xml -> ${MPMISSIONS}/${MAP}/${var,,}.xml"
then rm -f /tmp/x /tmp/y
# Merge into every mpmissions file xmlmerge -o /tmp/x ${WORKSHOP_DIR}/${ID}/${var,,}.xml ${MPMISSIONS}/${MAP}/${var,,}.xml
find ${MPMISSIONS} -name cfgeconomycore.xml -exec \ xmlstarlet fo /tmp/x > /tmp/y
xmlstarlet ed -L -s / -t elem -n ce \ # Ensure the XML is valid
-a /ce -t attr -n folder -v "${ID}" \ xmllint --noout /tmp/y || (
${C} \ echo
-m /ce /economycore {} \; echo "Merged XML file ${MPMISSIONS}/${MAP}/${var,,}.xml is not valid! Can't continue!"
fi echo
# These still have to be merged into the upstream file exit 1
# for i in "CFGEVENTSPAWNS:eventposdef:event" )
# do mv /tmp/y ${MPMISSIONS}/${MAP}/${var,,}.xml
# var=$(echo ${i} | cut -d: -f1) fi
# CHECK=$(echo ${i} | cut -d: -f2) done
# CHILD=$(echo ${i} | cut -d: -f3) done
# if [ -f "${WORKSHOP_DIR}/${ID}/${var,,}.xml" ]
# then
# echo "Merging ${var,,}.xml (Not really...WIP)"
# xmlstarlet ed -L -s / -t name event
# fi
# done
done
} }
# Start the server in the foreground # Start the server in the foreground
start(){ start(){
# Ensure mpmissions has at least one map. If not, copy it from the local read-only volume that stores pristine mpmissons directories # Ensure mpmissions has at least one map. If not, copy it from the local read-only volume that stores pristine mpmissons directories
if [ ! -d "${MPMISSIONS}/dayzOffline.chernarusplus" ] if [ ! -d "${MPMISSIONS}/${MAP}" ]
then then
echo echo
echo "Performing one-time copy of Chernarus mpmissions..." echo "Performing one-time copy of ${MAP} mpmissions..."
echo echo
cp -av /mpmissions/dayzOffline.chernarusplus ${MPMISSIONS} cp -av /mpmissions/${MAP} ${MPMISSIONS}
fi fi
# If we're developing, just block the container # If we're developing, just block the container
if [[ ${DEVELOPMENT} = "1" ]] if [[ ${DEVELOPMENT} = "1" ]]
then then
echo "DEVELOPMENT mode, blocking..." echo "DEVELOPMENT mode, blocking. Unset DEVELOPMENT in the current environment to run the server."
tail -f /dev/null tail -f /dev/null
exit 0 exit 0
fi fi
# Do the report on exit. Set here so that it only happens once we're starting the server, and not for other actions. # Do the report on exit. Set here so that it only happens once we're starting the server, and not for other actions.
trap ' trap '
report report
' EXIT ' EXIT
get_mods get_mods
mergexml mergexml
if [[ ${DONT_START} != "" ]]
then
echo
echo "Not starting server, as DONT_START is set"
echo
exit 0
fi
echo
cd ${SERVER_FILES} cd ${SERVER_FILES}
# Run the server. Allow docker to restart the container if the script exits with a code other than 0. This is so we can # Run the server. Allow docker to restart the container if the script exits with a code other than 0. This is so we can
# safely shut the container down without killing the server within. # safely shut the container down without killing the server within.
@ -322,7 +332,7 @@ rcon(){
activelist(){ activelist(){
X=1 X=1
C="${green}" C="${green}"
spaces=" " spaces=" "
have=no have=no
for link in $(ls -tdr ${SERVER_PROFILE}/@* 2> /dev/null) for link in $(ls -tdr ${SERVER_PROFILE}/@* 2> /dev/null)
do do
@ -335,7 +345,7 @@ activelist(){
ID=$(readlink ${link} | awk -F/ '{print $NF}') ID=$(readlink ${link} | awk -F/ '{print $NF}')
MODNAME=$(get_mod_name ${ID}) MODNAME=$(get_mod_name ${ID})
SIZE=$(du -sh "${WORKSHOP_DIR}/${ID}" | awk '{print $1}') SIZE=$(du -sh "${WORKSHOP_DIR}/${ID}" | awk '{print $1}')
printf "${C}%.3d %s %.23s %s https://steamcommunity.com/sharedfiles/filedetails/?id=%s %s${default}\n" ${X} ${ID} "${MODNAME}" "${spaces:${#MODNAME}+1}" ${ID} ${SIZE} printf "${C}%.3d %s %.30s %s https://steamcommunity.com/sharedfiles/filedetails/?id=%s %s${default}\n" ${X} ${ID} "${MODNAME}" "${spaces:${#MODNAME}+1}" ${ID} ${SIZE}
X=$((X+1)) X=$((X+1))
done done
if [[ ${have} = "no" ]] if [[ ${have} = "no" ]]
@ -379,7 +389,7 @@ status(){
# Current parameters # Current parameters
RUNNING="${RUNNING}\nRunning Parameters: $(cat /tmp/parameters)\nRunning mod parameter: $(cat /tmp/mod_command_line)" RUNNING="${RUNNING}\nRunning Parameters: $(cat /tmp/parameters)\nRunning mod parameter: $(cat /tmp/mod_command_line)"
fi fi
MAP=$(get_map_name) MAP=${MAP}
# Number of mods plus the list denoting on or off # Number of mods plus the list denoting on or off
echo -ne " echo -ne "
Server files installed: ${INSTALLED}" Server files installed: ${INSTALLED}"
@ -399,7 +409,6 @@ Working parameters: ${parameters}
Working mod parameter: ${mod_command_line}" Working mod parameter: ${mod_command_line}"
if [[ "${INSTALLED}" = "${YES}" ]] if [[ "${INSTALLED}" = "${YES}" ]]
then then
MAP=$(grep template ${SERVER_CFG_DST} | grep -v "^//" | cut -d= -f2 | cut -d\; -f1)
echo "Map: ${MAP}" echo "Map: ${MAP}"
fi fi
echo echo

View file

@ -61,6 +61,16 @@ installxml(){
then then
echo "Normalizing ${WORKSHOP_DIR}/${ID}/${var,,}.xml..." echo "Normalizing ${WORKSHOP_DIR}/${ID}/${var,,}.xml..."
cp ${WORKSHOP_DIR}/${ID}/${var,,}.xml /tmp/x cp ${WORKSHOP_DIR}/${ID}/${var,,}.xml /tmp/x
# Quirks
# Some cfgeventspanws.xml files have <events> instead of <eventposdef>. Let's just try to fix that first.
if [[ ${var} = "CFGEVENTSPAWNS" ]]
then
if grep -q '<events>' /tmp/x
then
echo " - (Quirk) has <events> instead of <eventposdef>. fixing..."
xmlstarlet ed -L -r "events" -v "eventposdef" /tmp/x
fi
fi
if ! grep -q '<'${CHECK}'>' /tmp/x if ! grep -q '<'${CHECK}'>' /tmp/x
then then
echo " - has no root node <${CHECK}>. fixing..." echo " - has no root node <${CHECK}>. fixing..."