From 6eb33b1aba4ea25d43bf460c68f5b52251b48ed2 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Mon, 14 Aug 2023 12:35:32 -0400 Subject: [PATCH] fixed server_start to work properly if ran from another directory --- start_server.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/start_server.sh b/start_server.sh index 9a98a31..6648341 100755 --- a/start_server.sh +++ b/start_server.sh @@ -1,5 +1,20 @@ #!/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 [ -f "config.sh" ]; then source config.sh @@ -18,21 +33,6 @@ else 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. echo "Fetching Factorio binary..." wget https://factorio.com/get-download/stable/headless/linux64 -O factorio_headless.tar.xz