Compare commits

..

115 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
51f9571b8c asdf 2023-11-26 01:14:29 -06:00
457f8d7618 adsf 2023-11-26 01:06:54 -06:00
89dc477d56 adsf 2023-11-26 00:57:48 -06:00
a2cb09a706 adsf 2023-11-26 00:50:50 -06:00
f3ff162162 asdf 2023-11-26 00:48:08 -06:00
02120d559e asdf 2023-11-25 17:16:51 -06:00
d43c1205b2 asdf 2023-11-25 14:43:52 -06:00
4f1ea6ab15 asdf 2023-11-25 12:37:04 -06:00
867861e7a2 asdf 2023-11-25 12:00:08 -06:00
252661ad27 asdf 2023-11-25 11:23:52 -06:00
2671f86053 asdf 2023-11-25 11:21:31 -06:00
49ebe57241 adf 2023-11-25 11:12:51 -06:00
c13fca9b81 asdf 2023-11-25 10:31:19 -06:00
46d218189e asdf 2023-11-25 09:37:55 -06:00
90298eda14 asdf 2023-11-25 09:35:06 -06:00
7af7b14d60 as 2023-11-25 09:34:17 -06:00
3304edea4f asdf 2023-11-25 09:29:09 -06:00
f42faa5a2b asdf 2023-11-25 08:54:52 -06:00
021fedd120 asdf 2023-11-25 08:48:39 -06:00
b499c3a0f5 asdf 2023-11-25 08:45:04 -06:00
d3fa93811c asdf 2023-11-25 08:44:23 -06:00
010b284c92 asdf 2023-11-25 08:42:27 -06:00
29626671e9 a 2023-11-25 08:26:03 -06:00
8281959706 asdy 2023-11-25 08:02:30 -06:00
a604dd7cf0 fix 2023-11-25 07:57:29 -06:00
81dcff095f asd 2023-11-25 07:46:26 -06:00
2828628054 asdf 2023-11-25 02:41:12 -06:00
d6b656b1c2 ads 2023-11-25 02:38:05 -06:00
71c8eb7e27 fix 2023-11-25 02:36:00 -06:00
d594545288 fix 2023-11-25 02:27:14 -06:00
e00eb2c791 fix 2023-11-25 02:20:26 -06:00
d760fc07ae fix 2023-11-25 02:18:19 -06:00
0cb5962c60 asdf 2023-11-25 02:16:59 -06:00
da9412b1af test 2023-11-25 02:11:45 -06:00
c901a10a6a fixes 2023-11-25 01:09:31 -06:00
4a718e39e4 lockserver 2023-11-25 01:05:22 -06:00
4bc6f900b3 disable takistan for now 2023-11-25 00:19:05 -06:00
aea0f80e6c asdf 2023-11-24 03:04:33 -06:00
feba84fc29 asdf 2023-11-22 08:37:09 -06:00
83a1517a50 asdf 2023-11-22 08:23:55 -06:00
7ad7f72fbc asdf 2023-11-21 06:43:47 -06:00
c6433c254e asdf 2023-11-20 23:08:02 -06:00
9d3b5e583c final modeerver 2023-11-20 23:00:03 -06:00
979bb8a310 asdf 2023-11-20 22:56:14 -06:00
e5bfc97225 asdf 2023-11-20 22:15:00 -06:00
e8cea139a0 asdf 2023-11-20 22:06:50 -06:00
0fed5f3a85 asdf 2023-11-20 22:06:12 -06:00
ecff0eab79 asdf 2023-11-20 21:57:55 -06:00
1709319496 asdf 2023-11-20 21:50:56 -06:00
03ba9bc1bc asdf 2023-11-20 21:49:37 -06:00
99a8e96db7 asdf 2023-11-20 21:43:19 -06:00
5e1e8045fe asdf 2023-11-20 21:22:19 -06:00
c89798289c asdf 2023-11-20 21:20:44 -06:00
270c0ff2f2 asdf 2023-11-20 21:18:04 -06:00
7935bad092 asdf 2023-11-20 21:15:02 -06:00
1dcdddf2a7 asdf 2023-11-20 21:12:40 -06:00
857e163763 asdf 2023-11-20 21:11:08 -06:00
920b7da772 asdf 2023-11-20 21:10:27 -06:00
b30c0187d0 asdf 2023-11-20 21:09:46 -06:00
f448fd12c6 asdf 2023-11-20 21:08:31 -06:00
f190e47f69 asdf 2023-11-20 21:06:58 -06:00
2f00167519 asdf 2023-11-20 21:05:21 -06:00
d453db748f fix 2023-11-20 21:03:23 -06:00
1acaea558d fix 2023-11-20 21:01:55 -06:00
c718676fa0 asdf 2023-11-20 20:50:40 -06:00
b273607052 asdf 2023-11-20 20:46:46 -06:00
ddcfe9e2a3 asdf 2023-11-20 20:44:19 -06:00
366253f1f9 fisrt 2023-11-20 20:11:25 -06:00
cdf31ce541 asdf 2023-11-20 07:27:46 -06:00
4b0a9ee901 asdf 2023-11-20 07:25:02 -06:00
12105271d7 asdf 2023-11-20 07:24:11 -06:00
6be29407b1 asdf 2023-11-20 07:20:10 -06:00
0c036832be asdf 2023-11-20 07:18:35 -06:00
d709397585 asdf 2023-11-20 07:15:26 -06:00
cb35daab78 asdf 2023-11-20 07:12:42 -06:00
1118bdaa15 asdf 2023-11-20 07:08:11 -06:00
ab5069deb9 first 2023-11-20 07:05:11 -06:00
01b578a564 first 2023-11-20 07:04:16 -06:00
5ecd4c4f59 first 2023-11-20 07:01:50 -06:00
69ec6bd7be updates 2023-11-20 06:25:12 -06:00
bc2661b93f ad 2023-11-20 04:50:19 -06:00
2ca83e25d9 asdf 2023-11-20 04:46:26 -06:00
f0b1709f1c asdf 2023-11-20 04:37:41 -06:00
67d33f4967 old 2023-11-20 00:25:25 -06:00
60b6fe9bff asdf 2023-11-19 23:58:58 -06:00
ded9963beb Merge branch 'master' of ssh://gitea.local.wvr.sh:2221/mitch/dayz-servers 2023-11-19 23:57:04 -06:00
14d068bbc5 fix 2023-11-19 23:56:25 -06:00
232942354b asdf 2023-11-19 06:23:45 -06:00
wvr
1dc3d2357d initial 2023-05-14 15:57:37 -05:00
fc82ab2479 updates 2022-12-08 22:41:54 -06:00
ca0f533310 bug fixes 2022-12-08 00:40:29 -08:00
e5b775c597 more checks 2022-12-07 23:41:23 -08:00
a4d7e3006f warnd ont die if types doesnt exist 2022-12-07 23:37:15 -08:00
wvr
79a2c9edf0 new 2022-12-07 23:28:22 -06:00
wvr
e8b1389ebd after 2022-12-05 21:13:08 -06:00
wvr
b57f67b9b8 finished 2022-12-05 19:53:23 -06:00
wvr
e153c0ff1a more 2022-12-05 14:20:06 -06:00
c099bcce3c add 1.0 files 2022-12-05 13:06:43 -06:00
33405b22f8 add modserver files 2022-12-05 13:04:26 -06:00
25 changed files with 2071 additions and 0 deletions

403
ORIGINAL_start.sh Normal file
View File

