Skip to content

Commit db3b960

Browse files
committed
Add option to ignore mods from auto-update
1 parent 37f7a4e commit db3b960

5 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ Copy mods into the mods folder and restart the server.
175175

176176
As of 0.17 a new environment variable was added ``UPDATE_MODS_ON_START`` which if set to ``true`` will cause the mods get to updated on server start. If set a valid [Factorio Username and Token](https://www.factorio.com/profile) must be supplied or else the server will not start. They can either be set as docker secrets, environment variables, or pulled from the server-settings.json file.
177177

178+
To prevent specific mods from being automatically updated, you can use the ``UPDATE_IGNORE`` environment variable with a comma-separated list of mod names. For example: ``UPDATE_IGNORE=mod1,mod2,mod3`` will skip updates for those three mods. This can be useful to prevent compatibility issues when certain mods should remain at specific versions. Be warned that it can also create compatibility issues.
179+
178180
**Note:** When using the Space Age DLC, the built-in mods (`elevated-rails`, `quality`, and `space-age`) are automatically skipped during mod updates to prevent conflicts. These mods are included with the DLC and should not be downloaded separately.
179181

180182
### Scenarios
@@ -292,6 +294,7 @@ These are the environment variables which can be specified at container run time
292294
| PRESET | Map generation preset when GENERATE_NEW_SAVE is true | | 0.17+ |
293295
| TOKEN | factorio.com token | | 0.17+ |
294296
| UPDATE_MODS_ON_START | If mods should be updated before starting the server | | 0.17+ |
297+
| UPDATE_IGNORE | Comma-separated list of mod names to skip during automatic updates | | 0.17+ |
295298
| USERNAME | factorio.com username | | 0.17+ |
296299
| CONSOLE_LOG_LOCATION | Saves the console log to the specifies location | | |
297300
| DLC_SPACE_AGE | Enables or disables the mods for DLC Space Age in mod-list.json[^1] | true | 2.0.8+ |

‎docker-compose.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ services:
1111
- ./data:/factorio
1212
environment:
1313
- UPDATE_MODS_ON_START=true
14+
# Uncomment to skip updating specific mods
15+
# - UPDATE_IGNORE=mod1,mod2,mod3
1416

1517
# Uncomment to enable autoupdate via watchtower
1618
#labels:

‎docker/docker-compose.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ services:
1717
# - PUID=1000
1818
# - PGID=1000
1919
# - UPDATE_MODS_ON_START=true
20+
# - UPDATE_IGNORE=mod1,mod2,mod3
2021
# - USERNAME=FactorioUsername
2122
# - TOKEN=FactorioToken
2223
# - PORT=34198

‎docker/files/docker-update-mods.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ if [[ -z ${TOKEN:-} ]]; then
2525
echo "You need to provide your Factorio token to update mods."
2626
fi
2727

28-
./update-mods.sh "$VERSION" "$MODS" "$USERNAME" "$TOKEN"
28+
./update-mods.sh "$VERSION" "$MODS" "$USERNAME" "$TOKEN" "${UPDATE_IGNORE:-}"

‎docker/files/update-mods.sh‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ FACTORIO_VERSION=$1
55
MOD_DIR=$2
66
USERNAME=$3
77
TOKEN=$4
8+
UPDATE_IGNORE=$5
89

910
MOD_BASE_URL="https://mods.factorio.com"
1011

12+
1113
print_step()
1214
{
1315
echo "$1"
@@ -158,6 +160,28 @@ get_mod_info()
158160
done < <(echo "$mod_info_json" | jq -c ".releases|sort_by(.released_at)|reverse|.[]")
159161
}
160162

163+
# Check if a mod should be ignored based on UPDATE_IGNORE environment variable
164+
is_mod_ignored() {
165+
local mod_name="$1"
166+
167+
# If UPDATE_IGNORE is not set or empty, don't ignore any mods
168+
if [[ -z "${UPDATE_IGNORE:-}" ]]; then
169+
return 1
170+
fi
171+
172+
# Split the comma-separated list and check if mod_name is in it
173+
IFS=',' read -ra ignored_mods <<< "$UPDATE_IGNORE"
174+
for ignored_mod in "${ignored_mods[@]}"; do
175+
# Trim whitespace from ignored_mod
176+
ignored_mod=$(echo "$ignored_mod" | xargs)
177+
if [[ "$mod_name" == "$ignored_mod" ]]; then
178+
return 0
179+
fi
180+
done
181+
182+
return 1
183+
}
184+
161185
update_mod()
162186
{
163187
MOD_NAME="$1"
@@ -233,7 +257,11 @@ if [[ -f $MOD_DIR/mod-list.json ]]; then
233257
jq -r ".mods|map(select(.enabled))|.[].name" "$MOD_DIR/mod-list.json" | while read -r mod; do
234258
# Skip base mod and DLC built-in mods
235259
if [[ $mod != base ]] && [[ $mod != elevated-rails ]] && [[ $mod != quality ]] && [[ $mod != space-age ]]; then
236-
update_mod "$mod" || true
260+
if is_mod_ignored "$mod"; then
261+
print_success "Skipping mod $mod (listed in UPDATE_IGNORE)"
262+
else
263+
update_mod "$mod" || true
264+
fi
237265
fi
238266
done
239267
fi

0 commit comments

Comments
 (0)