There are no mpmissions in the server container when it starts for the first time. Ensure Chernarus is copied over as a default when this is detected, as the server is expected to start successfully. Presumes a default config where the map hasn't been changed.

Make development work by setting an environment variable.
Set the web container to restart instead of not, should the express server crash.
Copy XML files that are merged when the server  starts only when the mpmissions directory exists.
Refactor XML functions for better naming.
Handle display of lists when no mods are installed.
Add support for adding mpmissions for Deer Isle and mpmissions in general via mod integrations.
Add support for Red Falcon Watercraft XML files. WIP.
Add a deer isle DayZ bicycle spawn file.
This commit is contained in:
Daniel Ceregatti 2023-09-07 12:08:12 -07:00
parent 5db38636c4
commit 887374587d
7 changed files with 102 additions and 75 deletions

View file

@ -32,7 +32,7 @@ services:
ports:
- "8001:8001/tcp"
- "8000:8000/tcp"
restart: no
restart: always
environment:
# The use of the Steam API in the (very incomplete) web app requires a key. Get yours here: https://steamcommunity.com/dev/apikey
- STEAMAPIKEY=YOUR_STEAM_API_KEY_HERE
@ -63,11 +63,15 @@ services:
# - 27016:27016/udp
# Always restart, unless stopped
restart: unless-stopped
environment:
# To prevent the server from starting to allow for development, set this to 1
- DEVELOPMENT=0
# Allows attaching a debugger from the host
cap_add:
- SYS_PTRACE
# cap_add:
# - SYS_PTRACE
# Allows core files to be created within the container. These are VERY LARGE! Enable only for debugging!
ulimits:
core:
soft: -1
hard: -1
# One must also set the sysctl kernel.core_pattern parameter ON THE HOST to a path that is writable within the container. YMMV
# ulimits:
# core:
# soft: -1
# hard: -1

View file