@@ -0,0 +1,403 @@
#!/usr/bin/env bash
#
# shellcheck disable=2043
#
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# General Settings
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# export DAYZ_FILES=/mnt/dayz
# export STOCK_SERVER_DATA="$DAYZ_FILES/stock/DayZServer"
# export MAIN="/mnt/c/DAYZ"
# export SERVERS="$MAIN/servers"
# export CACHE="$MAIN/cache"
# export MOD_CACHE="$CACHE/mods"
# ORIGINAL_DIR="$PWD"
# export RESTART_INTERVAL=$((60 * 60 * 4 + 3))
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Helper functions
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# alias do_sync='rsync -rltDh --delete --partial'
# msg() {
# >&2 printf '[*] %s ...\n' "$*"
# }
# warn() {
# >&2 printf '\n\n<<<< WARNING: %s >>>>>\n\n' "$*"
# }
# die() {
# msg "$*"
# exit 1
# }
# debug() {
# if [ "$DEBUG" ] ; then
# >&2 printf ' DEBUG: %s\n' "$*"
# fi
# }
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Checks
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# check() {
# mkdir -p "$DAYZ_FILES"
# if ! mount | grep -i "$DAYZ_FILES" >/dev/null ; then
# msg "$DAYZ_FILES is not mounted!"
# echo "hint: mount -t drvfs //truenas.home.weaver/dayz $DAYZ_FILES"
# exit 1
# fi
# if [ ! -d "$MAIN" ] ; then
# die "$MAIN does not exist"
# fi
# if [ ! -d "$STOCK_SERVER_DATA" ] ; then
# die "$STOCK_SERVER_DATA does not exist"
# fi
# }
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Environment Setup
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# init() {
# mkdir -p "$SERVER_HOME" "$MOD_CACHE/$MAP_FOLDER_NAME"
# :>"$SERVER_HOME/.modstring"
# }
# setup_environment() {
# msg "Copying stock server data"
# # list of all stock folders
# for folder in addons battleye bliss docs dta keys ; do
# do_sync "$STOCK_SERVER_DATA/$folder"/ "$SERVER_HOME/$folder" || die "Failed to copy stock: $folder"
# done
# # list of all stock files
# for file in ban.txt dayz.gproj dayzsetting.xml whitelist.txt \
# DayZServer_x64.exe steam_api64.dll steamclient64.dll tier0_s64.dll vstdlib_s64.dll ; do
# cp -f "$STOCK_SERVER_DATA/$file" "$SERVER_HOME/$file" || die "Failed to copy stock: $file"
# done
# msg "Copying mod files"
# do_sync "$DAYZ_FILES/mods/$MAP_FOLDER_NAME"/ "$MOD_CACHE/$MAP_FOLDER_NAME" || die "Failed to copy mod files"
# # msg "Copying DZSA executable"
# # cp -f "$DAYZ_FILES/software/DZSALModServer.exe" "$SERVER_HOME/"
# }
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Load Mods
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# load_mods() {
# if [ ! -f "$MOD_CACHE/$MAP_FOLDER_NAME/mods.txt" ] ; then
# die "mods.txt list missing"
# fi
# mkdir -p "$SERVER_HOME/mods"
# _modstring=""
# while read -r mod ; do
# case $mod in
# '@'*)
# msg "- Found mod: $mod"
# _modstring="$_modstring;mods/$mod"
# do_sync "$MOD_CACHE/$MAP_FOLDER_NAME/$mod"/ "$SERVER_HOME/mods/$mod"
# for addon_folder in addons Addons addon Addon ; do
# if [ -d "$SERVER_HOME/mods/$mod/$addon_folder" ] ; then
# for addon in "$SERVER_HOME/mods/$mod/$addon_folder"/* ; do
# if [ ! -f "$SERVER_HOME/addons/${addon##*/}" ] ; then
# cp -f "$addon" "$SERVER_HOME/addons/"
# fi
# done
# fi
# done
# for key_folder in keys Keys key Key ; do
# if [ -d "$SERVER_HOME/mods/$mod/$key_folder" ] ; then
# for key in "$SERVER_HOME/mods/$mod/$key_folder"/* ; do
# if [ ! -f "$SERVER_HOME/keys/${key##*/}" ] ; then
# cp -f "$key" "$SERVER_HOME/keys/"
# fi
# done
# fi
# done
# esac
# done < "$MOD_CACHE/$MAP_FOLDER_NAME/mods.txt"
# # trim the initial leading ';'
# _modstring=${_modstring#;}
# printf '%s\n' "$_modstring" > .modstring
# }
# # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# # Load Map
# # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# load_stock_map_data() {
# mkdir -p "$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME"
# do_sync --exclude='*storage_1*' \
# "$DAYZ_FILES/stock/maps/$MAP_FOLDER_NAME"/ \
# "$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME" || \
# die "Failed to copy stock map data"
# }
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# 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
# if we're on namalsk, we will have a types_dzn.xml as well
# this file contains the frozen food etc unique namalsk items
case $MAP_FOLDER_NAME in
*namalsk*)
DZN_FILE=namalsk_dzn.sh
msg "Patching $DZN_FILE"
if [ -f "$DAYZ_FILES/server_configs/types/$DZN_FILE" ] ; then
cp -f "$DAYZ_FILES/server_configs/types/$DZN_FILE" \
"$SERVER_HOME"/
cd "$SERVER_HOME" || die "could not cd to $SERVER_HOME"
sh "$SERVER_HOME/$DZN_FILE" \
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/db/types_dzn.xml" || \
die "Failed while running maps types edit script on types_dzn.xml"
else
die "Could not find $DAYZ_FILES/server_configs/types/$DZN_FILE"
fi
;;
esac
}
load_customtypes() {
if [ -d "$DAYZ_FILES/server_configs/types/custom.$MAP_FOLDER_NAME" ] ; then
CUSTOM_TYPES="$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/customtypes"
CFG_ECORE="$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/cfgeconomycore.xml"
mkdir -p "$CUSTOM_TYPES"
do_sync "$DAYZ_FILES/server_configs/types/custom.$MAP_FOLDER_NAME"/ \
"$CUSTOM_TYPES"
for xml in "$CUSTOM_TYPES"/*.xml ; do
debug " - Found custom type: ${xml##*/}"
if [ -f "$xml" ] ; then
sed -E -i '/<\/economycore>/d' "$CFG_ECORE"
printf '\n<ce folder="db">\n<file name="customtypes/%s" type="types" />\n</ce>\n\n' "${xml##*/}" \
>> "$CFG_ECORE"
printf '%s\n' '</economycore>' >> "$CFG_ECORE"
fi
done
fi
# ============== custom SPAWNABLE types ===================
if [ -d "$DAYZ_FILES/server_configs/types/spawnabletypes.$MAP_FOLDER_NAME" ] ; then
msg "Copying custom spawnable types"
CUSTOM_SPAWNABLE_TYPES="$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/spawnabletypes"
CFG_SPAWNABLE_TYPES="$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/cfgspawnabletypes.xml"
mkdir -p "$CUSTOM_SPAWNABLE_TYPES"
do_sync "$DAYZ_FILES/server_configs/types/spawnabletypes.$MAP_FOLDER_NAME"/ \
"$CUSTOM_SPAWNABLE_TYPES"
for xml in "$CUSTOM_SPAWNABLE_TYPES"/*.xml ; do
debug " - Found custom spawnabletype: ${xml##*/}"
if [ -f "$xml" ] ; then
sed -E -i '/<\/spawnabletypes>/d' "$CFG_SPAWNABLE_TYPES"
cat "$xml" >> "$CFG_SPAWNABLE_TYPES"
printf '%s\n' '</spawnabletypes>' >> "$CFG_SPAWNABLE_TYPES"
fi
done
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_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
msg "Copying generic Profilesfolder configs"
if [ -d "$DAYZ_FILES/server_configs/Profilesfolder/sUDE/config" ] ; then
mkdir -p "$SERVER_HOME/Profilesfolder/sUDE/config"
cp -f "$DAYZ_FILES/server_configs/Profilesfolder/sUDE/config"/* "$SERVER_HOME/Profilesfolder/sUDE/config"/
else
die "missing: $DAYZ_FILES/server_configs/Profilesfolder/sUDE/config"
fi
}
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Main
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
main() {
# init
# cd "$SERVER_HOME" || die "Could not cd to '$SERVER_HOME'"
# check || die "Failed check"
# msg "Setting up environment"
# setup_environment || die "Could not set up environment."
# msg "Loading mods"
# load_mods || die "Could not load mods"
# mod_string=$(cat .modstring)
# 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"
load_customtypes || die "Failed to load custom types"
# creating temp.bat here to avoid the arg max char limit of windows cmd.exe
cat > temp.bat <<EOF
:start
start "DayZ Server" /min DZSALModServer.exe -config=serverDZ.cfg -port="$SERVER_PORT" -profiles=Profilesfolder -mod="$mod_string" -cpuCount="$SERVER_CPU" -dologs -adminlog -netlog -freezecheck
EOF
# start the server
cmd.exe /C temp.bat
echo '===================================='
printf '%s - Server started.\n' "$(date)"
echo '===================================='
printf '\n**** Sleeping for: %s *****\n\n' "$RESTART_INTERVAL"
count=0
while [ "$count" -lt "$RESTART_INTERVAL" ] ; do
sleep 60
count=$((count + 60))
msg "TIME LEFT BEFORE RESTART: $(( (RESTART_INTERVAL - count) / 60 )) minutes"
done
echo "==========================="
msg "Time up"
msg "Killing server"
cmd.exe /C taskkill /im DayZServer_x64.exe /F
rm -f temp.bat 2>/dev/null ||:
msg "Sleeping 10 seconds to settle"
sleep 10
msg "SERVER IS RESTARTING"
}
# while msg 'Starting loop' ; do
# cd "$ORIGINAL_DIR" || die "Can no longer cd to $ORIGINAL_DIR"
# if [ -e ./SERVER.ENV ] ; then
# . ./SERVER.ENV
# else
# die "Could not source ./SERVER.ENV"
# fi
# if [ -f ./serverDZ.cfg ] ; then
# cp -f ./serverDZ.cfg "$SERVER_HOME"/
# else
# die "Could not find ./serverDZ.cfg"
# fi
# main "$@"
# done

View File

@@ -0,0 +1,19 @@
{
"UpdateTime": 30,
"ServerInformation": [
{
"Name": "ZyaD Server Status",
"Address": "72.213.191.131:2305",
"Token": "MTA0ODc5MDAzNTM3NTMyOTM3MA.GlobiD.MDkpw9ySx15KiQkudeUPkA2FGAmIltIv9gi9H4",
"Status": 1,
"UseNameAsLabel": false,
"ProviderType": 0,
"ChannelID": null,
"StatusFormat": "Chernaurus: @Players/@MaxPlayers"
}
],
"ApplicationTokens": {
"SteamAPIKey": "21269ABF5364A400A6367F32109EC651",
"BattleMetricsKey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbiI6ImMyMTJhMTk0MDcyMjYzOGYiLCJpYXQiOjE2Njc5Njg3MTAsIm5iZiI6MTY2Nzk2ODcxMCwiaXNzIjoiaHR0cHM6Ly93d3cuYmF0dGxlbWV0cmljcy5jb20iLCJzdWIiOiJ1cm46dXNlcjo2MjY3MTAifQ.n8lc4qGwO2SYXvX50l2kbCHgi4dppW9P9G8sG2UB690"
}
}

Binary file not shown.

View File

@@ -0,0 +1,45 @@
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="console" />
<appender-ref ref="file" />
</root>
<!--File Appender-->
<appender name="file" type="log4net.Appender.RollingFileAppender">
<threshold value="ERROR"/>
<file value="warnings_and_errors.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<maximumFileSize value="25MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %logger - %message%newline" />
</layout>
</appender>
<!--Console appender-->
<appender name="console" type="log4net.Appender.ManagedColoredConsoleAppender">
<threshold value="INFO"/>
<mapping>
<level value="INFO" />
<forecolor value="Green" />
</mapping>
<mapping>
<level value="WARN" />
<forecolor value="Yellow" />
</mapping>
<mapping>
<level value="ERROR" />
<forecolor value="Red" />
</mapping>
<mapping>
<level value="DEBUG" />
<forecolor value="Blue" />
</mapping>
<layout type="log4net.Layout.PatternLayout">
<conversionpattern value="%date %-5level - %message%newline" />
</layout>
</appender>
</log4net>

View File

@@ -0,0 +1 @@
2022-12-03 22:12:29,734 ERROR PlayerCountBot.Providers.SteamProvider - [Steam] - 21cbba8c-0f4c-46f4-8ce0-52c27a808b8a - Server Address: 72.213.191.131:2305 was not found in Steam's directory.

View File

@@ -0,0 +1,11 @@
app id:
1048790035375329370
pub key:
15a2d69333ab4d3c7fe52cefce65a86fbfd607a0c39a23a85958b5b1529bd5d6
permission integer:
829531688784
token:
MTA0ODc5MDAzNTM3NTMyOTM3MA.GlobiD.MDkpw9ySx15KiQkudeUPkA2FGAmIltIv9gi9H4

BIN
archive/discord/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

View File

@@ -0,0 +1 @@
1048793047376351282

404
archive/start.sh Normal file
View File

@@ -0,0 +1,404 @@
#!/usr/bin/env bash
#
# shellcheck disable=2043
#
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# General Settings
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
export DAYZ_FILES=/mnt/dayz
export STOCK_SERVER_DATA="$DAYZ_FILES/stock/DayZServer"
export MAIN="/mnt/c/DAYZ"
export SERVERS="$MAIN/servers"
export CACHE="$MAIN/cache"
export MOD_CACHE="$CACHE/mods"
export RESTART_INTERVAL=$((60 * 60 * 4 + 3))
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Helper functions
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
alias do_sync='rsync -rltDh --delete --partial'
msg() {
>&2 printf '[*] %s ...\n' "$*"
}
warn() {
>&2 printf '\n\n<<<< WARNING: %s >>>>>\n\n' "$*"
}
die() {
msg "$*"
exit 1
}
debug() {
if [ "$DEBUG" ] ; then
>&2 printf ' DEBUG: %s\n' "$*"
fi
}
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Checks
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
check() {
mkdir -p "$DAYZ_FILES"
if ! mount | grep -i "$DAYZ_FILES" >/dev/null ; then
msg "$DAYZ_FILES is not mounted!"
echo "hint: mount -t drvfs //truenas.home.weaver/dayz $DAYZ_FILES"
exit 1
fi
if [ ! -d "$MAIN" ] ; then
die "$MAIN does not exist"
fi
if [ ! -d "$STOCK_SERVER_DATA" ] ; then
die "$STOCK_SERVER_DATA does not exist"
fi
}
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Environment Setup
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
init() {
mkdir -p "$SERVER_HOME" "$MOD_CACHE/$MAP_FOLDER_NAME"
:>"$SERVER_HOME/.modstring"
}
setup_environment() {
msg "Copying stock server data"
# list of all stock folders
for folder in addons battleye bliss docs dta keys ; do
do_sync "$STOCK_SERVER_DATA/$folder"/ "$SERVER_HOME/$folder" || die "Failed to copy stock: $folder"
done
# list of all stock files
for file in ban.txt dayz.gproj dayzsetting.xml whitelist.txt \
DayZServer_x64.exe steam_api64.dll steamclient64.dll tier0_s64.dll vstdlib_s64.dll ; do
cp -f "$STOCK_SERVER_DATA/$file" "$SERVER_HOME/$file" || die "Failed to copy stock: $file"
done
msg "Copying mod files"
do_sync "$DAYZ_FILES/mods/$MAP_FOLDER_NAME"/ "$MOD_CACHE/$MAP_FOLDER_NAME" || die "Failed to copy mod files"
msg "Copying DZSA executable"
cp -f "$DAYZ_FILES/software/DZSALModServer.exe" "$SERVER_HOME/"
}
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Load Mods
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
load_mods() {
if [ ! -f "$MOD_CACHE/$MAP_FOLDER_NAME/mods.txt" ] ; then
die "mods.txt list missing"
fi
mkdir -p "$SERVER_HOME/mods"
_modstring=""
while read -r mod ; do
case $mod in
'@'*)
msg "- Found mod: $mod"
_modstring="$_modstring;mods/$mod"
do_sync "$MOD_CACHE/$MAP_FOLDER_NAME/$mod"/ "$SERVER_HOME/mods/$mod"
for addon_folder in addons Addons addon Addon ; do
if [ -d "$SERVER_HOME/mods/$mod/$addon_folder" ] ; then
for addon in "$SERVER_HOME/mods/$mod/$addon_folder"/* ; do
if [ ! -f "$SERVER_HOME/addons/${addon##*/}" ] ; then
cp -f "$addon" "$SERVER_HOME/addons/"
fi
done
fi
done
for key_folder in keys Keys key Key ; do
if [ -d "$SERVER_HOME/mods/$mod/$key_folder" ] ; then
for key in "$SERVER_HOME/mods/$mod/$key_folder"/* ; do
if [ ! -f "$SERVER_HOME/keys/${key##*/}" ] ; then
cp -f "$key" "$SERVER_HOME/keys/"
fi
done
fi
done
esac
done < "$MOD_CACHE/$MAP_FOLDER_NAME/mods.txt"
# trim the initial leading ';'
_modstring=${_modstring#;}
printf '%s\n' "$_modstring" > .modstring
}
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Load Map
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
load_stock_map_data() {
mkdir -p "$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME"
do_sync --exclude='*storage_1*' \
"$DAYZ_FILES/stock/maps/$MAP_FOLDER_NAME"/ \
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME" || \
die "Failed to copy stock map data"
}
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# 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
# if we're on namalsk, we will have a types_dzn.xml as well
# this file contains the frozen food etc unique namalsk items
case $MAP_FOLDER_NAME in
*namalsk*)
DZN_FILE=namalsk_dzn.sh
msg "Patching $DZN_FILE"
if [ -f "$DAYZ_FILES/server_configs/types/$DZN_FILE" ] ; then
cp -f "$DAYZ_FILES/server_configs/types/$DZN_FILE" \
"$SERVER_HOME"/
cd "$SERVER_HOME" || die "could not cd to $SERVER_HOME"
sh "$SERVER_HOME/$DZN_FILE" \
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/db/types_dzn.xml" || \
die "Failed while running maps types edit script on types_dzn.xml"
else
die "Could not find $DAYZ_FILES/server_configs/types/$DZN_FILE"
fi
;;
esac
}
load_customtypes() {
if [ -d "$DAYZ_FILES/server_configs/types/custom.$MAP_FOLDER_NAME" ] ; then
CUSTOM_TYPES="$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/customtypes"
CFG_ECORE="$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/cfgeconomycore.xml"
mkdir -p "$CUSTOM_TYPES"
do_sync "$DAYZ_FILES/server_configs/types/custom.$MAP_FOLDER_NAME"/ \
"$CUSTOM_TYPES"
for xml in "$CUSTOM_TYPES"/*.xml ; do
debug " - Found custom type: ${xml##*/}"
if [ -f "$xml" ] ; then
sed -E -i '/<\/economycore>/d' "$CFG_ECORE"
printf '\n<ce folder="db">\n<file name="customtypes/%s" type="types" />\n</ce>\n\n' "${xml##*/}" \
>> "$CFG_ECORE"
printf '%s\n' '</economycore>' >> "$CFG_ECORE"
fi
done
fi
# ============== custom SPAWNABLE types ===================
if [ -d "$DAYZ_FILES/server_configs/types/spawnabletypes.$MAP_FOLDER_NAME" ] ; then
msg "Copying custom spawnable types"
CUSTOM_SPAWNABLE_TYPES="$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/spawnabletypes"
CFG_SPAWNABLE_TYPES="$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/cfgspawnabletypes.xml"
mkdir -p "$CUSTOM_SPAWNABLE_TYPES"
do_sync "$DAYZ_FILES/server_configs/types/spawnabletypes.$MAP_FOLDER_NAME"/ \
"$CUSTOM_SPAWNABLE_TYPES"
for xml in "$CUSTOM_SPAWNABLE_TYPES"/*.xml ; do
debug " - Found custom spawnabletype: ${xml##*/}"
if [ -f "$xml" ] ; then
sed -E -i '/<\/spawnabletypes>/d' "$CFG_SPAWNABLE_TYPES"
cat "$xml" >> "$CFG_SPAWNABLE_TYPES"
printf '%s\n' '</spawnabletypes>' >> "$CFG_SPAWNABLE_TYPES"
fi
done
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_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
msg "Copying generic Profilesfolder configs"
if [ -d "$DAYZ_FILES/server_configs/Profilesfolder/sUDE/config" ] ; then
mkdir -p "$SERVER_HOME/Profilesfolder/sUDE/config"
cp -f "$DAYZ_FILES/server_configs/Profilesfolder/sUDE/config"/* "$SERVER_HOME/Profilesfolder/sUDE/config"/
else
die "missing: $DAYZ_FILES/server_configs/Profilesfolder/sUDE/config"
fi
}
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# Main
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
main() {
init
cd "$SERVER_HOME" || die "Could not cd to '$SERVER_HOME'"
check || die "Failed check"
msg "Setting up environment"
setup_environment || die "Could not set up environment."
msg "Loading mods"
load_mods || die "Could not load mods"
mod_string=$(cat .modstring)
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"
load_customtypes || die "Failed to load custom types"
echo '===================================='
printf '%s - Server started.\n' "$(date)"
echo '===================================='
# creating temp.bat here to avoid the arg max char limit of windows cmd.exe
cat > temp.bat <<EOF
:start
start "DayZ Server" /min DZSALModServer.exe -config=serverDZ.cfg -port="$SERVER_PORT" -profiles=Profilesfolder -mod="$mod_string" -cpuCount="$SERVER_CPU" -dologs -adminlog -netlog -freezecheck
EOF
cmd.exe /C temp.bat
printf '\n**** Sleeping for: %s *****\n\n' "$RESTART_INTERVAL"
count=0
while [ "$count" -lt "$RESTART_INTERVAL" ] ; do
sleep 60
count=$((count + 60))
msg "TIME LEFT BEFORE RESTART: $(( (RESTART_INTERVAL - count) / 60 )) minutes"
done
echo "==========================="
msg "Time up"
msg "Killing server"
cmd.exe /C taskkill /im DayZServer_x64.exe /F
rm -f temp.bat 2>/dev/null ||:
msg "Sleeping 10 seconds to settle"
sleep 10
msg "SERVER IS RESTARTING"
}
ORIGINAL_DIR="$PWD"
while msg 'Starting loop' ; do
cd "$ORIGINAL_DIR" || die "Can no longer cd to $ORIGINAL_DIR"
if [ -e ./SERVER.ENV ] ; then
. ./SERVER.ENV
else
die "Could not source ./SERVER.ENV"
fi
if [ -f ./serverDZ.cfg ] ; then
cp -f ./serverDZ.cfg "$SERVER_HOME"/
else
die "Could not find ./serverDZ.cfg"
fi
main "$@"
done

168
lib/globals.sh Normal file
View File

@@ -0,0 +1,168 @@
#!/bin/sh -e
#
# values used on both the modserver and individual servers
# ------------------------------------------------------------
################### GLOBAL VARS ##############################
export DAYZ_GAME_ID=221100
export DAYZ_SERVER_ID=223350
export STEAM_USER="yzaddayz"
# blank debug to unset it by default
export DEBUG=
export REMOTE_DAYZ_TRUENAS_SHARE='\\dayz-truenas.local.wvr.sh\dayz'
export REMOTE_DIR="/mnt/dayz"
export REMOTE_SERVER_LOCKFILE="$REMOTE_DIR/lockfile"
export REMOTE_MAPS="$REMOTE_DIR/stock/maps"
export REMOTE_MODS="$REMOTE_DIR/mods"
export REMOTE_STOCK_SERVER="$REMOTE_DIR/stock/DayZServer"
export REMOTE_STOCK_GAME="$REMOTE_DIR/stock/DayZ"
export CHERNARUS_MAP_NAME=dayzOffline.chernarusplus
export NAMALSK_MAP_NAME=regular.namalsk
export TAKISTAN_MAP_NAME=Offline.TakistanPlus
# NAMALSK_SURVIVAL is what the terrain/map comes with
export NAMALSK_SURVIVAL_MOD_ID=2289461232
export NAMALSK_ISLAND_MOD_ID=2289456201
export TAKISTAN_MOD_ID=2563233742
################### GLOBAL VARS ##############################
################### GLOBAL ALIASES ###########################
unalias rsync 2>/dev/null ||:
alias do_sync='rsync -avhu --progress --delete --partial --links'
################### GLOBAL ALIASES ###########################
################### GLOBAL FUNCTIONS #########################
msg() {
printf '>>>>>[MESSAGE]: %s\n' "$*"
}
errmsg() {
>&2 printf '>>>>>>[ERROR]: %s\n' "$*"
}
die() {
errmsg "$*"
exit 1
}
debug() {
if [ "$DEBUG" ] ; then
>&2 printf '>>>>>>DEBUG: %s\n' "$*"
fi
}
isempty() {
for arg in "$@" ; do
# exit in error if file
if [ -f "$arg" ] ; then
exit 1
elif [ -L "$arg" ] ; then
# if is a symlink, check what it points to
# note: this only checks one-link level deep
if [ -d "$(readlink "$arg")" ] ; then
exit 0
else
exit 1
fi
elif [ -d "$arg" ] ; then
:
else
# is not a directory or a link to a directory
exit 1
fi
# there should be a way to make this be builtins only
# using printf and glob expansions, look into later
if /bin/rmdir "$arg" 2>/dev/null ; then
/bin/mkdir -p "$arg"
exit 0
else
exit 1
fi
done
}
mount_dayz_network_drive() {
if ! is_network_drive_mounted ; then
if [ ! -d /mnt/dayz ] ; then
sudo mkdir -p /mnt/dayz
fi
if [ -e /proc/version ] ; then
read -r ver < /proc/version
case $ver in
# WSL
*icrosoft*)
msg "Detected WSL, mounting via drvfs"
sudo mount -t drvfs -o user=samba \
"$REMOTE_DAYZ_TRUENAS_SHARE" /mnt/dayz
;;
*)
msg "Detected Linux, mounting via cifs"
# shellcheck disable=2046
sudo mount -t cifs "$REMOTE_DAYZ_TRUENAS_SHARE" /mnt/dayz \
-o rw \
-o credentials=/root/sambacreds.txt \
-o iocharset=utf8 \
-o vers=3.0 \
-o uid=$(id -u) \
-o gid=$(id -g)
esac
unset ver
else
errmsg 'could not find /proc/version'
exit 1
fi
fi
if ! is_network_drive_mounted ; then
errmsg 'Could not mount network drive'
exit 1
fi
}
is_network_drive_mounted() {
if [ ! -f "$REMOTE_DIR/canary" ] ; then
return 1
fi
# test write
touch /mnt/dayz/canary.test
if [ $? -eq 0 ] ; then
rm /mnt/dayz/canary.test
else
errmsg "Mounted network drive but we do not have write access."
exit 1
fi
}
# =====================================================================================
islocked_remote_server() {
if [ -e "$REMOTE_SERVER_LOCKFILE" ] ; then
# msg "Server is not currently locked!"
return 0
else
return 1
fi
}
lock_remote_server() {
msg "Locking remote server."
if ! echo 'locked' | tee "$REMOTE_SERVER_LOCKFILE" ; then
die "Could not create: $REMOTE_SERVER_LOCKFILE"
fi
}
unlock_remote_server() {
msg "Unlocking remote server."
rm -f "$REMOTE_SERVER_LOCKFILE" || die "Could not remove: $REMOTE_SERVER_LOCKFILE"
}
wait_until_remote_server_unlocked() {
# wait until dayz-modserver lockfile is released on the NAS
if islocked_remote_server ; then
msg "Remote file server is currently locked"
msg "Sleeping until is no longer locked..."
while islocked_remote_server ; do
echo "Sleeping..."
sleep 10
done
msg "Server unlocked! Continuing..."
fi
}
# =====================================================================================

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 "$@"

14
lib/webhook.sh Normal file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
webhook_url="https://discord.com/api/webhooks/1176483934008262749/F2fav42fOyucZcgf-0z9o7iY9AkCPCNBfhazdeUU-9Ycc7jnhO7l12xS-F7idbK60xtz"
msg() {
message="$(printf '%s' "$*" | jq -Rsa .)"
curl -s \
-X POST "$webhook_url" \
-H "Content-Type:application/json" \
--data "{\"content\": $message}"
}
msg "$@"

View File

@@ -0,0 +1,2 @@
# Takistan Map
2563233742^takistan

View File

@@ -0,0 +1,137 @@
# ==================================================================
# Generic / All Servers
# ==================================================================
# Dabs Framework
# https://steamcommunity.com/sharedfiles/filedetails/?id=2545327648
2545327648^dabsframework
# CF
# https://steamcommunity.com/sharedfiles/filedetails/?id=1559212036
1559212036^cf
# VPP Admin Tools
# https://steamcommunity.com/sharedfiles/filedetails/?id=1828439124
############################ 1828439124^vppadmintools
# Ear Plugs
# https://steamcommunity.com/workshop/filedetails/?id=1819514788
############################ 1819514788^earplugs
# health regen 2x when blood is full
# https://steamcommunity.com/sharedfiles/filedetails/?id=2434838000&searchtext=health
############################ 2434838000^healthregen
# tent backpacks
# https://steamcommunity.com/sharedfiles/filedetails/?id=2884638645
############################ 2884638645^tentbackpacks
# durable suppressors (1.5x health)
# https://steamcommunity.com/sharedfiles/filedetails/?id=2880585815
############################ 2880585815^durablesuppressors
# Zen's Cause of Death
# https://steamcommunity.com/sharedfiles/filedetails/?id=2810260908
############################ 2810260908^causeofdeath
# Bear Buff (bears aggro from further away, chase players)
# https://steamcommunity.com/sharedfiles/filedetails/?id=2692521272
############################ 2692521272^bearbuff
# Custom Animations
# https://steamcommunity.com/sharedfiles/filedetails/?id=2545980712
############################ 2545980712^customanimations
# Worn Repair
# https://steamcommunity.com/sharedfiles/filedetails/?id=2581770969
############################ 2581770969^wornrepair
# No DepthOfField
# https://steamcommunity.com/sharedfiles/filedetails/?id=1721317955
############################ 1721317955^nodof
# Zen's Fire Fuel
# https://steamcommunity.com/sharedfiles/filedetails/?id=2866862200
############################ 2866862200^firefuel
# Zen's Gun Move Sounds
# https://steamcommunity.com/sharedfiles/filedetails/?id=2832627966
############################ 2832627966^gunmovesounds
# Bad Food
# https://steamcommunity.com/sharedfiles/filedetails/?id=2155069271
############################ 2155069271^badfood
# ==================================================================
# sUDE
# ==================================================================
# sFramework
# https://steamcommunity.com/sharedfiles/filedetails/?id=2614334381
############################ 2614334381^sframework
# sVisual
# https://steamcommunity.com/sharedfiles/filedetails/?id=2469448088
############################ 2469448088^svisual
# ==================================================================
# Chernarus Specific
# ==================================================================
# spurgles bagz
# https://steamcommunity.com/sharedfiles/filedetails/?id=2489196158
############################ 2489196158^spurglesbagz
# fliptransport
# https://steamcommunity.com/sharedfiles/filedetails/?id=1832448183
############################ 1832448183^fliptransport
# no weapon raise
# https://steamcommunity.com/sharedfiles/filedetails/?id=2098390861
############################ 2098390861^noweaponraise
# no vehicle damage
# https://steamcommunity.com/sharedfiles/filedetails/?id=1735947752
############################ 1735947752^novehicledamage
# Doc's Car Fixes
# https://steamcommunity.com/sharedfiles/filedetails/?id=2886222035
############################ 2886222035^docscarfixes
# Lag's Lighting Overhaul
# https://steamcommunity.com/sharedfiles/filedetails/?id=2873016243
############################ 2873016243^ladslightingoverhaul
# Uncuepa's Civilian Clothing
# https://steamcommunity.com/sharedfiles/filedetails/?id=1762444175
############################ 1762444175^uncuepascivilianclothing
# ==================================================================
# Inactive
# ==================================================================
############ Legacy Gun Play
############ https://steamcommunity.com/sharedfiles/filedetails/?id=2560589980
###########2560589980^legacygunplay
############### advanced weapon scopes
################ https://steamcommunity.com/sharedfiles/filedetails/?id=2143128974
###############2143128974^advancedweaponscopes
############ tactical flava
############# https://steamcommunity.com/sharedfiles/filedetails/?id=2646817942
###########2646817942^tacticalflava
############## sGunplay
############## https://steamcommunity.com/sharedfiles/filedetails/?id=2507204412
#############2507204412^sgunplay
################## enough stamina
################## https://steamcommunity.com/sharedfiles/filedetails/?id=2337398072
#################2337398072^enoughstamina
#################### Notes
#################### https://steamcommunity.com/sharedfiles/filedetails/?id=1999076953
###################1999076953^notes

View File

@@ -0,0 +1,39 @@
# Namalsk Survival
# https://steamcommunity.com/sharedfiles/filedetails/?id=2289461232
2289461232^namalsksurvival
# Namalsk Island
# https://steamcommunity.com/sharedfiles/filedetails/?id=2289456201
2289456201^namalskisland
#@dabsframework
#@cf
#@vppadmintools
#@notes
#@earplugs
#@healthregen
#@tentbackpacks
#@durablesuppressors
#@causeofdeath
#@bearbuff
#@customanimations
#@wornrepair
#@nodof
#@firefuel
#@gunmovesounds
#@badfood
#@noweaponraise
#@docscarfixes
#@novehicledamage
#@fliptransport
#@spurglesbagz
#@sframework
#@svisual
#@skyz
#@namalskisland
#@namalsksurvival
#@svisualnamalsk
#@gaussrifle
#@namalskigloo
#@frozencorpses
#@polarbarrenamefix

305
modserver_update.sh Normal file
View File

@@ -0,0 +1,305 @@
#!/bin/sh -e
#
# 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
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# ===================================================
# 01. Attempt to load global DayZ values
# ===================================================
echo "Starting, attempting to load 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
chmod +x "$GLOBALS_FILE"
. "$GLOBALS_FILE"
else
>&2 echo "Could not load: $GLOBALS_FILE"
exit 1
fi
# ===================================================
# 02. Local script variables
# ===================================================
export STEAMCMD_USER=steam
export MODLISTS="$WORKING_DIR/modlists"
export LOCAL_STOCK="$HOME/stock"
export LOCAL_STOCK_GAME="$LOCAL_STOCK/DayZ"
export LOCAL_STOCK_SERVER="$LOCAL_STOCK/DayZServer"
export LOCAL_MODS="$HOME/mods"
# ===================================================
# 03. Mount network drive
# ===================================================
if ! is_network_drive_mounted ; then
mount_dayz_network_drive
if ! is_network_drive_mounted ; then
die "Could not mount network drive"
fi
fi
# ===================================================
# 04. Checks
# ===================================================
check() {
mkdir -p "$LOCAL_STOCK_GAME" "$LOCAL_STOCK_SERVER" "$LOCAL_MODS"
if [ "$USER" != "$STEAMCMD_USER" ] ; then
die "Current user: '$USER' does not match '$STEAMCMD_USER'"
fi
if [ ! -d "$MODLISTS" ] ; then
die "Could not find modlists at: $MODLISTS"
fi
if [ ! -d "$REMOTE_MODS" ] ; then
die "Could not find remote mods at: $REMOTE_MODS"
fi
if [ ! -d "$REMOTE_MAPS" ] ; then
die "Could not find remote maps at: $REMOTE_MAPS"
fi
if islocked_remote_server ; then
die "Remote server already locked?"
fi
msg "(MODSERVER): Health checks passed successfully."
}
# ===================================================
# 05. Begin functions
# ===================================================
update_server() {
msg "(MODSERVER): STARTING UPDATING DAYZ SERVER"
steamcmd -tcp \
+force_install_dir "$LOCAL_STOCK_SERVER" \
+@sSteamCmdForcePlatformType windows \
+@ShutdownOnFailedCommand 1 \
+login "$STEAM_USER" \
+app_update "$DAYZ_SERVER_ID" \
+quit
is_network_drive_mounted &&
do_sync "$LOCAL_STOCK_SERVER"/ "$REMOTE_STOCK_SERVER"
msg "(MODSERVER): FINISHED UPDATING DAYZ SERVER"
}
update_game() {
msg "(MODSERVER): STARTING UPDATING DAYZ GAME"
steamcmd -tcp \
+force_install_dir "$LOCAL_STOCK_GAME" \
+@sSteamCmdForcePlatformType windows \
+@ShutdownOnFailedCommand 1 \
+login "$STEAM_USER" \
+app_update "$DAYZ_GAME_ID" \
+quit
is_network_drive_mounted &&
do_sync "$LOCAL_STOCK_GAME"/ "$REMOTE_STOCK_GAME"
msg "(MODSERVER): FINISHED UPDATING DAYZ GAME"
}
# args: $1 = server_modlist.txt to update
update_mods_for_server() {
msg "(MODSERVER): UPDATING MODS FOR MAP: $1"
mods_file="$MODLISTS/$1"
map_name=${1%.txt}
remote_map_mod_dir="$REMOTE_MODS/$map_name"
mkdir -p "$remote_map_mod_dir"
# Create temporary file to list all the mod_id's we are
# going to download. This speeds up steamcmd and avoids rate limits.
tempfile="/tmp/$map_name-mods_to_download.txt"
:> "$tempfile"
# load the server_modlist.txt, copying the mod id's we need to update
# to the temp file, while skipping comments and blank lines
#
# format should be: "mod_id^nickname"
#
# # Dabs Framework
# # https://steamcommunity.com/sharedfiles/filedetails/?id=2545327648
# 2545327648^dabsframework
#
while read -r mod ; do
case "$mod" in
\#*|''|' ')
;;
*)
mod=${mod%%^*}
# check validity of syntax
if [ -z "$mod" ] ; then
die "mod for $map_name appears to be empty - syntax error"
fi
printf "+workshop_download_item $DAYZ_GAME_ID %s\n" "$mod" >> "$tempfile"
esac
done <"$mods_file"
unset mod
# shellcheck disable=2046
steamcmd \
-tcp \
+force_install_dir "$LOCAL_MODS" \
+@sSteamCmdForcePlatformType windows \
+@ShutdownOnFailedCommand 1 \
+login "$STEAM_USER" \
$(xargs < "$tempfile") \
+quit
if [ $? -ne 0 ] ; then
die "Problem downloading mods for $map_name"
fi
msg "(MODSERVER): RENAMING MODS"
# blank map's mods.txt
:> "$remote_map_mod_dir/mods.txt"
while read -r mod ; do
# skip comments, blank lines
case "$mod" in
\#*|''|' ')
;;
*)
mod_id=${mod%%^*}
mod_name=${mod##*^}
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"
fi
do_sync "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$mod_id"/ "$remote_map_mod_dir/@${mod_name}"
printf '@%s\n' "$mod_name" >> "$remote_map_mod_dir/mods.txt"
msg "(MODSERVER): Finished syncing: $mod_name"
esac
done < "$mods_file"
rm -f "$tempfile" 2>/dev/null ||:
unset tempfile mod map_name mods_file mod_name mod_id remote_map_mod_dir
msg "(MODSERVER): FINISHED UPDATING MODS FOR MAP: $1"
}
update_stock_maps() {
msg "(MODSERVER): UPDATING MAPS"
msg "(MODSERVER): Copying Stock Chernarus"
do_sync \
"$LOCAL_STOCK_SERVER/mpmissions/$CHERNARUS_MAP_NAME"/ \
"$REMOTE_MAPS/$CHERNARUS_MAP_NAME"
msg "(MODSERVER): Updating Namalsk Survival"
steamcmd \
-tcp \
+force_install_dir "$LOCAL_MODS" \
+@sSteamCmdForcePlatformType windows \
+@ShutdownOnFailedCommand 1 \
+login "$STEAM_USER" \
+workshop_download_item \
"$DAYZ_GAME_ID" \
"$NAMALSK_SURVIVAL_MOD_ID" \
+quit
if [ $? -ne 0 ] ; then
die "Failed to update Namalsk Survival"
fi
if [ -d "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$NAMALSK_SURVIVAL_MOD_ID/Extras/Regular/$NAMALSK_MAP_NAME" ] ; then
do_sync "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$NAMALSK_SURVIVAL_MOD_ID/Extras/Regular/$NAMALSK_MAP_NAME"/ \
"$REMOTE_MAPS/$NAMALSK_MAP_NAME" || \
die "failed to copy Namalsk map files"
fi
msg "(MODSERVER): Updating Namalsk Island"
steamcmd \
-tcp \
+force_install_dir "$LOCAL_MODS" \
+@sSteamCmdForcePlatformType windows \
+@ShutdownOnFailedCommand 1 \
+login "$STEAM_USER" \
+workshop_download_item \
"$DAYZ_GAME_ID" \
"$NAMALSK_ISLAND_MOD_ID" \
+quit
if [ $? -ne 0 ] ; then
die "Failed to update Namalsk Island"
fi
####################TODO: # msg "Updating Optimized Namalsk Server PBOs"
msg "(MODSERVER): Updating TakistanPlus"
steamcmd \
-tcp \
+force_install_dir "$LOCAL_MODS" \
+@sSteamCmdForcePlatformType windows \
+@ShutdownOnFailedCommand 1 \
+login "$STEAM_USER" \
+workshop_download_item \
"$DAYZ_GAME_ID" \
"$TAKISTAN_MOD_ID" \
+quit
if [ $? -ne 0 ] ; then
die "Failed to update TakistanPlus"
fi
if [ -d "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$TAKISTAN_MOD_ID/Mission/$TAKISTAN_MAP_NAME" ] ; then
do_sync "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$TAKISTAN_MOD_ID/Mission/$TAKISTAN_MAP_NAME"/ \
"$REMOTE_MAPS/$TAKISTAN_MAP_NAME" || \
die "failed to copy Takistan map files"
fi
}
main() {
check || die "Failed to pass health checks"
lock_remote_server
update_server
update_game
update_stock_maps
for server in $(ls "$MODLISTS" | xargs) ; do
if [ ! -f "$MODLISTS/$server" ] ; then
msg "(MODSERVER): Could not find modlist for: $MODLISTS/$server"
continue
fi
update_mods_for_server "$server"
unset server
done
unlock_remote_server
}
main "$@" || exit 1

View File

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

18
scripts/linux-setup.sh Normal file
View File

@@ -0,0 +1,18 @@
#!/bin/sh
cd $HOME
# =========================================================
# RUN MY GENERIC SETUP SCRIPT
# =========================================================
git clone https://gitea.local.wvr.sh/mitch/linux-setup.git
cd linux-setup
sh setup.sh
cp update.sh $HOME/
chmod +x update.sh
# =========================================================
# for modserver
sudo apt install -y xmlstarlet jq cifs-utils samba-common

6
scripts/re-pull-git.sh Normal file
View File

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

View File

@@ -0,0 +1,6 @@
#!/bin/sh
. ./lib/globals.sh
unlock_remote_server

283
server_start.sh Normal file
View File

@@ -0,0 +1,283 @@
#!/bin/sh -e
#
# 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
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
# ===================================================
# 01. Attempt to load global DayZ values
# ===================================================
echo "Starting, attempting to load globals.sh"
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
# ===================================================
# 02. Local script variables
# ===================================================
#
#
# Local server file hierarchy:
#
# c:/DAYZ
# ^--/servers
# ^--/cache
#
export ORIGINAL_DIR="$PWD"
export LOCAL_DAYZ_FILES="/mnt/c/DAYZ"
export CACHE="$LOCAL_DAYZ_FILES/cache"
export STOCK_SERVER_CACHE="$CACHE/stock_server"
export MOD_CACHE="$CACHE/mods"
export SERVERS="$LOCAL_DAYZ_FILES/servers"
# ===================================================
# 03. Mount network drive
# ===================================================
if ! is_network_drive_mounted ; then
mount_dayz_network_drive
if ! is_network_drive_mounted ; then
die "Could not mount network drive"
fi
fi
# ===================================================
# 04. init and checks
# ===================================================
check() {
if [ ! -d "$LOCAL_DAYZ_FILES" ] ; then
die "dir: $LOCAL_DAYZ_FILES does not exist"
fi
if [ ! -d "$SERVER_HOME" ] ; then
die "dir: $SERVER_HOME does not exist"
fi
msg "Health checks completed successfully."
}
init_server() {
mkdir -p "$SERVER_HOME" "$CACHE" "$MOD_CACHE" "$STOCK_SERVER_CACHE" "$LOCAL_DAYZ_FILES/stock/maps/$MAP_FOLDER_NAME"
:>"$SERVER_HOME/modstring"
check || die "Failed check()"
msg "Completed intialization. Using server restart time of $RESTART_INTERVAL seconds."
}
# ===================================================
# 05. Load stock files
# ===================================================
load_stock_map_data() {
mkdir -p "$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME"
do_sync --exclude='*storage_1*' \
"$LOCAL_DAYZ_FILES/stock/maps/$MAP_FOLDER_NAME"/ \
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME" || \
die "Failed to copy remote stock map data to local cache"
}
refresh_local_cache() {
msg "Refreshing local stock server cache"
wait_until_remote_server_unlocked
do_sync "$REMOTE_STOCK_SERVER"/ "$STOCK_SERVER_CACHE" || \
die "Failed to copy remote stock server data to local cache"
msg "Sucessfully copied stock server data into local cache"
# -------------------------------------
msg "Refreshing local map data cache for: $MAP_FOLDER_NAME"
wait_until_remote_server_unlocked
do_sync "$REMOTE_MAPS/$MAP_FOLDER_NAME"/ "$LOCAL_DAYZ_FILES/stock/maps/$MAP_FOLDER_NAME" || \
die "Failed to copy remote stock map data for: $MAP_FOLDER_NAME"
msg "Successfully copied stock map data for: $MAP_FOLDER_NAME"
# -------------------------------------
msg "Refreshing local mods cache"
wait_until_remote_server_unlocked
do_sync "$REMOTE_MODS"/ "$MOD_CACHE" || \
die "Failed to copy remote mods to local cache"
msg "Successfully copied remote mods into local cache"
}
setup_environment() {
msg "Setting up environment"
msg "Copying stock server data from local cache into $SERVER_HOME"
# list of all stock server folders
for folder in addons battleye bliss docs dta keys ; do
do_sync "$STOCK_SERVER_CACHE/$folder"/ "$SERVER_HOME/$folder" || die "Failed to copy stock: $folder"
done
# list of all stock server files
for file in dayz.gproj dayzsetting.xml whitelist.txt \
DayZServer_x64.exe steam_api64.dll steamclient64.dll \
tier0_s64.dll vstdlib_s64.dll ; do
cp -fv "$STOCK_SERVER_CACHE/$file" "$SERVER_HOME/$file" || die "Failed to copy stock: $file"
done
msg "Copying into $SERVER_HOME stock map data for: $MAP_FOLDER_NAME"
load_stock_map_data
msg "Copying mod files from local cache into $SERVER_HOME"
do_sync "$MOD_CACHE/$MAP_FOLDER_NAME"/ "$SERVER_HOME/mods" || die "Failed to copy mods to $SERVER_HOME"
msg "Copying DZSA executable"
wait_until_remote_server_unlocked
do_sync "$REMOTE_DIR/res/software/DZSALModServer.exe" "$SERVER_HOME"/ || \
die "Failed to copy DZSALModServer.exe"
}
# finds list of mods to load and stores them in modstring file
# to be used as parameters to the server
load_mods() {
msg "Loading mods"
if [ ! -f "$MOD_CACHE/$MAP_FOLDER_NAME/mods.txt" ] ; then
die "mods.txt list for $MAP_FOLDER_NAME is missing"
fi
mkdir -p "$SERVER_HOME/mods"
_modstring=""
while read -r mod ; do
case $mod in
'@'*)
msg "- Found mod: $mod"
_modstring="$_modstring;mods/$mod"
# common spelling differences, check for all
for addon_folder in addons Addons addon Addon add_ons add_on Add_on Add_ons ; do
if [ -d "$SERVER_HOME/mods/$mod/$addon_folder" ] ; then
for addon in "$SERVER_HOME/mods/$mod/$addon_folder"/* ; do
if [ ! -f "$SERVER_HOME/addons/${addon##*/}" ] ; then
cp -f "$addon" "$SERVER_HOME/addons/"
fi
done
fi
done
for key_folder in keys Keys key Key ; do
if [ -d "$SERVER_HOME/mods/$mod/$key_folder" ] ; then
for key in "$SERVER_HOME/mods/$mod/$key_folder"/* ; do
if [ ! -f "$SERVER_HOME/keys/${key##*/}" ] ; then
cp -f "$key" "$SERVER_HOME/keys/"
fi
done
fi
done
esac
done < "$MOD_CACHE/$MAP_FOLDER_NAME/mods.txt"
# trim the initial leading ';'
_modstring=${_modstring#;}
printf '%s\n' "$_modstring" > modstring
msg "Mods successfully loaded."
}
# ===================================================
# 06. Start function
# ===================================================
start_server() {
check || die "Failed check()"
cd "$SERVER_HOME" || die "Could not cd to '$SERVER_HOME'"
wait_until_remote_server_unlocked
setup_environment || die "Could not set up environment."
load_mods || die "Could not load mods"
# =====================================================================================
# creating temp.bat here to avoid the arg max char limit of windows cmd.exe
PROCESS_NAME="SERVER: $SERVER_NAME"
cat > temp.bat <<EOF
:start
start "$PROCESS_NAME" ^
/min DZSALModServer.exe ^
-config=serverDZ.cfg ^
-port="$SERVER_PORT" ^
-profiles=Profilesfolder ^
-mod="$(cat modstring)" ^
-cpuCount="$SERVER_CPU" ^
-dologs -adminlog -netlog -freezecheck
EOF
# =====================================================================================
# start the server
cmd.exe /C temp.bat
rm -f temp.bat modstring 2>/dev/null ||:
msg "Server started: $(date)"
msg "RESTART_INTERVAL: $RESTART_INTERVAL"
count=0
while [ "$count" -lt "$RESTART_INTERVAL" ] ; do
sleep 60
count=$((count + 60))
msg "TIME LEFT BEFORE RESTART: $(( (RESTART_INTERVAL - count) / 60 )) minutes"
done
msg "Time up - Killing server"
cmd.exe /C taskkill /FI "WINDOWTITLE eq $PROCESS_NAME"
msg "Sleeping 10 seconds to settle"
sleep 10
msg "SERVER IS RESTARTING"
}
# ===================================================
# 07. Main loop
# ===================================================
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"
if [ -e ./SERVER.ENV ] ; then
. ./SERVER.ENV
else
die "Could not source ./SERVER.ENV"
fi
# this must be here and not up top as we must load it from the SERVER.ENV
export SERVER_HOME="$SERVERS/$SERVER_NAME"
# create directories in $SERVER_HOME, blank the modstring
init_server
if [ -e ./serverDZ.cfg ] ; then
cp -f ./serverDZ.cfg "$SERVER_HOME"/ || die "Failed to copy ./serverDZ into $SERVER_HOME"
else
die "Could not find ./serverDZ.cfg"
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
refresh_local_cache || die "Failed to refresh local cache."
# load stock server, map, mod files into $SERVER_HOME
setup_environment || die "Failed to setup environment."
# START THE SERVER - RUN ServerDZ.EXE
start_server "$@"
done
}
main "$@" || exit 1

