Compare commits

...

19 Commits

Author SHA1 Message Date
Yannick Beauchamp-H
b20d93e229 Change DLC_SPACE_AGE to enable specific Space Age mods (#530)
* Change variable DLC_SPACE_AGE to allow listing specific Space Age mods to enable

* Adjust DLC_SPACE_AGE note

Co-authored-by: Florian Kinder <florian.kinder@fankserver.com>

---------

Co-authored-by: Florian Kinder <florian.kinder@fankserver.com>
2024-10-23 23:54:02 +02:00
Florian Kinder
9562212254 Filter for path and remove tags
related #526
2024-10-23 23:53:11 +02:00
github-actions[bot]
6060c7b722 Auto Update Factorio to stable version: 2.0.9 experimental version: 2.0.10 2024-10-23 21:20:20 +00:00
github-actions[bot]
06baf6a186 Auto Update Factorio to stable version: 2.0.9 experimental version: 2.0.10 2024-10-23 20:24:52 +00:00
Florian Kinder
6eb0cd96d8 MODS is available since 2.0.8
Took 11 minutes
2024-10-23 17:24:05 +02:00
github-actions[bot]
bbbfef343c Auto Update Factorio to stable version: 2.0.9 experimental version: 2.0.9 2024-10-23 11:18:00 +00:00
github-actions[bot]
44a58b056c Auto Update Factorio to stable version: 2.0.9 experimental version: 2.0.9 2024-10-23 10:23:09 +00:00
Florian Kinder
e37bcf1ed0 Create base mod-list.json if it does not exist (#523) 2024-10-22 23:54:00 +02:00
Florian Kinder
3defd74c46 Merge branch 'hjhixon-patch-1' 2024-10-22 23:41:12 +02:00
Harry Hixon
dde2761a8c fix entrypoint logic for checking if root 2024-10-22 23:40:47 +02:00
Yannick Beauchamp-H
0ec91c3391 Add documentation for env variable MODS and make it actually change the mod directory (#520) 2024-10-22 23:22:20 +02:00
Florian Kinder
f9040c7450 Added missing environment variable
Took 20 minutes
2024-10-22 21:23:58 +02:00
github-actions[bot]
c9957b7d76 Auto Update Factorio to stable version: 2.0.8 experimental version: 2.0.9 2024-10-22 19:19:24 +00:00
Florian Kinder
89ae20012e Added DLC_SPACE_AGE environment variable (#519)
* Added DLC_SPACE_AGE environment variable to enable or disable dlc related mods

Took 53 minutes

* 🎨

Took 2 minutes
2024-10-22 20:40:34 +02:00
github-actions[bot]
d137f32c2f Auto Update Factorio to stable version: 2.0.8 experimental version: 2.0.9 2024-10-22 18:29:48 +00:00
Florian Kinder
4f3c5f2e93 Do not run the build in pull requests
Took 6 minutes
2024-10-22 19:33:29 +02:00
Florian Kinder
f7e9dea263 Improve logging in updating mods (#518)
Took 55 minutes
2024-10-22 19:28:25 +02:00
Florian Kinder
748dec4ad5 Fixed tag match in update (#515)
Took 38 minutes
2024-10-22 07:40:13 +02:00
github-actions[bot]
3ce89a714b Auto Update Factorio to stable version: 2.0.8 experimental version: 2.0.8 2024-10-22 05:21:25 +00:00
10 changed files with 118 additions and 30 deletions

View File

@@ -4,9 +4,10 @@ on:
push: push:
branches: branches:
- master - master
tags: paths:
- latest - buildinfo.json
pull_request: # workaround for #526
workflow_dispatch:
jobs: jobs:
build: build:

View File

@@ -4,6 +4,10 @@ on:
push: push:
branches: branches:
- master - master
paths:
- README.md
# workaround for #526
workflow_dispatch:
jobs: jobs:
docker-description: docker-description:

View File

@@ -6,8 +6,8 @@
[中文](./README_zh_CN.md) [中文](./README_zh_CN.md)
<!-- start autogeneration tags --> <!-- start autogeneration tags -->
* `2`, `2.0`, `2.0.8`, `latest`, `stable`, `stable-2.0.8` * `2`, `2.0`, `2.0.9`, `stable`, `stable-2.0.9`
* `2`, `2.0`, `2.0.7`, `stable`, `stable-2.0.7` * `2.0.10`, `latest`
* `1`, `1.1`, `1.1.110`, `stable-1.1.110` * `1`, `1.1`, `1.1.110`, `stable-1.1.110`
* `1.0`, `1.0.0` * `1.0`, `1.0.0`
* `0.17`, `0.17.79` * `0.17`, `0.17.79`
@@ -261,18 +261,20 @@ The `server-settings.json` file may then contain the variable references like th
These are the environment variables which can be specified at container run time. These are the environment variables which can be specified at container run time.
| Variable Name | Description | Default | Available in | | Variable Name | Description | Default | Available in |
| - | - | - | - | |----------------------|----------------------------------------------------------------------|----------------|--------------|
| GENERATE_NEW_SAVE | Generate a new save if one does not exist before starting the server | false | 0.17+ | | GENERATE_NEW_SAVE | Generate a new save if one does not exist before starting the server | false | 0.17+ |
| LOAD_LATEST_SAVE | Load latest when true. Otherwise load SAVE_NAME | true | 0.17+ | | LOAD_LATEST_SAVE | Load latest when true. Otherwise load SAVE_NAME | true | 0.17+ |
| PORT | UDP port the server listens on | 34197 | 0.15+ | | PORT | UDP port the server listens on | 34197 | 0.15+ |
| BIND | IP address (v4 or v6) the server listens on (IP\[:PORT]) | | 0.15+ | | BIND | IP address (v4 or v6) the server listens on (IP\[:PORT]) | | 0.15+ |
| RCON_PORT | TCP port the rcon server listens on | 27015 | 0.15+ | | RCON_PORT | TCP port the rcon server listens on | 27015 | 0.15+ |
| SAVE_NAME | Name to use for the save file | _autosave1 | 0.17+ | | SAVE_NAME | Name to use for the save file | _autosave1 | 0.17+ |
| TOKEN | factorio.com token | | 0.17+ | | TOKEN | factorio.com token | | 0.17+ |
| UPDATE_MODS_ON_START | If mods should be updated before starting the server | | 0.17+ | | UPDATE_MODS_ON_START | If mods should be updated before starting the server | | 0.17+ |
| USERNAME | factorio.com username | | 0.17+ | | | USERNAME | factorio.com username | | 0.17+ |
| CONSOLE_LOG_LOCATION | Saves the console log to the specifies location | | | CONSOLE_LOG_LOCATION | Saves the console log to the specifies location | | |
| DLC_SPACE_AGE | Enables or disables the mods for DLC Space Age in mod-list.json[^1] | true | 2.0.8+ |
| MODS | Mod directory to use | /factorio/mods | 2.0.8+ |
**Note:** All environment variables are compared as strings **Note:** All environment variables are compared as strings
@@ -430,3 +432,8 @@ Use the `PORT` environment variable to start the server on the a different port,
* [bplein](https://github.com/bplein/docker_factorio_server) - Coded scenario support * [bplein](https://github.com/bplein/docker_factorio_server) - Coded scenario support
* [jaredledvina](https://github.com/jaredledvina/docker_factorio_server) - Contributed version updates * [jaredledvina](https://github.com/jaredledvina/docker_factorio_server) - Contributed version updates
* [carlbennett](https://github.com/carlbennett) - Contributed version updates and bugfixes * [carlbennett](https://github.com/carlbennett) - Contributed version updates and bugfixes
[^1]: Space Age mods can also be individually enabled by using their name separated by space.
Example 1: Enable all by using `true`
Example 2: Enable all by listing the mod names `space-age elevated-rails quality`
Example 3: Enable only Elevated rails `elevated-rails`

View File

@@ -57,15 +57,21 @@
"1.1.110" "1.1.110"
] ]
}, },
"2.0.8": { "2.0.9": {
"sha256": "d9594c4d552a3e4f965b188a4774da8c8b010fc23ddb0efc63b1d94818dde1ca", "sha256": "f499077b3e2c1313452c350f1faf17db31cae2a0fa738f69166e97c3caa3c86d",
"tags": [ "tags": [
"latest",
"stable", "stable",
"stable-2.0.8", "stable-2.0.9",
"2", "2",
"2.0", "2.0",
"2.0.8" "2.0.9"
]
},
"2.0.10": {
"sha256": "2d7dd212fa6f715218a5e33bad7d593af8998fa7bf7ce727343159ee1f8c23f4",
"tags": [
"latest",
"2.0.10"
] ]
} }
} }

View File

@@ -28,7 +28,8 @@ ENV PORT=34197 \
SCENARIOS=/factorio/scenarios \ SCENARIOS=/factorio/scenarios \
SCRIPTOUTPUT=/factorio/script-output \ SCRIPTOUTPUT=/factorio/script-output \
PUID="$PUID" \ PUID="$PUID" \
PGID="$PGID" PGID="$PGID" \
DLC_SPACE_AGE="true"
SHELL ["/bin/bash", "-eo", "pipefail", "-c"] SHELL ["/bin/bash", "-eo", "pipefail", "-c"]

View File

@@ -6,8 +6,8 @@ services:
args: args:
# Check buildinfo.json for supported versions and SHAs # Check buildinfo.json for supported versions and SHAs
# https://github.com/factoriotools/factorio-docker/blob/master/buildinfo.json # https://github.com/factoriotools/factorio-docker/blob/master/buildinfo.json
- VERSION=2.0.8 - VERSION=2.0.9
- SHA256=d9594c4d552a3e4f965b188a4774da8c8b010fc23ddb0efc63b1d94818dde1ca - SHA256=f499077b3e2c1313452c350f1faf17db31cae2a0fa738f69166e97c3caa3c86d
ports: ports:
- "34197:34197/udp" - "34197:34197/udp"
- "27015:27015/tcp" - "27015:27015/tcp"

57
docker/files/docker-dlc.sh Executable file
View File

@@ -0,0 +1,57 @@
#!/bin/bash
set -eou pipefail
# Path to the mod-list.json file
MOD_LIST_FILE="$MODS/mod-list.json"
ALL_SPACE_AGE_MODS=("elevated-rails" "quality" "space-age")
if [[ ! -f "$MOD_LIST_FILE" ]]; then
# Create the mod-list.json file if it doesn't exist
echo '{"mods":[{"name":"base","enabled":true}]}' > "$MOD_LIST_FILE"
fi
enable_mod()
{
echo "Enable mod $1 for DLC"
jq --arg mod_name "$1" 'if .mods | map(.name) | index($mod_name) then .mods |= map(if .name == $mod_name and .enabled == false then .enabled = true else . end) else . end' "$MOD_LIST_FILE" > "$MOD_LIST_FILE.tmp"
mv "$MOD_LIST_FILE.tmp" "$MOD_LIST_FILE"
}
disable_mod()
{
echo "Disable mod $1 for DLC"
jq --arg mod_name "$1" 'if .mods | map(.name) | index($mod_name) then .mods |= map(if .name == $mod_name and .enabled == true then .enabled = false else . end) else .mods += [{"name": $mod_name, "enabled": false}] end' "$MOD_LIST_FILE" > "$MOD_LIST_FILE.tmp"
mv "$MOD_LIST_FILE.tmp" "$MOD_LIST_FILE"
}
# Enable or disable DLCs if configured
if [[ ${DLC_SPACE_AGE:-} == "true" ]]; then
# Define the DLC mods
ENABLE_MODS=(${ALL_SPACE_AGE_MODS[@]})
elif [[ ${DLC_SPACE_AGE:-} == "false" ]]; then
# Define the DLC mods
DISABLE_MODS=(${ALL_SPACE_AGE_MODS[@]})
else
ENABLE_MODS=()
DISABLE_MODS=()
for SPACE_AGE_MOD in "${ALL_SPACE_AGE_MODS[@]}"; do
REGEX="(^|\s)$SPACE_AGE_MOD($|\s)"
if [[ "$DLC_SPACE_AGE" =~ $REGEX ]]; then
ENABLE_MODS+=($SPACE_AGE_MOD)
else
DISABLE_MODS+=($SPACE_AGE_MOD)
fi
done
fi
# Iterate over each DLC mod to enable
for MOD in "${ENABLE_MODS[@]}"; do
enable_mod "$MOD"
done
# Iterate over each DLC mod to disable
for MOD in "${DISABLE_MODS[@]}"; do
disable_mod "$MOD"
done

View File

@@ -43,8 +43,10 @@ if [[ ${UPDATE_MODS_ON_START:-} == "true" ]]; then
./docker-update-mods.sh ./docker-update-mods.sh
fi fi
./docker-dlc.sh
EXEC="" EXEC=""
if [[ $(id -u) = 0 ]]; then if [[ $(id -u) == 0 ]]; then
# Update the User and Group ID based on the PUID/PGID variables # Update the User and Group ID based on the PUID/PGID variables
usermod -o -u "$PUID" factorio usermod -o -u "$PUID" factorio
groupmod -o -g "$PGID" factorio groupmod -o -g "$PGID" factorio
@@ -100,6 +102,7 @@ FLAGS=(\
--server-adminlist "$CONFIG/server-adminlist.json" \ --server-adminlist "$CONFIG/server-adminlist.json" \
--rcon-password "$(cat "$CONFIG/rconpw")" \ --rcon-password "$(cat "$CONFIG/rconpw")" \
--server-id /factorio/config/server-id.json \ --server-id /factorio/config/server-id.json \
--mod-directory "$MODS" \
) )
if [ -n "$CONSOLE_LOG_LOCATION" ]; then if [ -n "$CONSOLE_LOG_LOCATION" ]; then

View File

@@ -28,7 +28,7 @@ update_mod()
MOD_NAME="$1" MOD_NAME="$1"
MOD_NAME_ENCODED="${1// /%20}" MOD_NAME_ENCODED="${1// /%20}"
print_step "Checking for update of mod $MOD_NAME..." print_step "Checking for update of mod $MOD_NAME for factorio $FACTORIO_VERSION ..."
MOD_INFO_URL="$MOD_BASE_URL/api/mods/$MOD_NAME_ENCODED" MOD_INFO_URL="$MOD_BASE_URL/api/mods/$MOD_NAME_ENCODED"
MOD_INFO_JSON=$(curl --silent "$MOD_INFO_URL") MOD_INFO_JSON=$(curl --silent "$MOD_INFO_URL")
@@ -54,7 +54,7 @@ update_mod()
return 0 return 0
fi fi
print_step "Downloading..." print_step " Downloading $MOD_FILENAME"
FULL_URL="$MOD_BASE_URL$MOD_URL?username=$USERNAME&token=$TOKEN" FULL_URL="$MOD_BASE_URL$MOD_URL?username=$USERNAME&token=$TOKEN"
HTTP_STATUS=$(curl --silent -L -w "%{http_code}" -o "$MOD_DIR/$MOD_FILENAME" "$FULL_URL") HTTP_STATUS=$(curl --silent -L -w "%{http_code}" -o "$MOD_DIR/$MOD_FILENAME" "$FULL_URL")

View File

@@ -4,12 +4,16 @@ SEMVER_REGEX="^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
stable_online_version=$(curl 'https://factorio.com/api/latest-releases' | jq '.stable.headless' -r) stable_online_version=$(curl 'https://factorio.com/api/latest-releases' | jq '.stable.headless' -r)
experimental_online_version=$(curl 'https://factorio.com/api/latest-releases' | jq '.experimental.headless' -r) experimental_online_version=$(curl 'https://factorio.com/api/latest-releases' | jq '.experimental.headless' -r)
stable_sha256=$(curl "https://factorio.com/download/sha256sums/" | grep -E "(factorio_headless_x64_|factorio-headless_linux_)${stable_online_version}.tar.xz" | awk '{print $1}') stable_sha256=$(curl "https://factorio.com/download/sha256sums/" | grep -E "(factorio_headless_x64_|factorio-headless_linux_)${stable_online_version}.tar.xz" | awk '{print $1}')
experimental_sha256=$(curl "https://factorio.com/download/sha256sums/" | grep -E "(factorio_headless_x64_|factorio-headless_linux_)${experimental_online_version}.tar.xz" | awk '{print $1}') experimental_sha256=$(curl "https://factorio.com/download/sha256sums/" | grep -E "(factorio_headless_x64_|factorio-headless_linux_)${experimental_online_version}.tar.xz" | awk '{print $1}')
stable_current_version=$(jq 'with_entries(select(contains({value:{tags:["stable"]}}))) | keys | .[0]' buildinfo.json -r)
latest_current_version=$(jq 'with_entries(select(contains({value:{tags:["latest"]}}))) | keys | .[0]' buildinfo.json -r) stable_current_version=$(jq 'with_entries(select(.value.tags | index("stable"))) | keys | .[0]' buildinfo.json -r)
latest_current_version=$(jq 'with_entries(select(.value.tags | index("latest"))) | keys | .[0]' buildinfo.json -r)
echo "stable_online_version=${stable_online_version} experimental_online_version=${experimental_online_version}" echo "stable_online_version=${stable_online_version} experimental_online_version=${experimental_online_version}"
echo "stable_current_version=${stable_current_version} latest_current_version=${latest_current_version}" echo "stable_current_version=${stable_current_version} latest_current_version=${latest_current_version}"
if [[ -z "${stable_online_version}" ]] || [[ -z "${experimental_online_version}" ]]; then if [[ -z "${stable_online_version}" ]] || [[ -z "${experimental_online_version}" ]]; then
exit exit
fi fi
@@ -57,6 +61,11 @@ echo "stableCurrentVersionShort=${stableCurrentVersionShort} latestCurrentVersio
tmpfile=$(mktemp) tmpfile=$(mktemp)
# Remove stable tag
cp buildinfo.json "$tmpfile"
jq --arg stable_current_version "$stable_current_version" 'with_entries(if .key == $stable_current_version then .value.tags |= . - ["stable"] else . end)' "$tmpfile" > buildinfo.json
rm -f -- "$tmpfile"
# Remove latest tag # Remove latest tag
cp buildinfo.json "$tmpfile" cp buildinfo.json "$tmpfile"
jq --arg latest_current_version "$latest_current_version" 'with_entries(if .key == $latest_current_version then .value.tags |= . - ["latest"] else . end)' "$tmpfile" > buildinfo.json jq --arg latest_current_version "$latest_current_version" 'with_entries(if .key == $latest_current_version then .value.tags |= . - ["latest"] else . end)' "$tmpfile" > buildinfo.json