Skip to content
This repository has been archived by the owner on Oct 28, 2023. It is now read-only.

Commit

Permalink
Add a check for existing save file before starting the server
Browse files Browse the repository at this point in the history
  • Loading branch information
thmhoag committed Jan 28, 2020
1 parent ad5e210 commit 8bd4030
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions run.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 8bd4030

Please sign in to comment.