View File

@@ -0,0 +1,16 @@
##!/bin/sh
export SERVER_NAME="mitch_chernarus_test"
export MAP_FOLDER_NAME="$CHERNARUS_MAP_NAME"
export SERVER_PORT=2302
# number of threads to allocate
export SERVER_CPU=10
# (4 hours, in seconds)
################################# export RESTART_INTERVAL=$((60 * 60 * 4))
# (5 minutes)
export RESTART_INTERVAL=$((5 * 60))

View File

@@ -0,0 +1 @@
../../lib/globals.sh

View File

@@ -0,0 +1,45 @@
hostname = "mitch_chernarus_test"; // Server name
maxPlayers = 10; // Maximum amount of players
steamQueryPort = 2306;
password = "";
passwordAdmin = "SuperSecretAdmin1!";
class Missions
{
class DayZ
{
template="dayzOffline.chernarusplus"; // Mission to load on server startup. <MissionName>.<TerrainName>
// Vanilla mission: dayzOffline.chernarusplus
// DLC mission: dayzOffline.enoch
};
};
vonCodecQuality = 20; // Voice over network codec quality, the higher the better (values 0-30)
disable3rdPerson = 1;
disableCrosshair = 1;
disablePersonalLight = 1;
serverTimeAcceleration=12; // Accelerated Time (value 0-24)// This is a time multiplier for in-game time. In this case, the time would move 24 times faster than normal, so an entire day would pass in one hour.
serverNightTimeAcceleration=1; // Accelerated Nigh Time - The numerical value being a multiplier (0.1-64) and also multiplied by serverTimeAcceleration value. Thus, in case it is set to 4 and serverTimeAcceleration is set to 2, night time would move 8 times faster than normal. An entire night would pass in 3 hours.
enableWhitelist = 0;
verifySignatures = 2; // Verifies .pbos against .bisign files. (only 2 is supported)
forceSameBuild = 1; // When enabled, the server will allow the connection only to clients with same the .exe revision as the server (value 0-1)
disableVoN = 0; // Enable/disable voice over network (value 0-1)
lightingConfig = 0; // 0 for brighter night setup, 1 for darker night setup
serverTime="SystemTime"; // Initial in-game time of the server. "SystemTime" means the local time of the machine. Another possibility is to set the time to some value in "YYYY/MM/DD/HH/MM" format, f.e. "2015/4/8/17/23" .
serverTimePersistent=0; // Persistent Time (value 0-1)// The actual server time is saved to storage, so when active, the next server start will use the saved time value.
guaranteedUpdates=1; // Communication protocol used with game server (use only number 1)
loginQueueConcurrentPlayers=5; // The number of players concurrently processed during the login process. Should prevent massive performance drop during connection when a lot of people are connecting at the same time.
loginQueueMaxPlayers=500; // The maximum number of players that can wait in login queue
instanceId = 1; // DayZ server instance id, to identify the number of instances per box and their storage folders with persistence files
storageAutoFix = 1; // Checks if the persistence files are corrupted and replaces corrupted ones with empty ones (value 0-1)

View File

@@ -0,0 +1 @@
../../server_start.sh