added an experimental parameter

This commit is contained in:
Seaswimmer 2023-08-15 01:36:41 -04:00
parent 0859bdb265
commit 04d7c6d6ce
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8
3 changed files with 13 additions and 1 deletions

View file

@ -30,6 +30,7 @@ These three `.sh` files were created for Infern009's Factorio server, and use [B
- `cp config.sh.example config.sh` - `cp config.sh.example config.sh`
- Modify the parameters in `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. - `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). - 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. - `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` - `--map-gen-settings ./data/map-gen-settings.json`

View file

@ -2,6 +2,8 @@
save_name="default" # Set this to the name of your save file. 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. # Don't change this unless you know what you're doing.
# Set this to the custom parameters you want the --create command to use. # Set this to the custom parameters you want the --create command to use.
extra_params_create="" extra_params_create=""

View file

@ -18,6 +18,7 @@ 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
configpath="config.sh"
echo "Loaded configuration from config.sh" echo "Loaded configuration from config.sh"
else else
# If config.sh doesn't exist, check if config.sh.example exists # If config.sh doesn't exist, check if config.sh.example exists
@ -25,6 +26,7 @@ else
# Fetch variables from config.sh.example # Fetch variables from config.sh.example
echo "WARNING: config.sh file does not exist, falling back on default configuration." echo "WARNING: config.sh file does not exist, falling back on default configuration."
source config.sh.example source config.sh.example
configpath="config.sh.example"
echo "Loaded configuration from config.sh.example" echo "Loaded configuration from config.sh.example"
else else
# Handle the scenario when both files are missing # Handle the scenario when both files are missing
@ -35,7 +37,14 @@ fi
# This handles automatically updating the Factorio binary. # This handles automatically updating the Factorio binary.
echo "Fetching Factorio binary..." echo "Fetching Factorio binary..."
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 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..." echo "Extracting Factorio binary..."
tar -xvf factorio_headless.tar.xz --strip-components=1 --overwrite tar -xvf factorio_headless.tar.xz --strip-components=1 --overwrite
echo "Factorio binary updated!" echo "Factorio binary updated!"