fixed server_start to work properly if ran from another directory

This commit is contained in:
Seaswimmer 2023-08-14 12:35:32 -04:00
parent 489943b6a6
commit 6eb33b1aba
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -1,5 +1,20 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Retrieves the script's directory and cd's into it.
script_dir="$(cd "$(dirname "$0")" && pwd)"
cd ${script_dir}
# Check if the current directory is inside a Git repository.
if [ -d .git ] || git rev-parse --is-inside-work-tree > /dev/null 2>&1 ; then
# Pull updated scripts from CoastalCommits.
echo "Updating scripts..."
git pull
echo "Scripts updated!"
echo "Server must be restarted for script updates to take effect."
else
echo "WARNING: This directory is not a Git repository. Script updates will not be automatically fetched."
fi
# If config.sh exists, fetch variables from it # If config.sh exists, fetch variables from it
if [ -f "config.sh" ]; then if [ -f "config.sh" ]; then
source config.sh source config.sh
@ -18,21 +33,6 @@ else
fi fi
fi fi
# Retrieves the script's directory and cd's into it.
script_dir="$(cd "$(dirname "$0")" && pwd)"
cd ${script_dir}
# Check if the current directory is inside a Git repository.
if [ -d .git ] || git rev-parse --is-inside-work-tree > /dev/null 2>&1 ; then
# Pull updated scripts from CoastalCommits.
echo "Updating scripts..."
git pull
echo "Scripts updated!"
echo "Server must be restarted for script updates to take effect."
else
echo "WARNING: This directory is not a Git repository. Script updates will not be automatically fetched."
fi
# This handles automatically updating the Factorio binary. # This handles automatically updating the Factorio binary.
echo "Fetching Factorio binary..." echo "Fetching Factorio binary..."
wget https://factorio.com/get-download/stable/headless/linux64 -O factorio_headless.tar.xz wget https://factorio.com/get-download/stable/headless/linux64 -O factorio_headless.tar.xz