From f3ff1621629b322496dc2aefe43ade4085c05afa Mon Sep 17 00:00:00 2001 From: Mitch Weaver Date: Sun, 26 Nov 2023 00:48:08 -0600 Subject: [PATCH] asdf --- lib/globals.sh | 13 ++++++++++++- server_start.sh | 43 +++++++++++++++++++------------------------ 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/lib/globals.sh b/lib/globals.sh index ff09436..f355c29 100644 --- a/lib/globals.sh +++ b/lib/globals.sh @@ -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 +} # ===================================================================================== diff --git a/server_start.sh b/server_start.sh index c103608..9392350 100644 --- a/server_start.sh +++ b/server_start.sh @@ -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 </dev/null ||: msg "Sleeping 10 seconds to settle" sleep 10 msg "SERVER IS RESTARTING" - } # ===================================================