This commit is contained in:
2023-11-26 00:48:08 -06:00
parent 02120d559e
commit f3ff162162
2 changed files with 31 additions and 25 deletions

View File

@@ -148,9 +148,20 @@ lock_remote_server() {
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
}
# =====================================================================================

View File

@@ -49,7 +49,9 @@ export SERVERS="$LOCAL_DAYZ_FILES/servers"
################################# export RESTART_INTERVAL=$((60 * 60 * 4))
# (10 minutes)
export RESTART_INTERVAL=$((10 * 60))
# export RESTART_INTERVAL=$((10 * 60))
export RESTART_INTERVAL=$((1 * 60))
# ===================================================
# 03. Mount network drive
@@ -145,6 +147,7 @@ refresh_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
@@ -170,6 +173,7 @@ setup_environment() {
# 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
@@ -209,7 +213,6 @@ load_mods() {
# trim the initial leading ';'
_modstring=${_modstring#;}
printf '%s\n' "$_modstring" > .modstring
unset _modstring
msg "Mods successfully loaded. Using modstring:"
printf '"%s"\n' "$(cat .modstring)"
@@ -220,32 +223,25 @@ load_mods() {
# ===================================================
start_server() {
check || die "Failed check()"
# 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
cd "$SERVER_HOME" || die "Could not cd to '$SERVER_HOME'"
msg "Setting up environment"
wait_until_remote_server_unlocked
setup_environment || die "Could not set up environment."
msg "Loading mods"
load_mods || die "Could not load mods"
mod_string=$(cat .modstring)
# =====================================================================================
# 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 "$SERVER_NAME" /min DZSALModServer.exe -config=serverDZ.cfg -port="$SERVER_PORT" -profiles=Profilesfolder -mod="$mod_string" -cpuCount="$SERVER_CPU" -dologs -adminlog -netlog -freezecheck
start "$PROCESS_NAME" ^
/min DZSALModServer.exe ^
-config=serverDZ.cfg ^
-port="$SERVER_PORT" ^
-profiles=Profilesfolder ^
-mod="$(cat .mod_string)" ^
-cpuCount="$SERVER_CPU" ^
-dologs -adminlog -netlog -freezecheck
EOF
# =====================================================================================
@@ -266,16 +262,15 @@ EOF
done
echo "==========================="
msg "Time up"
msg "Killing server"
cmd.exe /C taskkill /im DayZServer_x64.exe /F
msg "Time up - Killing server"
# TODO: need to change this to be title of the cmd else it will kill all servers
cmd.exe /C taskkill /IM /FI "$PROCESS_NAME"
###### 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"
}
# ===================================================