From 8bd4030370ae58b12edbe74dc8e8eb0c8ebe0f6a Mon Sep 17 00:00:00 2001 From: Thomas Hoag Date: Tue, 28 Jan 2020 17:46:18 -0500 Subject: [PATCH] Add a check for existing save file before starting the server --- run.sh | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/run.sh b/run.sh index 13c2b56..e279340 100755 --- a/run.sh +++ b/run.sh @@ -1,11 +1,15 @@ #!/usr/bin/env bash +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +REPODIR="$(dirname "$SCRIPTDIR")" + +# always fail script if a cmd fails +set -eo pipefail + echo "###########################################################################" echo "# Ark Server - " `date` echo "###########################################################################" - - echo "Ensuring correct permissions..." sudo chown steam:steam -R /ark @@ -87,11 +91,32 @@ fi [ -f /ark/config/Game.ini ] && ln -sf /ark/config/Game.ini /ark/server/ShooterGame/Saved/Config/LinuxServer/Game.ini [ -f /ark/config/GameUserSettings.ini ] && ln -sf /ark/config/GameUserSettings.ini /ark/server/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini -echo "Backing up on start..." -arkmanager backup +if [[ "$VALIDATE_SAVE_EXISTS" = true && ! -z "$am_ark_AltSaveDirectoryName" && ! -z "$am_serverMap" ]]; then + savepath="/ark/server/ShooterGame/Saved/$am_ark_AltSaveDirectoryName" + savefile="$am_serverMap.ark" + echo "Validating that a save file exists for $am_serverMap" + echo "Checking $savepath" + if [[ ! -f "$savepath/$savefile" ]]; then + echo "$savefile not found!" + echo "Attempting to notify via Discord..." + arkmanager notify "Critical error: unable to find $savefile in $savepath!" + exit 1 + else + echo "$savefile found." + fi +else + echo "Save file validation is not enabled." +fi -function stop { +if [[ ! -z $BACKUP_ONSTART ]]; then + echo "Backing up on start..." + arkmanager backup +else + echo "Backup on start is not enabled." +fi + +function stop { arkmanager stop exit 0 }