Compare commits

..

1 Commits

Author SHA1 Message Date
da49c13bb7 Fixed tag match in update
Took 38 minutes
2024-10-22 07:37:00 +02:00
12 changed files with 34 additions and 121 deletions

View File

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

View File

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

View File

@ -13,8 +13,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_TOKEN }}
- name: Run update script - name: Run update script
run: ./update.sh run: ./update.sh

View File

@ -6,8 +6,8 @@
[中文](./README_zh_CN.md) [中文](./README_zh_CN.md)
<!-- start autogeneration tags --> <!-- start autogeneration tags -->
* `2.0.14`, `latest` * `2`, `2.0`, `2.0.8`, `latest`, `stable`, `stable-2.0.8`
* `2`, `2.0`, `2.0.13`, `stable`, `stable-2.0.13` * `2`, `2.0`, `2.0.7`, `stable`, `stable-2.0.7`
* `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,20 +261,18 @@ 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
@ -432,8 +430,3 @@ 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

@ -10,7 +10,7 @@
* `0.x.y` - 具体的版本 * `0.x.y` - 具体的版本
* `0.x-z` - 在该版本上的增量更新 * `0.x-z` - 在该版本上的增量更新
## 什么是 Factorio ## 什么是 Facotrio
> 摘录自 [steam factorio 页面](https://store.steampowered.com/app/427520/Factorio/) > 摘录自 [steam factorio 页面](https://store.steampowered.com/app/427520/Factorio/)

View File

@ -57,21 +57,15 @@
"1.1.110" "1.1.110"
] ]
}, },
"2.0.13": { "2.0.8": {
"sha256": "27b36901a39e593adf28418c0286142c6c7a9f83d156963c7369bd405a25c7d1", "sha256": "d9594c4d552a3e4f965b188a4774da8c8b010fc23ddb0efc63b1d94818dde1ca",
"tags": [
"stable",
"stable-2.0.13",
"2",
"2.0",
"2.0.13"
]
},
"2.0.14": {
"sha256": "5a4bc4c3b2a97ed1fc58eb796321e848dcc64435bd91013dd9c78a14a8ce8815",
"tags": [ "tags": [
"latest", "latest",
"2.0.14" "stable",
"stable-2.0.8",
"2",
"2.0",
"2.0.8"
] ]
} }
} }

View File

@ -28,8 +28,7 @@ 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.13 - VERSION=2.0.8
- SHA256=27b36901a39e593adf28418c0286142c6c7a9f83d156963c7369bd405a25c7d1 - SHA256=d9594c4d552a3e4f965b188a4774da8c8b010fc23ddb0efc63b1d94818dde1ca
ports: ports:
- "34197:34197/udp" - "34197:34197/udp"
- "27015:27015/tcp" - "27015:27015/tcp"
@ -22,8 +22,3 @@ services:
# - PORT=34198 # - PORT=34198
# - PRESET=deathworld # - PRESET=deathworld
# - ADDR=::1 # - ADDR=::1
# # Uncomment the following line to enable the use of the host's network stack,
# # which may be necessary for some setups like NAS or when using some proxy service like firewall rules.
# extra_hosts:
# - "host.docker.internal:host-gateway"

View File

@ -1,57 +0,0 @@
#!/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

@ -1,6 +1,5 @@
#!/bin/bash #!/bin/bash
set -eoux pipefail set -eoux pipefail
INSTALLED_DIRECTORY=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
FACTORIO_VOL=/factorio FACTORIO_VOL=/factorio
LOAD_LATEST_SAVE="${LOAD_LATEST_SAVE:-true}" LOAD_LATEST_SAVE="${LOAD_LATEST_SAVE:-true}"
GENERATE_NEW_SAVE="${GENERATE_NEW_SAVE:-false}" GENERATE_NEW_SAVE="${GENERATE_NEW_SAVE:-false}"
@ -41,13 +40,11 @@ if [[ $NRTMPSAVES -gt 0 ]]; then
fi fi
if [[ ${UPDATE_MODS_ON_START:-} == "true" ]]; then if [[ ${UPDATE_MODS_ON_START:-} == "true" ]]; then
${INSTALLED_DIRECTORY}/docker-update-mods.sh ./docker-update-mods.sh
fi fi
${INSTALLED_DIRECTORY}/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
@ -103,7 +100,6 @@ 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 for factorio $FACTORIO_VERSION ..." print_step "Checking for update of mod $MOD_NAME..."
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 $MOD_FILENAME" print_step "Downloading..."
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

@ -73,8 +73,8 @@ rm -f -- "$tmpfile"
# Update tag by stable # Update tag by stable
cp buildinfo.json "$tmpfile" cp buildinfo.json "$tmpfile"
if [[ "$stable_online_version" == "$stable_current_version" ]]; then if [[ $stableOnlineVersionShort == "$stableCurrentVersionShort" ]]; then
jq --arg stable_current_version "$stable_current_version" --arg stable_online_version "$stable_online_version" --arg sha256 "$stable_sha256" 'with_entries(if .key == $stable_current_version then .key |= $stable_online_version | .value.sha256 |= $sha256 | .value.tags |= . - [$stable_current_version] + [$stable_online_version, "stable"] else . end)' "$tmpfile" > buildinfo.json jq --arg stable_current_version "$stable_current_version" --arg stable_online_version "$stable_online_version" --arg sha256 "$stable_sha256" 'with_entries(if .key == $stable_current_version then .key |= $stable_online_version | .value.sha256 |= $sha256 | .value.tags |= . - [$stable_current_version] + [$stable_online_version] else . end)' "$tmpfile" > buildinfo.json
else else
jq --arg stable_current_version "$stable_current_version" --arg stable_online_version "$stable_online_version" --arg sha256 "$stable_sha256" --arg stableOnlineVersionShort "$stableOnlineVersionShort" --arg stableOnlineVersionMajor "$stableOnlineVersionMajor" 'with_entries(if .key == $stable_current_version then .value.tags |= . - ["latest","stable",$stableOnlineVersionMajor] else . end) | to_entries | . + [{ key: $stable_online_version, value: { sha256: $sha256, tags: ["latest","stable",("stable-" + $stable_online_version),$stableOnlineVersionMajor,$stableOnlineVersionShort,$stable_online_version]}}] | from_entries' "$tmpfile" > buildinfo.json jq --arg stable_current_version "$stable_current_version" --arg stable_online_version "$stable_online_version" --arg sha256 "$stable_sha256" --arg stableOnlineVersionShort "$stableOnlineVersionShort" --arg stableOnlineVersionMajor "$stableOnlineVersionMajor" 'with_entries(if .key == $stable_current_version then .value.tags |= . - ["latest","stable",$stableOnlineVersionMajor] else . end) | to_entries | . + [{ key: $stable_online_version, value: { sha256: $sha256, tags: ["latest","stable",("stable-" + $stable_online_version),$stableOnlineVersionMajor,$stableOnlineVersionShort,$stable_online_version]}}] | from_entries' "$tmpfile" > buildinfo.json
fi fi