diff --git a/README.md b/README.md index b0ab482..af585a9 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ These three `.sh` files were created for Infern009's Factorio server, and use [B - `cp config.sh.example config.sh` - Modify the parameters in `config.sh`. - `save_name` - This parameter controls the name of the save file this script will use to start the server. + - `experimental` - This parameter controls if the script will download the latest build or the experimental build of the game. See the [Factorio download page](https://www.factorio.com/download) for more information. - If you have modified any default config files except for the `config.ini`, you'll want to change the commands' parameters to match those files. I'll assume you're storing them in the `./data` directory. You can find more arguments on the [Factorio Wiki](https://wiki.factorio.com/Command_line_parameters). - `extra_params_create=""` - This parameter adds additional flags to the `--create` command the script runs if a save matching `save_name` is not found. - `--map-gen-settings ./data/map-gen-settings.json` diff --git a/config.sh.example b/config.sh.example index 4df435b..b1998ad 100644 --- a/config.sh.example +++ b/config.sh.example @@ -2,6 +2,8 @@ save_name="default" # Set this to the name of your save file. +experimental="false" # This decides whether or not to download the experimental/latest build of the game, or the stable version. + # Don't change this unless you know what you're doing. # Set this to the custom parameters you want the --create command to use. extra_params_create="" diff --git a/start_server.sh b/start_server.sh index 150836f..17237e1 100755 --- a/start_server.sh +++ b/start_server.sh @@ -18,6 +18,7 @@ fi # If config.sh exists, fetch variables from it if [ -f "config.sh" ]; then source config.sh + configpath="config.sh" echo "Loaded configuration from config.sh" else # If config.sh doesn't exist, check if config.sh.example exists @@ -25,6 +26,7 @@ else # Fetch variables from config.sh.example echo "WARNING: config.sh file does not exist, falling back on default configuration." source config.sh.example + configpath="config.sh.example" echo "Loaded configuration from config.sh.example" else # Handle the scenario when both files are missing @@ -35,7 +37,14 @@ 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 +if [ "$experimental" = "true" ]; then + wget https://factorio.com/get-download/latest/headless/linux64 -O factorio_headless.tar.xz +elif [ "$experimental" = "false" ]; then + wget https://factorio.com/get-download/stable/headless/linux64 -O factorio_headless.tar.xz +else + echo "FATAL: ${configpath} file is misconfigured! Experimental variable is not set correctly. Must be 'true' or 'false'." + exit 1 +fi echo "Extracting Factorio binary..." tar -xvf factorio_headless.tar.xz --strip-components=1 --overwrite echo "Factorio binary updated!"