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,25 +126,21 @@ 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(){
echo
# First copy the pristine files from upstream # First copy the pristine files from upstream
for i in cfgeconomycore.xml #cfgeventspawns.xml echo -e "${green}Copying upstream XML files into local mpmissions for map ${MAP}${default}":
do find /mpmissions/${MAP} \( -name "cfgeconomycore.xml" -o -name "cfgeventspawns.xml" \) -exec cp -v {} ${SERVER_FILES}{} \;
echo "Copying pristine version of ${i} into local mpmission ${MAP}..." # Follow https://community.bistudio.com/wiki/DayZ:Central_Economy_mission_files_modding
for dir in $(ls -d ${MPMISSIONS}/*) # First, remove any existing files, via the mod_ prefix
do rm -rf ${MPMISSIONS}/${MAP}/mod_*
if [[ ${dir} != ${MAP} ]]
then
continue
fi
find /mpmissions/$(basename ${dir}) -name ${i} -exec cp -v {} ${SERVER_FILES}{} \;
done
done
# Follow https://community.bistudio.com/wiki/DayZ:Central_Economy_mission_files_modding and make a single XML
# file for the ones that can go into it.
for link in $(ls -tdr ${SERVER_PROFILE}/@* 2> /dev/null) for link in $(ls -tdr ${SERVER_PROFILE}/@* 2> /dev/null)
do do
ID=$(readlink ${link} | awk -F/ '{print $NF}') ID=$(readlink ${link} | awk -F/ '{print $NF}')
@ -157,62 +157,64 @@ mergexml(){
if [[ ${FOUND} = 0 ]] if [[ ${FOUND} = 0 ]]
then then
MODNAME=$(get_mod_name ${ID}) MODNAME=$(get_mod_name ${ID})
echo " Adding mod ${MODNAME}" echo
echo -e "${green}Adding mod ${MODNAME}${default}"
FOUND=1 FOUND=1
fi fi
echo -n " " echo -n "Copy "
for dir in $(ls ${MPMISSIONS}) mkdir -p ${MPMISSIONS}/${MAP}/mod_${ID}
do cp -v ${WORKSHOP_DIR}/${ID}/${var,,}.xml ${MPMISSIONS}/${MAP}/mod_${ID}/${var,,}.xml
# Only copy for the current map
if [[ ${dir} != ${MAP} ]]
then
continue
fi
rm -rf ${MPMISSIONS}/${dir}/${ID}
mkdir -p ${MPMISSIONS}/${dir}/${ID}
cp -v ${WORKSHOP_DIR}/${ID}/${var,,}.xml ${MPMISSIONS}/${dir}/${ID}/${var,,}.xml
done
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 " 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 fi
done done
if [[ ${C} != "" ]] if [[ ${C} != "" ]]
then then
# Merge into every mpmissions file # Merge into the current mpmissions file
find ${MPMISSIONS} -name cfgeconomycore.xml -exec \ echo "Create new XML node <ce folder=\"mod_${ID}\"> -> ${MPMISSIONS}/${MAP}/cfgeconomycore.xml"
find ${MPMISSIONS}/${MAP} -name cfgeconomycore.xml -exec \
xmlstarlet ed -L -s / -t elem -n ce \ xmlstarlet ed -L -s / -t elem -n ce \
-a /ce -t attr -n folder -v "${ID}" \ -a /ce -t attr -n folder -v "mod_${ID}" ${C} \
${C} \
-m /ce /economycore {} \; -m /ce /economycore {} \;
fi fi
# These still have to be merged into the upstream file # These are merged directly into the upstream file
# for i in "CFGEVENTSPAWNS:eventposdef:event" for i in "CFGEVENTSPAWNS:eventposdef:event"
# do do
# var=$(echo ${i} | cut -d: -f1) var=$(echo ${i} | cut -d: -f1)
# CHECK=$(echo ${i} | cut -d: -f2) CHECK=$(echo ${i} | cut -d: -f2)
# CHILD=$(echo ${i} | cut -d: -f3) CHILD=$(echo ${i} | cut -d: -f3)
# if [ -f "${WORKSHOP_DIR}/${ID}/${var,,}.xml" ] if [ -f "${WORKSHOP_DIR}/${ID}/${var,,}.xml" ]
# then then
# echo "Merging ${var,,}.xml (Not really...WIP)" echo "Merge XML ${WORKSHOP_DIR}/${ID}/${var,,}.xml -> ${MPMISSIONS}/${MAP}/${var,,}.xml"
# xmlstarlet ed -L -s / -t name event rm -f /tmp/x /tmp/y
# fi xmlmerge -o /tmp/x ${WORKSHOP_DIR}/${ID}/${var,,}.xml ${MPMISSIONS}/${MAP}/${var,,}.xml
# done xmlstarlet fo /tmp/x > /tmp/y
# Ensure the XML is valid
xmllint --noout /tmp/y || (
echo
echo "Merged XML file ${MPMISSIONS}/${MAP}/${var,,}.xml is not valid! Can't continue!"
echo
exit 1
)
mv /tmp/y ${MPMISSIONS}/${MAP}/${var,,}.xml
fi
done
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
@ -222,6 +224,14 @@ start(){
' 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.
@ -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..."