From 2f1509fb65e617ee96eeaaf7fe41b09ab34a3148 Mon Sep 17 00:00:00 2001 From: Daniel Ceregatti Date: Wed, 19 Jun 2024 16:59:33 -0700 Subject: [PATCH] Change the default maps to always come from github. One used to be able to install the server using the anonymous steam user, but now the mpmissions aren't included if the anonymous user is used. Handle multiple env files for now while we transition server orchestration entirely to the web container. Add MuchStuffPack mod integration. Add git to the web container so we can checkout server resources from github as git. Allows us to just pull on git to keep up to date. --- .gitignore | 2 +- files/bin/map.sh | 35 +++++++++++++++++++++-------------- files/mods/1991570984/xml.env | 1 + files/mods/@MuchStuffPack | 1 + files/mods/enoch/map.env | 6 ++++++ web/Dockerfile | 1 + web/bin/dz | 19 ++++++++++++------- 7 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 files/mods/1991570984/xml.env create mode 120000 files/mods/@MuchStuffPack create mode 100644 files/mods/enoch/map.env diff --git a/.gitignore b/.gitignore index 0d7d73e..52906c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .idea *.iml -.env +.env* node_modules/ diff --git a/files/bin/map.sh b/files/bin/map.sh index a5c1c89..7b53124 100755 --- a/files/bin/map.sh +++ b/files/bin/map.sh @@ -2,11 +2,17 @@ set -eE -if [ -f /files/mods/${1}/map.env ] +TERM="map" +if [[ ${1} =~ ^[0-9]+$ ]] then - source /files/mods/${1}/map.env + TERM="mod id" +fi + +if [ -f "/files/mods/${1}/map.env" ] +then + source "/files/mods/${1}/map.env" else - echo "map.env not found for mod id ${1}..." + echo "map.env not found for ${TERM} ${1}..." exit 1 fi @@ -14,17 +20,18 @@ if [[ ${2} = "uninstall" ]] then echo "Backing up, as uninstalling will remove the ${MAP} mpmissions directory" dz backup - rm -rf ${SERVER_FILES}/mpmissions/${MPDIR} -elif [[ ${2} = "update" ]] + rm -rf "${SERVER_FILES}/mpmissions/${MPDIR}" +elif [[ ${2} = "update" ]] || [[ ${2} = "install" ]] then cd /tmp - git clone ${REPO} 2> /dev/null 1> /dev/null - cp -a ${DIR}/${MPDIR} ${SERVER_FILES}/mpmissions - rm -rf ${DIR} -elif [[ ${2} = "install" ]] -then - cd /tmp - git clone ${REPO} 2> /dev/null 1> /dev/null - cp -a ${DIR}/${MPDIR} ${SERVER_FILES}/mpmissions - rm -rf ${DIR} + if [ -d "${DIR}" ] + then + pushd "${DIR}" > /dev/null + git pull + popd > /dev/null + else + git clone "${REPO}" + fi + rm -rf "${SERVER_FILES}/mpmissions/${MPDIR}" + cp -a "${DIR}/${MPDIR}" "${SERVER_FILES}/mpmissions" fi diff --git a/files/mods/1991570984/xml.env b/files/mods/1991570984/xml.env new file mode 100644 index 0000000..d6bf0b7 --- /dev/null +++ b/files/mods/1991570984/xml.env @@ -0,0 +1 @@ +TYPES=./extras/msp_types.xml \ No newline at end of file diff --git a/files/mods/@MuchStuffPack b/files/mods/@MuchStuffPack new file mode 120000 index 0000000..edabe1a --- /dev/null +++ b/files/mods/@MuchStuffPack @@ -0,0 +1 @@ +1991570984 \ No newline at end of file diff --git a/files/mods/enoch/map.env b/files/mods/enoch/map.env new file mode 100644 index 0000000..7c2a888 --- /dev/null +++ b/files/mods/enoch/map.env @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +MAP="Enoch" +DIR="DayZ-Central-Economy" +REPO="https://github.com/BohemiaInteractive/${DIR}.git" +MPDIR="dayzOffline.enoch" diff --git a/web/Dockerfile b/web/Dockerfile index 3eb05b3..f9574e8 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -16,6 +16,7 @@ RUN sed -i /etc/apt/sources.list.d/debian.sources -e 's/Components: main/Compone RUN apt-get update && apt-get -y upgrade && apt-get -y install --no-install-recommends \ binutils \ curl \ + git \ gwenhywfar-tools \ jq \ libxml2-utils \ diff --git a/web/bin/dz b/web/bin/dz index fe6e796..047ac3d 100755 --- a/web/bin/dz +++ b/web/bin/dz @@ -56,7 +56,6 @@ installxml(){ do var=$(echo ${i} | cut -d: -f1) CHECK=$(echo ${i} | cut -d: -f2) - CHILD=$(echo ${i} | cut -d: -f3) if [ -f "${WORKSHOP_DIR}/${ID}/${var,,}.xml" ] then echo "Normalizing ${WORKSHOP_DIR}/${ID}/${var,,}.xml..." @@ -127,13 +126,14 @@ add(){ # Remove a mod remove(){ - if [ -d "${WORKSHOP_DIR}/${1}" ] + DIR="${WORKSHOP_DIR}/${1:?}" + if [ -d "${DIR}" ] then MODNAME=$(get_mod_name ${1}) - echo "Removing directory ${WORKSHOP_DIR}/${1}" - rm -rf "${WORKSHOP_DIR}/${1}" + echo "Removing directory ${DIR}" + rm -rf "${DIR}" else - echo "Directory ${WORKSHOP_DIR}/${1} doesn't exist?" + echo "Directory ${DIR} doesn't exist?" fi if [ -L "${SERVER_FILES}/@${MODNAME}" ] then @@ -305,9 +305,14 @@ Mods: " 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}/map.env ] + TERM="map" + if [[ "${1}" =~ ^[0-9]+$ ]] + then + TERM="mod id" + fi + if [ -f "${FILES}/mods/${1}/map.env" ] then - echo "Installing mpmissions files for mod id ${1}..." + echo "Installing mpmissions files for ${TERM} ${1}..." source ${FILES}/mods/${1}/map.env ${FILES}/bin/map.sh ${1} install fi