This commit is contained in:
wvr
2022-12-07 23:28:22 -06:00
parent e8b1389ebd
commit 79a2c9edf0
5 changed files with 301 additions and 45 deletions

112
adjust_type.sh Executable file
View File

@@ -0,0 +1,112 @@
#!/usr/bin/env bash
#
# Wrapper for editing DayZ types.xml using xmlstarlet
#
#----------------------------------------------------------
# example: swap_flag M16A2 count_in_cargo 1 file
swap_flag() {
file=$4
if ! command -v xmlstarlet >/dev/null ; then
>&2 echo "NOT IN \$PATH: xmlstarlet"
exit 1
fi
if [ ! -f "$file" ] ; then
>&2 echo "File: '$file' is not a file"
exit 1
fi
if [ "$1" ] && [ "$2" ] && [ "$3" ] ; then
_name=$1
_flag=$2
_value=$3
xmlstarlet ed -P -L \
-u \ "//types/type[@name=\"$_name\"]/flags[@$_flag]/@$_flag" \
-v \
"$_value" \
"$file"
else
>&2 echo "Bad params in swap_flag"
exit 1
fi
}
# example: swap_value M4A1 nominal 3 file
swap_value() {
file=$4
if ! command -v xmlstarlet >/dev/null ; then
>&2 echo "NOT IN \$PATH: xmlstarlet"
exit 1
fi
if [ ! -f "$file" ] ; then
>&2 echo "File: '$file' is not a file"
exit 1
fi
if [ "$1" ] && [ "$2" ] && [ "$3" ] ; then
_name=$1
_tag=$2
_value=$3
xmlstarlet ed -P -L \
-u \ "//types/type[@name=\"$_name\"]/$_tag" \
-v \
"$_value" \
"$file"
else
>&2 echo "Bad params in swap_value"
exit 1
fi
}
usage() {
cat <<EOF
Usage: ${0##*/} [-f|-v] name tag value file
-f swap a flag from flags
-v swap a normal value
# --------------------------------
# Examples
# --------------------------------
# examples #1:
<type name="M16A2">
<lifetime>28800</lifetime>
</type>
${0##*/} -v M16A2 lifetime 20000 some_file.xml
# example #2:
<type name="M16A2">
<flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="0" crafted="0" deloot="0"/>
</type>
${0##*/} -f M16A2 count_in_player 1 some_file.xml
EOF
exit 1
}
if [ "$DEBUG" ] ; then
echo "ADJUSTING TYPE: $2 $3"
fi
case $1 in
-h|--help)
usage
;;
-f)
shift
swap_flag "$1" "$2" "$3" "$4" || exit 1
;;
-v)
shift
swap_value "$1" "$2" "$3" "$4" || exit 1
;;
esac

View File

@@ -18,6 +18,10 @@
############## https://steamcommunity.com/sharedfiles/filedetails/?id=2507204412 ############## https://steamcommunity.com/sharedfiles/filedetails/?id=2507204412
#############2507204412^sgunplay #############2507204412^sgunplay
################## enough stamina
################## https://steamcommunity.com/sharedfiles/filedetails/?id=2337398072
#################2337398072^enoughstamina
# ================================================================== # ==================================================================
# Generic / All Servers # Generic / All Servers
# ================================================================== # ==================================================================
@@ -50,10 +54,6 @@
# https://steamcommunity.com/sharedfiles/filedetails/?id=2884638645 # https://steamcommunity.com/sharedfiles/filedetails/?id=2884638645
2884638645^tentbackpacks 2884638645^tentbackpacks
# enough stamina
# https://steamcommunity.com/sharedfiles/filedetails/?id=2337398072
2337398072^enoughstamina
# durable suppressors (1.5x health) # durable suppressors (1.5x health)
# https://steamcommunity.com/sharedfiles/filedetails/?id=2880585815 # https://steamcommunity.com/sharedfiles/filedetails/?id=2880585815
2880585815^durablesuppressors 2880585815^durablesuppressors
@@ -103,7 +103,7 @@
2469448088^svisual 2469448088^svisual
# ================================================================== # ==================================================================
# Chernaurus Specific # Chernarus Specific
# ================================================================== # ==================================================================
# spurgles bagz # spurgles bagz

50
mod-server/update.sh → modserver/update.sh Normal file → Executable file
View File