@ -69,11 +69,16 @@ list(){
X=1
C="${green}"
spaces=" "
FIRST=1
for link in $(ls -d ${SERVER_FILES}/@* 2> /dev/null | sort)
do
if [[ ${FIRST} = 1 ]]
then
echo
echo -e " ID Name URL Size"
echo "------------------------------------------------------------------------------------------------------------------------"
for link in $(ls -d ${SERVER_FILES}/@* | sort)
do
FIRST=0
fi
ID=$(readlink ${link} | awk -F/ '{print $NF}')
MODNAME=$(get_mod_name ${ID})
SIZE=$(du -sh "${WORKSHOP_DIR}/${ID}" | awk '{print $1}')

View file

@ -2,27 +2,27 @@
set -eE
if [ -f /files/mods/${1}/install.env ]
then
source /files/mods/${1}/install.env
else
echo "install.env not found for mod id ${1}..."
exit 1
fi
echo
if [[ ${2} = "uninstall" ]]
then
echo "Backing up, as uninstalling will remove the ${MAP} mpmissions directory"
dayzserver backup
echo "Uninstalling mpmissions..."
echo
dz backup
rm -rf ${SERVER_FILES}/mpmissions/${MPDIR}
elif [[ ${2} = "update" ]]
then
echo "Updating mpmissions directory..."
echo
cd /tmp
git clone ${REPO} 2> /dev/null 1> /dev/null
cp -a ${DIR}/${MPDIR} ${SERVER_FILES}/mpmissions
rm -rf ${DIR}
else
echo "Installing mpmissions files..."
echo
elif [[ ${2} = "install" ]]
then
cd /tmp
git clone ${REPO} 2> /dev/null 1> /dev/null
cp -a ${DIR}/${MPDIR} ${SERVER_FILES}/mpmissions

View file

@ -7,6 +7,11 @@ set -eE
ID=${1}
if ! [ -f ${FILES}/mods/${ID}/xml.env ]
then
exit 0
fi
source ${FILES}/mods/${ID}/xml.env
# Iterate over the file names we can handle

View file

@ -126,9 +126,15 @@ report() {
mergexml(){
# First copy the pristine files from upstream
echo "Copying pristine versions of cfgeconomycore.xml and cfgeventspawns.xml..."
find /mpmissions -name cfgeconomycore.xml -exec cp -v {} ${SERVER_FILES}{} \;
# find /mpmissions -name cfgeventspawns.xml -exec cp {} ${SERVER_FILES}{} \;
for i in cfgeconomycore.xml #cfgeventspawns.xml
do
echo "Copying pristine version of ${i} into local mpmission(s)..."
for dir in $(ls -d ${MPMISSIONS}/*)
do
#echo "dir: ${dir}, basename: $(basename ${dir})"
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.
@ -180,13 +186,20 @@ mergexml(){
# Start the server in the foreground
start(){
# Ensure mpmissions has at least one map. If not, block the server from starting
# 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" ]
then
echo
echo "Performing one-time copy of Chernarus mpmissions..."
echo
cp -a /mpmission/dayzOffline.chernarusplus ${MPMISSIONS}
cp -av /mpmissions/dayzOffline.chernarusplus ${MPMISSIONS}
fi
# If we're developing, just block the container
if [[ ${DEVELOPMENT} = "1" ]]
then
echo "DEVELOPMENT mode, blocking..."
tail -f /dev/null
exit 0
fi
# Do the report on exit. Set here so that it only happens once we're starting the server, and not for other actions.
trap '
@ -422,9 +435,6 @@ case "${C}" in
n|rcon)
rcon "${@}"
;;
r|remove)
remove "${@}"
;;
r|restart)
restart "${@}"
;;

View file

@ -1,14 +1,11 @@
#!/usr/bin/env bash
# Set PS1 so we know we're in the container
# Set PS1 so we know we're in the container, should we exec into it.
cat > .bashrc <<EOF
alias ls='ls --color'
export PS1="${debian_chroot:+($debian_chroot)}\u@dz-server:\w\$ "
EOF
# Uncomment the line below to run things manually in the container, then run:
# docker compose exec main bash, and from within the container: dz start (or do whatever)
#tail -f /dev/null
# Otherwise, start the server normally
# Start the server.
# If the DEVELOPMENT environment variable is set to 1, the container will just block and not start the server.
dz start

View file

@ -26,6 +26,7 @@ Options and arguments:
i|install - Install the DayZ server files
g|login - Login to Steam.
m|modupdate - Update the mod files
p|map id - Install a mod's mpmissions files by id. (Presumes template exists)
r|remove id - Remove all files and directories of a Workshop item by id
s|status - Shows Steam login status, if base files are installed, installed mods
u|update - Update the server files
@ -110,7 +111,7 @@ add(){
# Lower case all the files in mod directories.
find "${WORKSHOP_DIR}/${1}" -depth -exec rename -f 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \;
echo -e "Mod id ${1} - ${green}${MODNAME}${default} - added"
installxml ${ID}
xml ${ID}
}
# Remove a mod
@ -241,7 +242,6 @@ modupdate(){
status(){
INSTALLED="${NO}"
LOGGED_IN="${NO}"
RUNNING="${NO}"
# DayZ Server files installation
if [ -f "${SERVER_INSTALL_FILE}" ]
@ -274,31 +274,34 @@ Mods: "
MODS=$(list)
if [[ ${MODS} == "" ]]
then
echo -n "none"
echo -ne "${red}none${default}"
fi
echo -e "${MODS}"
}
check_mod_install(){
# See if this mod id exists in files/mods, and offer to install other server side files if an install.sh is found
map(){
# Install map mpmissions for mods that have them. Presumes a map.env was created for the mod, with the required metadata (git URL, etc.)
if [ -f ${FILES}/mods/${1}/install.env ]
then
echo "Installing mpmissions files for mod id ${1}..."
source ${FILES}/mods/${1}/install.env
${FILES}/bin/install.sh ${1} install
fi
}
mod_install(){
if [ -f ${FILES}/mods/${1}/${2}.sh ]
then
echo "An ${2}.sh was found for mod id ${1}. Running..."
${FILES}/mods/${1}/${2}.sh
fi
# A generic map install script. Presumes a git repo as the source
if [ -f ${FILES}/mods/${1}/install.env ]
then
echo "An ${2}.env was found for mod id ${1}. Performing ${2}..."
source ${FILES}/mods/${1}/install.env
${FILES}/mods/install.sh ${1} ${2}
fi
}
# "Manage" XML files.
xml(){
/files/bin/xml.sh ${1}
installxml ${1}
#installxml ${1}
}
# Capture the first argument and shift it off so we can pass $@ to every function
@ -326,6 +329,9 @@ case "${C}" in
l|s|status)
status "${@}"
;;
p|map)
map "${@}"
;;
u|update)
update "${@}"
;;