Compare commits

..

16 Commits

Author SHA1 Message Date
d64f62977b asdf 2023-11-29 07:33:12 -06:00
1205108c34 adsf 2023-11-29 07:17:48 -06:00
fcc86b3760 asdf 2023-11-29 07:13:33 -06:00
0ebab689b7 asdf 2023-11-29 07:13:11 -06:00
95e5ff889b asdf 2023-11-29 07:12:53 -06:00
65e4aa16a0 asdf 2023-11-29 07:11:56 -06:00
dfe20d9fed asdf 2023-11-29 06:58:07 -06:00
a9a87303c2 asdf 2023-11-29 06:52:36 -06:00
7dec690284 asdf 2023-11-29 06:50:02 -06:00
b25a761c6a asdf 2023-11-29 06:48:46 -06:00
29cd2e3ec0 asdf 2023-11-29 06:45:55 -06:00
0fe8c31b72 asdf 2023-11-29 06:30:19 -06:00
bb3ac16365 asdf 2023-11-29 05:35:07 -06:00
4d3b0104f4 asdf 2023-11-26 09:27:29 -06:00
250f1f7dba Merge branch 'master' of ssh://gitea.local.wvr.sh:2221/mitch/dayz-servers 2023-11-26 09:23:36 -06:00
c66cacd231 adjust_types.sh rewritten 2023-11-26 09:23:26 -06:00
17 changed files with 247 additions and 180 deletions

View File

@@ -1,112 +0,0 @@
#!/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

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 83 KiB

View File