@@ -4,8 +4,9 @@ DAYZ_GAME_ID=221100
DAYZ_SERVER_ID=223350 DAYZ_SERVER_ID=223350
LOCAL_MODS_DIR="${HOME}/.steam/debian-installation/steamapps/workshop/content/$DAYZ_GAME_ID" LOCAL_MODS_DIR="${HOME}/.steam/debian-installation/steamapps/workshop/content/$DAYZ_GAME_ID"
STEAM_USER="yzaddayz" STEAM_USER="yzaddayz"
REMOTE_MAPS="/mnt/dayz/stock/maps"
alias do_sync='rsync -avrhu --delete --partial' alias do_sync='rsync -rvltDhu --delete --partial --progress'
msg() { msg() {
printf '[*] %s\n' "$*" printf '[*] %s\n' "$*"
@@ -17,8 +18,7 @@ update_server() {
msg "------------------ UPDATING DAYZ SERVER -------------------" msg "------------------ UPDATING DAYZ SERVER -------------------"
LOCAL_INSTALL_DIR="${HOME}/.steam/debian-installation/steamapps/common/DayZServer" LOCAL_INSTALL_DIR="${HOME}/.steam/debian-installation/steamapps/common/DayZServer"
REMOTE_INSTALL_DIR="/mnt/dayz/DayZServer" REMOTE_INSTALL_DIR="/mnt/dayz/stock/DayZServer"
MODS_FILE="$HOME/mods.txt"
steamcmd -tcp +login "$STEAM_USER" +app_update "$DAYZ_GAME_ID" +quit steamcmd -tcp +login "$STEAM_USER" +app_update "$DAYZ_GAME_ID" +quit
steamcmd -tcp +login "$STEAM_USER" +app_update "$DAYZ_SERVER_ID" +quit steamcmd -tcp +login "$STEAM_USER" +app_update "$DAYZ_SERVER_ID" +quit
@@ -31,6 +31,7 @@ update_server() {
update_mods() { update_mods() {
MODS_FILE="$HOME/modlists/$1.txt" MODS_FILE="$HOME/modlists/$1.txt"
REMOTE_MODS_DIR="/mnt/dayz/mods/$1" REMOTE_MODS_DIR="/mnt/dayz/mods/$1"
mkdir -p "$REMOTE_MODS_DIR"
tempfile=/tmp/mods-to-download.txt tempfile=/tmp/mods-to-download.txt
:> "$tempfile" :> "$tempfile"
@@ -54,6 +55,8 @@ update_mods() {
rm -rf "$HOME/mods_to_copy" 2>/dev/null ||: rm -rf "$HOME/mods_to_copy" 2>/dev/null ||:
mkdir -p "$HOME/mods_to_copy" mkdir -p "$HOME/mods_to_copy"
:> "$HOME/mods_to_copy/mods.txt"
while read -r mod ; do while read -r mod ; do
# skip comments, blank lines # skip comments, blank lines
case "$mod" in case "$mod" in
@@ -63,23 +66,56 @@ update_mods() {
mod_id=${mod%%^*} mod_id=${mod%%^*}
mod_name=${mod##*^} mod_name=${mod##*^}
do_sync "$LOCAL_MODS_DIR/$mod_id"/ "$HOME/mods_to_copy/@${mod_name}" do_sync "$LOCAL_MODS_DIR/$mod_id"/ "$HOME/mods_to_copy/@${mod_name}"
printf '@%s\n' "$mod_name" >> "$HOME/mods_to_copy/mods.txt"
esac esac
done < "$MODS_FILE" done < "$MODS_FILE"
msg "----------- SYNCING MODS -------------" msg "----------- SYNCING MODS -------------"
do_sync "$HOME/mods_to_copy"/ "$REMOTE_MODS_DIR" do_sync "$HOME/mods_to_copy"/ "$REMOTE_MODS_DIR"
msg "copying mods.txt ..."
cp -vf "$MODS_FILE" "$REMOTE_MODS_DIR/mods.txt"
rm "$tempfile" 2>/dev/null ||: rm "$tempfile" 2>/dev/null ||:
rm -rf "$HOME/mods_to_copy" 2>/dev/null ||: rm -rf "$HOME/mods_to_copy" 2>/dev/null ||:
} }
update_stock_maps() {
msg "----------- UPDATING MAPS -------------"
cherno=dayzOffline.chernarusplus
namalsk=regular.namalsk
takistan=Offline.TakistanPlus
NAMALSK_MOD_ID=2289461232
TAKISTAN_MOD_ID=2563233742
do_sync \
"${HOME}/.steam/debian-installation/steamapps/common/DayZServer/mpmissions/$cherno"/ \
"$REMOTE_MAPS/$cherno"
msg "Updating Namalsk Survival"
steamcmd -tcp +login "$STEAM_USER" +workshop_download_item "$DAYZ_GAME_ID" "$NAMALSK_MOD_ID" +quit || exit 1
if [ -d "$LOCAL_MODS_DIR/$NAMALSK_MOD_ID/Extras/Regular/$namalsk" ] ; then
do_sync "$LOCAL_MODS_DIR/$NAMALSK_MOD_ID/Extras/Regular/$namalsk"/ "$REMOTE_MAPS/$namalsk" || \
die "failed to copy Namalsk map files"
fi
msg "Updating Optimized Namalsk Server PBOs"
#NAMALSK_OPTIMIZED
steamcmd -tcp +login "$STEAM_USER" +workshop_download_item "$DAYZ_GAME_ID" "$NAMALSK_MOD_ID" +quit || exit 1
msg "Updating TakistanPlus"
steamcmd -tcp +login "$STEAM_USER" +workshop_download_item "$DAYZ_GAME_ID" "$TAKISTAN_MOD_ID" +quit || exit 1
if [ -d "$LOCAL_MODS_DIR/$TAKISTAN_MOD_ID/Mission/$takistan" ] ; then
do_sync "$LOCAL_MODS_DIR/$TAKISTAN_MOD_ID/Mission/$takistan"/ "$REMOTE_MAPS/$takistan" || \
die "failed to copy Takistan map files"
fi
msg "NOTE: deer isle doesn't get automatic updates... Skipping"
}
main () { main () {
update_server update_server
update_stock_maps
for server in "$(ls "$HOME/modlists" | xargs | sed 's/\.txt//g')" ; do for server in $(ls "$HOME/modlists" | xargs | sed 's/\.txt//g') ; do
rm -rf "$HOME/.steam/debian-installation/steamapps/workshop/downloads" rm -rf "$HOME/.steam/debian-installation/steamapps/workshop/downloads"
mkdir -p "$HOME/.steam/debian-installation/steamapps/workshop/downloads" mkdir -p "$HOME/.steam/debian-installation/steamapps/workshop/downloads"
update_mods "$server" update_mods "$server"

View File

@@ -1,6 +1,3 @@
#!/bin/sh #!/usr/bin/env bash
sudo mkdir -p /mnt/dayz
sudo mount -t drvfs //truenas.home.weaver/dayz /mnt/dayz sudo mount -t drvfs //truenas.home.weaver/dayz /mnt/dayz
ls -l /mnt/dayz

159
start.sh
View File

@@ -1,4 +1,4 @@
#!/bin/sh -e #!/usr/bin/env bash
# #
# shellcheck disable=2043 # shellcheck disable=2043
# #
@@ -9,25 +9,12 @@
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
export DAYZ_FILES=/mnt/dayz export DAYZ_FILES=/mnt/dayz
export STOCK_SERVER_DATA="$DAYZ_FILES/stock/DayZServer" export STOCK_SERVER_DATA="$DAYZ_FILES/stock/DayZServer"
export MAIN="/mnt/c/DAYZ" export MAIN="/mnt/c/DAYZ"
export SERVERS="$MAIN/servers" export SERVERS="$MAIN/servers"
export CACHE="$MAIN/cache" export CACHE="$MAIN/cache"
export MOD_CACHE="$CACHE/mods" export MOD_CACHE="$CACHE/mods"
export RESTART_INTERVAL=$((60 * 60 * 4 + 3)) export RESTART_INTERVAL=$((60 * 60 * 4 + 3))
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# SERVER SPECIFIC SETTINGS
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
export SERVER_NAME='ZyaD Chernarus'
export SERVER_HOME="$SERVERS/$SERVER_NAME"
export MAP_FOLDER_NAME='chernarus'
export LOCAL_FOLDER_MAP_NAME='dayzOffline.chernarusplus'
export SERVER_PORT=2302
export SERVER_CPU=8
export SERVER_CONFIG_FILE="serverDZ.cfg"
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Helper functions # Helper functions
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
@@ -89,14 +76,6 @@ setup_environment() {
do_sync "$STOCK_SERVER_DATA/$file" "$SERVER_HOME/$file" || die "Failed to copy stock: $file" do_sync "$STOCK_SERVER_DATA/$file" "$SERVER_HOME/$file" || die "Failed to copy stock: $file"
done done
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# NOTE: TODO: Namalsk etc will need this changed!@@!@!@!@!@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
msg "Copying stock mpmissions data"
do_sync --exclude="*storage_1*" "$STOCK_SERVER_DATA/mpmissions/dayzOffline.enoch"/ "$SERVER_HOME/mpmissions/dayzOffline.enoch"
do_sync --exclude="*storage_1*" "$STOCK_SERVER_DATA/mpmissions/dayzOffline.chernarusplus"/ "$SERVER_HOME/mpmissions/dayzOffline.chernarusplus"
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
msg "Copying mod files" msg "Copying mod files"
do_sync "$DAYZ_FILES/mods/$MAP_FOLDER_NAME"/ "$MOD_CACHE/$MAP_FOLDER_NAME" || die "Failed to copy mod files" do_sync "$DAYZ_FILES/mods/$MAP_FOLDER_NAME"/ "$MOD_CACHE/$MAP_FOLDER_NAME" || die "Failed to copy mod files"
@@ -149,6 +128,123 @@ load_mods() {
printf '%s\n' "$_modstring" > .modstring printf '%s\n' "$_modstring" > .modstring
} }
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Load Map
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
load_stock_map_data() {
msg "Loading stock map data"
do_sync --exclude="*storage_1*" \
"$DAYZ_FILES/stock/maps/$MAP_FOLDER_NAME"/ \
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME"
}
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Types Patching
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
patch_types() {
if [ ! -f "$DAYZ_FILES/server_configs/types/default_types_to_delete.txt" ] ; then
die "CANNOT REACH FILE: default_types_to_delete.txt"
fi
# deletes
while read -r line ; do
case "$line" in
'#'*|' '*|'')
;;
*)
debug "TYPES -- deleting object: $line"
xmlstarlet ed -L -P -d "//types/type[@name=\"$line\"]" \
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/db/types.xml"
esac
done < "$DAYZ_FILES/server_configs/types/default_types_to_delete.txt"
# copy types edit tool
if [ -f "$DAYZ_FILES/scripts/adjust_type.sh" ] ; then
cp -f "$DAYZ_FILES/scripts/adjust_type.sh" "$SERVER_HOME"/
else
die "Could not find adjust_type.sh"
fi
if [ -f "$DAYZ_FILES/server_configs/types/$MAP_FOLDER_NAME.sh" ] ; then
cp -f "$DAYZ_FILES/server_configs/types/$MAP_FOLDER_NAME.sh" \
"$SERVER_HOME"/
cd "$SERVER_HOME" || die "could not cd to $SERVER_HOME"
sh "$SERVER_HOME/$MAP_FOLDER_NAME.sh" \
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/db/types.xml" || \
die "Failed while running maps types edit script"
else
die "Could not find $DAYZ_FILES/server_configs/types/$MAP_FOLDER_NAME.sh"
fi
}
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Configs
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
load_configs() {
msg "Loading server configs"
if [ -d "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME" ] ; then
for xml in "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME"/*.xml ; do
if [ -f "$xml" ] ; then
debug "Found: $xml -- Copying."
do_sync "$xml" "$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/${xml##*/}" || \
die "Failed to copy: ${xml##*/}"
fi
done
for json in "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME"/*.json ; do
if [ -f "$json" ] ; then
debug "Found: $json -- Copying."
do_sync "$json" "$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/${json##*/}" || \
die "Failed to copy: ${json##*/}"
fi
done
if [ -f "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/init.c" ] ; then
debug "Found: init.c -- Copying."
do_secure_sync \
"$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/init.c" \
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/init.c" || \
die "failed to copy init.c"
fi
if [ -f "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/areaflags.map" ] ; then
debug "Found: areaflags.map -- Copying."
do_sync \
"$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/areaflags.map" \
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/areaflags.map" || \
die "failed to copy areaflags.map"
fi
fi
if [ -d "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/db" ] ; then
for xml in "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/db"/*.xml ; do
if [ -f "$xml" ] ; then
debug "Found: $xml -- Copying."
do_sync "$xml" "$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/db/${xml##*/}" || \
die "Failed to copy: ${xml##*/}"
fi
done
fi
if [ -d "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/env" ] ; then
for xml in "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/env"/*.xml ; do
if [ -f "$xml" ] ; then
debug "Found: $xml -- Copying."
do_sync "$xml" "$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/env/${xml##*/}" || \
die "Failed to copy: ${xml##*/}"
fi
done
fi
}
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Main # Main
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
@@ -165,7 +261,17 @@ main() {
load_mods || die "Could not load mods" load_mods || die "Could not load mods"
mod_string=$(cat .modstring) mod_string=$(cat .modstring)
>&2 printf 'MOD_STRING: %s\n' "$mod_string" msg "Loading stock map data"
load_stock_map_data || die "Could not load map"
msg "Patching types.xml"
patch_types || die "Failed to patch types"
msg "Copying server configs"
load_configs || die "Failed to load configs"
# msg "Creating custom types list"
#############################
echo '====================================' echo '===================================='
printf '%s - Server started.\n' "$(date)" printf '%s - Server started.\n' "$(date)"
@@ -198,6 +304,11 @@ EOF
msg "SERVER IS RESTARTING" msg "SERVER IS RESTARTING"
} }
while : ; do while msg 'Starting loop' ; do
if [ -f ./SERVER.ENV ] ; then
. ./SERVER.ENV
else
die "Could not source ./SERVER.ENV"
fi
main "$@" main "$@"
done done