@@ -1,4 +1,4 @@
#!/bin/sh -ex #!/bin/sh -e
# #
# values used on both the modserver and individual servers # values used on both the modserver and individual servers
# ------------------------------------------------------------ # ------------------------------------------------------------
@@ -8,7 +8,8 @@ export DAYZ_GAME_ID=221100
export DAYZ_SERVER_ID=223350 export DAYZ_SERVER_ID=223350
export STEAM_USER="yzaddayz" export STEAM_USER="yzaddayz"
export DEBUG=false # blank debug to unset it by default
export DEBUG=
export REMOTE_DAYZ_TRUENAS_SHARE='\\dayz-truenas.local.wvr.sh\dayz' export REMOTE_DAYZ_TRUENAS_SHARE='\\dayz-truenas.local.wvr.sh\dayz'
export REMOTE_DIR="/mnt/dayz" export REMOTE_DIR="/mnt/dayz"
@@ -32,18 +33,16 @@ export TAKISTAN_MOD_ID=2563233742
################### GLOBAL VARS ############################## ################### GLOBAL VARS ##############################
################### GLOBAL ALIASES ########################### ################### GLOBAL ALIASES ###########################
# note: OLD? MAYBE NEEDED?
###########alias do_sync='rsync -rvltDhu --delete --partial --progress'
unalias rsync 2>/dev/null ||: unalias rsync 2>/dev/null ||:
alias do_sync='rsync -avhu --progress --delete --partial --links' alias do_sync='rsync -avhu --progress --delete --partial --links'
################### GLOBAL ALIASES ########################### ################### GLOBAL ALIASES ###########################
################### GLOBAL FUNCTIONS ######################### ################### GLOBAL FUNCTIONS #########################
msg() { msg() {
printf '\n[*] %s\n\n' "$*" printf '>>>>>[MESSAGE]: %s\n' "$*"
} }
errmsg() { errmsg() {
>&2 printf '\n[Error]: %s\n\n' "$*" >&2 printf '>>>>>>[ERROR]: %s\n' "$*"
} }
die() { die() {
errmsg "$*" errmsg "$*"
@@ -51,7 +50,7 @@ die() {
} }
debug() { debug() {
if [ "$DEBUG" ] ; then if [ "$DEBUG" ] ; then
>&2 printf '>>>>>>>>>DEBUG: %s\n' "$*" >&2 printf '>>>>>>DEBUG: %s\n' "$*"
fi fi
} }
isempty() { isempty() {
@@ -86,7 +85,9 @@ isempty() {
} }
mount_dayz_network_drive() { mount_dayz_network_drive() {
if ! is_network_drive_mounted ; then if ! is_network_drive_mounted ; then
if [ ! -d /mnt/dayz ] ; then
sudo mkdir -p /mnt/dayz sudo mkdir -p /mnt/dayz
fi
if [ -e /proc/version ] ; then if [ -e /proc/version ] ; then
read -r ver < /proc/version read -r ver < /proc/version
case $ver in case $ver in

145
lib/typestool.sh Normal file
View File

@@ -0,0 +1,145 @@
#!/bin/sh -e
#
# Wrapper for editing DayZ types.xml using xmlstarlet
#
# 01. "should check code directly not $?"
# shellcheck disable=2181
#
# 02. "can't follow . import"
# shellcheck disable=1090,1091
#
# 03. "possible misspelling"
# shellcheck disable=2153
#
# 04. "use find .. over ls"
# shellcheck disable=2011
#----------------------------------------------------------
# =================================================================
# LOAD GLOBALS FILE
# =================================================================
GLOBALS_FILE="$PWD/globals.sh"
if [ -e "$GLOBALS_FILE" ] ; then
chmod +x "$GLOBALS_FILE"
. "$GLOBALS_FILE"
else
>&2 echo "Could not load: $GLOBALS_FILE"
exit 1
fi
# =================================================================
# example: swap_flag M16A2 count_in_cargo 1 file
swap_flags() {
file=$4
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 [ ! -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##*/} [--swap-flags|--swap-value] item_name tag value types.xml
--swap-value swap an item tag's value
--swap-flags swap an item's flags sub-value
# ================================
# Examples
# ================================
# --------------------------------
# Ex #1: Swapping a value
# --------------------------------
<type name="M4A1">
<nominal>1</nominal>
</type>
${0##*/} --swap-value M4A1 nominal 2 some_file.xml
# --------------------------------
# Ex #2: Swapping a flags value
# --------------------------------
<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##*/} --swap-flags M16A2 count_in_player 1 some_file.xml
EOF
exit 1
}
check() {
if ! command -v xmlstarlet >/dev/null ; then
die "Please install xmlstarlet"
fi
}
main() {
check || die "Failed check"
if [ "$DEBUG" ] ; then
echo "ADJUSTING TYPE: $2 $3"
fi
case $1 in
-h|--help)
usage
;;
-v|--swap-value)
shift
swap_value "$1" "$2" "$3" "$4" || exit 1
;;
-f|--swap-flags)
shift
swap_flags "$1" "$2" "$3" "$4" || exit 1
;;
esac
}
main "$@"

View File

@@ -10,3 +10,5 @@ msg() {
-H "Content-Type:application/json" \ -H "Content-Type:application/json" \
--data "{\"content\": $message}" --data "{\"content\": $message}"
} }
msg "$@"

View File

@@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh -e
# #
# 01. "should check code directly not $?" # 01. "should check code directly not $?"
# shellcheck disable=2181 # shellcheck disable=2181
@@ -18,19 +18,37 @@
# =================================================== # ===================================================
echo "Starting, attempting to load globals.sh" echo "Starting, attempting to load globals.sh"
GLOBALS_FILE="$PWD/lib/globals.sh" # if we are called externally by one of the servers,
# the command will be "~/dayz-servers/modserver_update.sh"
# we need to change from $PWD to accomodate for that
export WORKING_DIR=$PWD
if [ ! -d "$WORKING_DIR"/lib ] ; then
export WORKING_DIR="$HOME/dayz-servers"
if [ ! -d "$WORKING_DIR"/lib ] ; then
>&2 echo "Could not find lib. Exiting"
exit 1
fi
fi
# grab fresh copy of all helper scripts / libraries
if [ -d "$WORKING_DIR/lib" ] ; then
cp -f "$WORKING_DIR/lib"/* .
fi
GLOBALS_FILE="$WORKING_DIR/globals.sh"
if [ -e "$GLOBALS_FILE" ] ; then if [ -e "$GLOBALS_FILE" ] ; then
chmod +x "$GLOBALS_FILE" chmod +x "$GLOBALS_FILE"
. "$GLOBALS_FILE" . "$GLOBALS_FILE"
else else
die "Could not load: $GLOBALS_FILE" >&2 echo "Could not load: $GLOBALS_FILE"
exit 1
fi fi
# =================================================== # ===================================================
# 02. Local script variables # 02. Local script variables
# =================================================== # ===================================================
export STEAMCMD_USER=steam export STEAMCMD_USER=steam
export MODLISTS="$PWD/modlists" export MODLISTS="$WORKING_DIR/modlists"
export LOCAL_STOCK="$HOME/stock" export LOCAL_STOCK="$HOME/stock"
export LOCAL_STOCK_GAME="$LOCAL_STOCK/DayZ" export LOCAL_STOCK_GAME="$LOCAL_STOCK/DayZ"
@@ -74,14 +92,14 @@ check() {
die "Remote server already locked?" die "Remote server already locked?"
fi fi
msg "Health checks passed successfully." msg "(MODSERVER): Health checks passed successfully."
} }
# =================================================== # ===================================================
# 05. Begin functions # 05. Begin functions
# =================================================== # ===================================================
update_server() { update_server() {
msg "============== UPDATING DAYZ SERVER =================" msg "(MODSERVER): STARTING UPDATING DAYZ SERVER"
steamcmd -tcp \ steamcmd -tcp \
+force_install_dir "$LOCAL_STOCK_SERVER" \ +force_install_dir "$LOCAL_STOCK_SERVER" \
+@sSteamCmdForcePlatformType windows \ +@sSteamCmdForcePlatformType windows \
@@ -92,11 +110,11 @@ update_server() {
is_network_drive_mounted && is_network_drive_mounted &&
do_sync "$LOCAL_STOCK_SERVER"/ "$REMOTE_STOCK_SERVER" do_sync "$LOCAL_STOCK_SERVER"/ "$REMOTE_STOCK_SERVER"
msg "============ DONE UPDATING SERVER =====================" msg "(MODSERVER): FINISHED UPDATING DAYZ SERVER"
} }
update_game() { update_game() {
msg "========== UPDATING DAYZ GAME ================" msg "(MODSERVER): STARTING UPDATING DAYZ GAME"
steamcmd -tcp \ steamcmd -tcp \
+force_install_dir "$LOCAL_STOCK_GAME" \ +force_install_dir "$LOCAL_STOCK_GAME" \
+@sSteamCmdForcePlatformType windows \ +@sSteamCmdForcePlatformType windows \
@@ -107,12 +125,12 @@ update_game() {
is_network_drive_mounted && is_network_drive_mounted &&
do_sync "$LOCAL_STOCK_GAME"/ "$REMOTE_STOCK_GAME" do_sync "$LOCAL_STOCK_GAME"/ "$REMOTE_STOCK_GAME"
msg "============= DONE UPDATING GAME ===================" msg "(MODSERVER): FINISHED UPDATING DAYZ GAME"
} }
# args: $1 = server_modlist.txt to update # args: $1 = server_modlist.txt to update
update_mods_for_server() { update_mods_for_server() {
msg "======= UPDATING MODS FOR MAP: $1 ========" msg "(MODSERVER): UPDATING MODS FOR MAP: $1"
mods_file="$MODLISTS/$1" mods_file="$MODLISTS/$1"
map_name=${1%.txt} map_name=${1%.txt}
@@ -164,12 +182,11 @@ update_mods_for_server() {
die "Problem downloading mods for $map_name" die "Problem downloading mods for $map_name"
fi fi
msg "------------ RENAMING MODS -------------" msg "(MODSERVER): RENAMING MODS"
mods_to_copy="$LOCAL_MODS/mods_to_copy"
rm -rf "$mods_to_copy" 2>/dev/null ||: # blank map's mods.txt
mkdir -p "$mods_to_copy" :> "$remote_map_mod_dir/mods.txt"
:> "$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
@@ -181,29 +198,27 @@ update_mods_for_server() {
if [ ! -d "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$mod_id" ] ; then if [ ! -d "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$mod_id" ] ; then
die "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$mod_id does not exist" die "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$mod_id does not exist"
fi fi
cp -raf "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$mod_id" "$mods_to_copy/@${mod_name}" do_sync "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$mod_id"/ "$remote_map_mod_dir/@${mod_name}"
printf '@%s\n' "$mod_name" >> "$mods_to_copy/mods.txt" printf '@%s\n' "$mod_name" >> "$remote_map_mod_dir/mods.txt"
msg "(MODSERVER): Finished syncing: $mod_name"
esac esac
done < "$mods_file" done < "$mods_file"
msg "----------- SYNCING MODS -------------"
do_sync "$mods_to_copy"/ "$remote_map_mod_dir"
rm -f "$tempfile" 2>/dev/null ||: rm -f "$tempfile" 2>/dev/null ||:
unset tempfile mod map_name mods_file mods_to_copy mod_name mod_id remote_map_mod_dir unset tempfile mod map_name mods_file mod_name mod_id remote_map_mod_dir
msg "======= DONE UPDATING MODS FOR: $1 ========" msg "(MODSERVER): FINISHED UPDATING MODS FOR MAP: $1"
} }
update_stock_maps() { update_stock_maps() {
msg "----------- UPDATING MAPS -------------" msg "(MODSERVER): UPDATING MAPS"
msg "Copying Stock Chernarus" msg "(MODSERVER): Copying Stock Chernarus"
do_sync \ do_sync \
"$LOCAL_STOCK_SERVER/mpmissions/$CHERNARUS_MAP_NAME"/ \ "$LOCAL_STOCK_SERVER/mpmissions/$CHERNARUS_MAP_NAME"/ \
"$REMOTE_MAPS/$CHERNARUS_MAP_NAME" "$REMOTE_MAPS/$CHERNARUS_MAP_NAME"
msg "Updating Namalsk Survival" msg "(MODSERVER): Updating Namalsk Survival"
steamcmd \ steamcmd \
-tcp \ -tcp \
+force_install_dir "$LOCAL_MODS" \ +force_install_dir "$LOCAL_MODS" \
@@ -225,7 +240,7 @@ update_stock_maps() {
die "failed to copy Namalsk map files" die "failed to copy Namalsk map files"
fi fi
msg "Updating Namalsk Island" msg "(MODSERVER): Updating Namalsk Island"
steamcmd \ steamcmd \
-tcp \ -tcp \
+force_install_dir "$LOCAL_MODS" \ +force_install_dir "$LOCAL_MODS" \
@@ -243,7 +258,7 @@ update_stock_maps() {
####################TODO: # msg "Updating Optimized Namalsk Server PBOs" ####################TODO: # msg "Updating Optimized Namalsk Server PBOs"
msg "Updating TakistanPlus" msg "(MODSERVER): Updating TakistanPlus"
steamcmd \ steamcmd \
-tcp \ -tcp \
+force_install_dir "$LOCAL_MODS" \ +force_install_dir "$LOCAL_MODS" \
@@ -277,7 +292,7 @@ main() {
for server in $(ls "$MODLISTS" | xargs) ; do for server in $(ls "$MODLISTS" | xargs) ; do
if [ ! -f "$MODLISTS/$server" ] ; then if [ ! -f "$MODLISTS/$server" ] ; then
msg "Could not find modlist for: $MODLISTS/$server" msg "(MODSERVER): Could not find modlist for: $MODLISTS/$server"
continue continue
fi fi
update_mods_for_server "$server" update_mods_for_server "$server"

View File

@@ -0,0 +1 @@
choco install -y firefox 7zip cpu-z hwinfo vcredist2015 directx directx-sdk

View File

@@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
chmod -x globals.sh chmod -x globals.sh 2>/dev/null ||:
chmod -x lib/globals.sh 2>/dev/null ||:
git stash
git pull git pull

View File

@@ -1,4 +1,4 @@
#!/bin/sh -ex #!/bin/sh -e
# #
# 01. "should check code directly not $?" # 01. "should check code directly not $?"
# shellcheck disable=2181 # shellcheck disable=2181
@@ -45,14 +45,6 @@ export STOCK_SERVER_CACHE="$CACHE/stock_server"
export MOD_CACHE="$CACHE/mods" export MOD_CACHE="$CACHE/mods"
export SERVERS="$LOCAL_DAYZ_FILES/servers" export SERVERS="$LOCAL_DAYZ_FILES/servers"
# (4 hours, in seconds)
################################# export RESTART_INTERVAL=$((60 * 60 * 4))
# (10 minutes)
# export RESTART_INTERVAL=$((10 * 60))
export RESTART_INTERVAL=$((1 * 60))
# =================================================== # ===================================================
# 03. Mount network drive # 03. Mount network drive
# =================================================== # ===================================================
@@ -222,7 +214,8 @@ EOF
cmd.exe /C temp.bat cmd.exe /C temp.bat
rm -f temp.bat modstring 2>/dev/null ||: rm -f temp.bat modstring 2>/dev/null ||:
msg '%s - Server started.\n' "$(date)" msg "Server started: $(date)"
msg "RESTART_INTERVAL: $RESTART_INTERVAL"
count=0 count=0
while [ "$count" -lt "$RESTART_INTERVAL" ] ; do while [ "$count" -lt "$RESTART_INTERVAL" ] ; do
@@ -242,7 +235,15 @@ EOF
# =================================================== # ===================================================
# 07. Main loop # 07. Main loop
# =================================================== # ===================================================
main() { main() {
NUMBER_OF_STARTS=0
while true ; do
NUMBER_OF_STARTS=$((NUMBER_OF_STARTS + 1))
msg "Server is preparing to start..."
msg "NUMBER OF STARTS: $NUMBER_OF_STARTS"
cd "$ORIGINAL_DIR" || die "Can no longer cd to $ORIGINAL_DIR" cd "$ORIGINAL_DIR" || die "Can no longer cd to $ORIGINAL_DIR"
if [ -e ./SERVER.ENV ] ; then if [ -e ./SERVER.ENV ] ; then
@@ -263,6 +264,11 @@ main() {
die "Could not find ./serverDZ.cfg" die "Could not find ./serverDZ.cfg"
fi fi
# trigger update for remote server game/map/mod files
# for this, the current machine needs to have ssh-copy-id done
# or else will ask for password
ssh steam@dayz-modserver 'sh /home/steam/dayz-servers/modserver_update.sh'
# sync remote server stock and mod files into local cache # sync remote server stock and mod files into local cache
refresh_local_cache || die "Failed to refresh local cache." refresh_local_cache || die "Failed to refresh local cache."
@@ -271,6 +277,7 @@ main() {
# START THE SERVER - RUN ServerDZ.EXE # START THE SERVER - RUN ServerDZ.EXE
start_server "$@" start_server "$@"
done
} }
main "$@" || exit 1 main "$@" || exit 1

View File

@@ -8,3 +8,9 @@ export SERVER_PORT=2302
# number of threads to allocate # number of threads to allocate
export SERVER_CPU=10 export SERVER_CPU=10
# (4 hours, in seconds)
################################# export RESTART_INTERVAL=$((60 * 60 * 4))
# (5 minutes)
export RESTART_INTERVAL=$((5 * 60))