mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2025-07-01 06:28:05 +02:00
Compare commits
91 Commits
6eb0cd96d8
...
latest
Author | SHA1 | Date | |
---|---|---|---|
9f6c781331 | |||
8a718705b7 | |||
60277e89f1 | |||
4562f675ea | |||
22d02c42fa | |||
6b3dd77a54 | |||
6d3be9aef1 | |||
bf97066b9c | |||
c0c235a28d | |||
d5db1b1281 | |||
0c0349b5d6 | |||
0c1b2f4164 | |||
b36cd87194 | |||
e82cead5f4 | |||
d9ff25fa10 | |||
b7fdff9b94 | |||
04f20de96c | |||
fcd2c2e40e | |||
f02c02f38e | |||
b4be6993c6 | |||
a2c11ade50 | |||
b334d27cf0 | |||
ede09dc402 | |||
0929686ad3 | |||
317d3731e8 | |||
080a70f6be | |||
83bffe4b13 | |||
14df05cd6d | |||
c0e1bae277 | |||
370059f2f6 | |||
7e8c89c02a | |||
1e52dc48c9 | |||
14aa945717 | |||
57bbf46196 | |||
090e771c0c | |||
9e89a7930e | |||
20e6176a85 | |||
e5e1993c97 | |||
6e0ea49985 | |||
f757e538b7 | |||
a94f8a0d4e | |||
2b76185f94 | |||
3c45811e15 | |||
8990021fa1 | |||
50e5c868e5 | |||
89aebaba4b | |||
d19c97c075 | |||
19e5dc7532 | |||
6a3b160d76 | |||
a3d5456e58 | |||
8d5096e28b | |||
a1135b6a55 | |||
192f686b6b | |||
66ce43c0ca | |||
ebadd1d8b8 | |||
c9989d3a07 | |||
2dfaac7ec4 | |||
c2d7c5696e | |||
f14bedbc63 | |||
d91c45fa62 | |||
2092e86aec | |||
ecb89b0c11 | |||
42a08a95d4 | |||
61d52eaa7c | |||
6916fcb150 | |||
8c9dfd004e | |||
867635db16 | |||
b7413607c4 | |||
5d6f70b285 | |||
a24e42b281 | |||
d1142e3408 | |||
4eb53b6e48 | |||
f986f1c870 | |||
bc760a9599 | |||
d153e30f1c | |||
cc5061d339 | |||
14ae422463 | |||
88ca95a1ae | |||
64980b9db3 | |||
85f8011105 | |||
cc8d89df84 | |||
956ade4f0b | |||
049d34ea9a | |||
d01580b5a5 | |||
25a283ad79 | |||
b172b16ff4 | |||
eb150cff0d | |||
b20d93e229 | |||
9562212254 | |||
6060c7b722 | |||
06baf6a186 |
6
.github/workflows/docker-build.yml
vendored
6
.github/workflows/docker-build.yml
vendored
@ -4,8 +4,10 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- latest
|
||||
paths:
|
||||
- buildinfo.json
|
||||
# workaround for #526
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
6
.github/workflows/docker-description.yml
vendored
6
.github/workflows/docker-description.yml
vendored
@ -4,6 +4,10 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- README.md
|
||||
# workaround for #526
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
docker-description:
|
||||
@ -13,7 +17,7 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Docker Hub Description
|
||||
uses: peter-evans/dockerhub-description@v4.0.0
|
||||
uses: peter-evans/dockerhub-description@v4.0.2
|
||||
if: ${{ env.DOCKER_USERNAME != '' && env.DOCKER_PASSWORD != '' }}
|
||||
env:
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
2
.github/workflows/update.yml
vendored
2
.github/workflows/update.yml
vendored
@ -13,6 +13,8 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.REPO_TOKEN }}
|
||||
|
||||
- name: Run update script
|
||||
run: ./update.sh
|
||||
|
64
README.md
64
README.md
@ -6,7 +6,51 @@
|
||||
[中文](./README_zh_CN.md)
|
||||
|
||||
<!-- start autogeneration tags -->
|
||||
* `2`, `2.0`, `2.0.9`, `latest`, `stable`, `stable-2.0.9`
|
||||
* `2.0.58`, `latest`
|
||||
* `2.0.57`
|
||||
* `2`, `2.0`, `2.0.55`, `stable`, `stable-2.0.55`
|
||||
* `2.0.54`
|
||||
* `2.0.53`
|
||||
* `2.0.52`
|
||||
* `2.0.51`
|
||||
* `2.0.50`
|
||||
* `2.0.49`
|
||||
* `2.0.48`
|
||||
* `2.0`, `2.0.47`, `stable-2.0.47`
|
||||
* `2.0.46`
|
||||
* `2.0.45`
|
||||
* `2.0.44`
|
||||
* `2.0`, `2.0.43`, `stable-2.0.43`
|
||||
* `2.0`, `2.0.42`, `stable-2.0.42`
|
||||
* `2.0`, `2.0.41`, `stable-2.0.41`
|
||||
* `2.0.40`
|
||||
* `2.0`, `2.0.39`, `stable-2.0.39`
|
||||
* `2.0.38`
|
||||
* `2.0.37`
|
||||
* `2.0.36`
|
||||
* `2.0.35`
|
||||
* `2.0.34`
|
||||
* `2.0.33`
|
||||
* `2.0`, `2.0.32`, `stable-2.0.32`
|
||||
* `2.0.31`
|
||||
* `2.0`, `2.0.30`, `stable-2.0.30`
|
||||
* `2.0.29`
|
||||
* `2.0`, `2.0.28`, `stable-2.0.28`
|
||||
* `2.0.27`
|
||||
* `2.0.26`
|
||||
* `2.0.25`
|
||||
* `2.0.24`
|
||||
* `2.0`, `2.0.23`, `stable-2.0.23`
|
||||
* `2.0.22`
|
||||
* `2.0`, `2.0.21`, `stable-2.0.21`
|
||||
* `2.0`, `2.0.20`, `stable-2.0.20`
|
||||
* `2.0.19`
|
||||
* `2.0.18`
|
||||
* `2.0.17`
|
||||
* `2.0.16`
|
||||
* `2.0`, `2.0.15`, `stable-2.0.15`
|
||||
* `2.0`, `2.0.14`, `stable-2.0.14`
|
||||
* `2.0`, `2.0.13`, `stable-2.0.13`
|
||||
* `1`, `1.1`, `1.1.110`, `stable-1.1.110`
|
||||
* `1.0`, `1.0.0`
|
||||
* `0.17`, `0.17.79`
|
||||
@ -19,7 +63,7 @@
|
||||
## Tag descriptions
|
||||
|
||||
* `latest` - most up-to-date version (may be experimental).
|
||||
* `stable` - version declared stable on [factorio.com](https://www.factorio.com).
|
||||
* `stable` - version declared stable on [factorio.com](https://www.factorio.com) ([FFF-435 Since 2.0 versions gets released as experimental first, once stable it will be marked as stable](https://factorio.com/blog/post/fff-435)).
|
||||
* `0.x` - latest version in a branch.
|
||||
* `0.x.y` - a specific version.
|
||||
* `0.x-z` - incremental fix for that version.
|
||||
@ -93,6 +137,15 @@ docker run -d -it \
|
||||
docker attach factorio
|
||||
```
|
||||
|
||||
### RCON (2.0.18+)
|
||||
|
||||
Alternativly (e.g. for scripting) the RCON connection can be used to send commands to the running factorio server.
|
||||
This does not require the RCON connection to be exposed.
|
||||
|
||||
```shell
|
||||
docker exec factorio rcon /h
|
||||
```
|
||||
|
||||
### Upgrading
|
||||
|
||||
Before upgrading backup the save. It's easy to make a save in the client.
|
||||
@ -272,7 +325,7 @@ These are the environment variables which can be specified at container run time
|
||||
| UPDATE_MODS_ON_START | If mods should be updated before starting the server | | 0.17+ |
|
||||
| USERNAME | factorio.com username | | 0.17+ |
|
||||
| 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 | true | 2.0.8+ |
|
||||
| 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
|
||||
@ -431,3 +484,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
|
||||
* [jaredledvina](https://github.com/jaredledvina/docker_factorio_server) - Contributed version updates
|
||||
* [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`
|
||||
|
341
README_zh_CN.md
341
README_zh_CN.md
@ -1,41 +1,86 @@
|
||||
# Factorio-异星工厂 [](https://travis-ci.org/factoriotools/factorio-docker)  [](https://hub.docker.com/r/factoriotools/factorio/) [](https://hub.docker.com/r/factoriotools/factorio/) [](https://hub.docker.com/r/factoriotools/factorio/) [](https://microbadger.com/images/factoriotools/factorio "Get your own image badge on microbadger.com")
|
||||
# Factorio [](https://hub.docker.com/r/factoriotools/factorio/) [](https://hub.docker.com/r/factoriotools/factorio/) [](https://hub.docker.com/r/factoriotools/factorio/)
|
||||
|
||||
版本信息可以在[这里](https://github.com/factoriotools/factorio-docker/blob/master/README.md#factorio------)找到
|
||||
> [!注意]
|
||||
> ARM 架构支持是实验性的。如果你尝试在 Raspberry Pi 上运行,可能会遇到崩溃和延迟问题。
|
||||
|
||||
[English](./README.md)
|
||||
|
||||
<!-- start autogeneration tags -->
|
||||
* `2`, `2.0`, `2.0.55`, `latest`, `stable`, `stable-2.0.55`
|
||||
* `2.0.54`
|
||||
* `2.0.53`
|
||||
* `2.0.52`
|
||||
* `2.0.51`
|
||||
* `2.0.50`
|
||||
* `2.0.49`
|
||||
* `2.0.48`
|
||||
* `2.0`, `2.0.47`, `stable-2.0.47`
|
||||
* `2.0.46`
|
||||
* `2.0.45`
|
||||
* `2.0.44`
|
||||
* `2.0`, `2.0.43`, `stable-2.0.43`
|
||||
* `2.0`, `2.0.42`, `stable-2.0.42`
|
||||
* `2.0`, `2.0.41`, `stable-2.0.41`
|
||||
* `2.0.40`
|
||||
* `2.0`, `2.0.39`, `stable-2.0.39`
|
||||
* `2.0.38`
|
||||
* `2.0.37`
|
||||
* `2.0.36`
|
||||
* `2.0.35`
|
||||
* `2.0.34`
|
||||
* `2.0.33`
|
||||
* `2.0`, `2.0.32`, `stable-2.0.32`
|
||||
* `2.0.31`
|
||||
* `2.0`, `2.0.30`, `stable-2.0.30`
|
||||
* `2.0.29`
|
||||
* `2.0`, `2.0.28`, `stable-2.0.28`
|
||||
* `2.0.27`
|
||||
* `2.0.26`
|
||||
* `2.0.25`
|
||||
* `2.0.24`
|
||||
* `2.0`, `2.0.23`, `stable-2.0.23`
|
||||
* `2.0.22`
|
||||
* `2.0`, `2.0.21`, `stable-2.0.21`
|
||||
* `2.0`, `2.0.20`, `stable-2.0.20`
|
||||
* `2.0.19`
|
||||
* `2.0.18`
|
||||
* `2.0.17`
|
||||
* `2.0.16`
|
||||
* `2.0`, `2.0.15`, `stable-2.0.15`
|
||||
* `2.0`, `2.0.14`, `stable-2.0.14`
|
||||
* `2.0`, `2.0.13`, `stable-2.0.13`
|
||||
* `1`, `1.1`, `1.1.110`, `stable-1.1.110`
|
||||
* `1.0`, `1.0.0`
|
||||
* `0.17`, `0.17.79`
|
||||
* `0.16`, `0.16.51`
|
||||
* `0.15`, `0.15.40`
|
||||
* `0.14`, `0.14.23`
|
||||
* `0.13`, `0.13.20`
|
||||
* `0.12`, `0.12.35`<!-- end autogeneration tags -->
|
||||
|
||||
## 标签描述
|
||||
|
||||
* `latest` - 最新版本 (可能含有实验性功能).
|
||||
* `stable` - 最新的稳定版本 [factorio.com](https://www.factorio.com).
|
||||
* `0.x` - 某个分支上的最新版本
|
||||
* `0.x.y` - 具体的版本
|
||||
* `0.x-z` - 在该版本上的增量更新
|
||||
* `latest` - 最新版本(可能含有实验性功能)。
|
||||
* `stable` - 在 [factorio.com](https://www.factorio.com) 上声明为稳定的版本([FFF-435 自 2.0 版本起,版本首先作为实验版发布,一旦稳定就会被标记为稳定版](https://factorio.com/blog/post/fff-435))。
|
||||
* `0.x` - 某个分支上的最新版本。
|
||||
* `0.x.y` - 具体的版本。
|
||||
* `0.x-z` - 该版本的增量修复。
|
||||
|
||||
## 什么是 Facotrio?
|
||||
## 什么是 Factorio?
|
||||
|
||||
> 摘录自 [steam factorio 页面](https://store.steampowered.com/app/427520/Factorio/)
|
||||
[Factorio](https://www.factorio.com) 是一款建造和维护工厂的游戏。
|
||||
|
||||
「异星工厂」Factorio 是一款建造工业生产流水线并保持其高效运转的游戏。
|
||||
在游戏中,你将挖掘资源、研发科技、建设基础设施、自动化生产并与敌人战斗。发挥你的想象力来设计工厂,将简单的元素组合成巧妙的结构,运用管理技能保持其正常运转,最后保护它不受那些不太喜欢你的生物的侵害。
|
||||
|
||||
在游戏中,你可以抠矿、搞科研、盖工厂、建设自动生产流水线,同时还要与异星虫子们互相伤害。
|
||||
游戏非常稳定,并为建造大规模工厂进行了优化。你可以创建自己的地图,用 Lua 编写模组,或通过多人游戏与朋友一起游戏。
|
||||
|
||||
你将从一无所有艰辛起步。挥斧砍树,抡镐抠矿,手搓机械臂和传送带,然而像这样一直搞下去并没有什么卵用。因此,你需要高效的大规模发电厂,庞大的石油化工体系,壮观的全自动化产业链,以及替你东奔西走的机器人大队,让你成为物资储备丰盈工业帝国的真正操控者!
|
||||
|
||||
然而,总有一群刁民想害你。这个星球上的土著虫群对你在自家后院里瞎折腾的行为很不爽,总有一天这群刁民会联合起来找你麻烦。因此,你要制造武器、建立防御、准备镇压,让它们知道谁才是真正的主宰者。
|
||||
|
||||
你可以在多人游戏中加入不同的阵营,在大触们的带领下与朋友们分工协作, 一起建设恢弘无比的工业园区。
|
||||
|
||||
Factorio的模组支持吸引了全世界的设计师参与到对游戏的完善和革新中来,从优化调整到游戏辅助,甚至对游戏的彻底翻新,日新月异的模组将为你不断提供新的乐趣。
|
||||
除了游戏核心的自由模式和沙盒模式之外,任务包还提供了更多不同形式的游戏挑战,这已经作为一个免费的DLC提供给玩家了。
|
||||
|
||||
对随机生成的地图不满意?不满足于原生游戏任务?这都不是事儿。通过内置的地图编辑器,你可以任意修改地图,配置地形、建筑、敌人等各种元素。如果你是大触,还可以添加自定义脚本,让你的游戏更具独创性、更加阴吹思婷!
|
||||
|
||||
**注意**:这个仓库仅包含游戏服务端. 游戏本体可以在 [factorio.com](factorio.com)、 [Steam](https://store.steampowered.com/app/427520/Factorio/)、[GOG.com](https://www.gog.com/game/factorio) 和 [Humble Bundle](https://www.humblebundle.com/store/factorio) 上找到。
|
||||
**注意**:这仅仅是服务端。完整游戏可在 [Factorio.com](https://www.factorio.com)、[Steam](https://store.steampowered.com/app/427520/)、[GOG.com](https://www.gog.com/game/factorio) 和 [Humble Bundle](https://www.humblebundle.com/store/factorio) 获得。
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 快速入门
|
||||
### 快速开始
|
||||
|
||||
运行服务端以在指定目录下生成必要的配置文件以及存档,`/opt/factorio` 也许是一个不错的选择。
|
||||
运行服务端以创建必要的文件夹结构和配置文件。在这个例子中,数据存储在 `/opt/factorio`。
|
||||
|
||||
```shell
|
||||
sudo mkdir -p /opt/factorio
|
||||
@ -45,59 +90,67 @@ sudo docker run -d \
|
||||
-p 27015:27015/tcp \
|
||||
-v /opt/factorio:/factorio \
|
||||
--name factorio \
|
||||
--restart=always \
|
||||
--restart=unless-stopped \
|
||||
factoriotools/factorio
|
||||
```
|
||||
|
||||
这样一来, 服务端会使用 `/opt/factorio/saves` 中最新的存档进行游戏。
|
||||
对于 Docker 新手,这里解释一下选项:
|
||||
|
||||
你一定想知道上面那些咒语是什么意思:
|
||||
* `-d` - 以守护进程方式运行("分离"模式)。
|
||||
* `-p` - 暴露端口。
|
||||
* `-v` - 将本地文件系统的 `/opt/factorio` 挂载到容器中的 `/factorio`。
|
||||
* `--restart` - 如果服务端崩溃或系统启动时重启服务端。
|
||||
* `--name` - 将容器命名为 "factorio"(否则它会有一个有趣的随机名称)。
|
||||
|
||||
* `-d` - 以守护进程方式运行 ("detached")。
|
||||
* `-p` - 暴露宿主机 (host) 某些端口。
|
||||
* `-v` - 将宿主机中 `/opt/factorio` 目录挂载到docker容器的 `/factorio` 目录。
|
||||
* `--restart` - 在宿主重启或服务端运行崩溃后重启服务端。
|
||||
* `--name` - 将docker容器命名为 "factorio" (否则docker会给他随机起一个搞怪名字)。
|
||||
需要 `chown` 命令是因为在 0.16+ 版本中,出于安全原因,我们不再以 root 身份运行游戏服务端,而是以用户 ID 为 845 的 'factorio' 用户身份运行。因此主机必须允许该用户写入这些文件。
|
||||
|
||||
`chown` 命令用来更改服务端所在目录的所有权用户以及用户组,为了安全起见我们并不希望游戏直接在root用户权限下运行,因此将用户id更改为845,从而服务端允许该用户在目录中进行读、写、运行操作。
|
||||
|
||||
查看日志以搞清楚发生了什么。
|
||||
检查日志以查看发生了什么:
|
||||
|
||||
```shell
|
||||
docker logs factorio
|
||||
```
|
||||
|
||||
停止docker容器 (服务端)。
|
||||
停止服务端:
|
||||
|
||||
```shell
|
||||
docker stop factorio
|
||||
```
|
||||
|
||||
在运行过服务端之后可以在 `/opt/factorio/config` 目录中找到 `server-settings.json` 文件,修改改文件以定制你自己的服务端。
|
||||
现在在 `/opt/factorio/config` 文件夹中有一个 `server-settings.json` 文件。根据你的喜好修改它并重启服务端:
|
||||
|
||||
```shell
|
||||
docker start factorio
|
||||
```
|
||||
|
||||
现在试试连接服务端。如果没有正常运行的话请按照上面步骤查看日志。
|
||||
尝试连接到服务端。如果无法正常工作,请检查日志。
|
||||
|
||||
### Console-终端
|
||||
### 控制台
|
||||
|
||||
为了运行在服务端终端中运行命令,需要通过 `-it` 参数在交互模式下启动服务端。通过 `docker attach` 连接终端从而可以输入命令。
|
||||
要向服务端发出控制台命令,请使用 `-it` 以交互模式启动服务端。使用 `docker attach` 打开控制台,然后输入命令。
|
||||
|
||||
```shell
|
||||
docker run -d -it \
|
||||
--name factorio \
|
||||
factoriotools/factorio
|
||||
|
||||
docker run -d -it \
|
||||
--name factorio \
|
||||
factoriotools/factorio
|
||||
docker attach factorio
|
||||
```
|
||||
|
||||
### 升级服务端
|
||||
### RCON (2.0.18+)
|
||||
|
||||
在升级服务端之前请务必**备份存档**,在客户端(也就是你的游戏中)备份存档相当容易(保存就好)。
|
||||
或者(例如用于脚本),可以使用 RCON 连接向正在运行的 factorio 服务端发送命令。
|
||||
这不需要暴露 RCON 连接。
|
||||
|
||||
请确保在启动服务端时使用了 `-v` 参数,从而服务端将会把存档写在你指定的挂在目录中。`docker rm` 命令会彻底删除运行 facotrio 服务端的容器,也同时会删除容器的整个文件系统实例,因此如果没有挂载外部目录的话,存档也会被删除哦。
|
||||
```shell
|
||||
docker exec factorio rcon /h
|
||||
```
|
||||
|
||||
### 更新
|
||||
|
||||
在升级服务端之前,请备份存档。在客户端中制作存档很容易。
|
||||
|
||||
确保在运行服务端时使用了 `-v` 参数,这样存档就在 Docker 容器外部。`docker rm` 命令会完全销毁容器,如果存档没有存储在数据卷中,也会包括存档。
|
||||
|
||||
删除容器并刷新镜像:
|
||||
|
||||
```shell
|
||||
docker stop factorio
|
||||
@ -105,21 +158,21 @@ docker rm factorio
|
||||
docker pull factoriotools/factorio
|
||||
```
|
||||
|
||||
然后就像前面说的那样启动服务端,大概一分钟后新的服务端就已经在运行中啦,并且存档和设置还和原来一样!
|
||||
现在像之前一样运行服务端。大约一分钟后,新版本的 Factorio 应该就会运行起来,完整保留存档和配置!
|
||||
|
||||
### 存档
|
||||
|
||||
在第一次运行服务端的时候,服务端会根据 `/opt/factorio/config` 目录中的 `map-gen-settings.json` 和 `map-settings.json` 配置文件的内容,在 `/opt/factorio/saves` 目录下会生成一张新地图(存档)`_autosave1.zip`。之后如果在停掉之后再次运行,服务端会载入最新的存档。
|
||||
服务端首次启动时会生成一个名为 `_autosave1.zip` 的新地图。使用 `/opt/factorio/config` 中的 `map-gen-settings.json` 和 `map-settings.json` 文件作为地图设置。在后续运行中使用最新的存档。
|
||||
|
||||
如果想要运行一个旧存档,你需要停止运行中的服务端,并且运行一个命令 `touch oldsave.zip`。 这会重置其日期,然后重新启动服务端。或者你可以通过删除所有其他存档只留下想要运行的存档来完成同样的目的。
|
||||
要加载旧存档,请停止服务端并运行命令 `touch oldsave.zip`。这会重置日期。然后重启服务端。另一个选择是删除除一个存档外的所有存档。
|
||||
|
||||
如果想生成一个新的存档,你需要停止运行中的服务端,然后删除所有的存档再启动服务端就好。
|
||||
要生成新地图,请停止服务端,删除所有存档并重启服务端。
|
||||
|
||||
#### 在运行命令中直接指定存档(需要 0.17.79-2+ 版本)
|
||||
#### 直接指定存档(0.17.79-2+)
|
||||
|
||||
你可以在启动服务端时通过设置一个特殊的环境变量来载入一个特定的存档:
|
||||
你可以通过一组环境变量配置服务端来指定要加载的特定存档:
|
||||
|
||||
设置 `SAVE_NAME` 为 `saves` 中你想运行的存档名,去掉 `.zip` 后缀:
|
||||
要加载现有存档,请将 `SAVE_NAME` 设置为位于 `saves` 目录中的现有存档文件名,不包含 `.zip` 扩展名:
|
||||
|
||||
```shell
|
||||
sudo docker run -d \
|
||||
@ -129,11 +182,11 @@ sudo docker run -d \
|
||||
-e LOAD_LATEST_SAVE=false \
|
||||
-e SAVE_NAME=replaceme \
|
||||
--name factorio \
|
||||
--restart=always \
|
||||
--restart=unless-stopped \
|
||||
factoriotools/factorio
|
||||
```
|
||||
|
||||
若要生成一个新存档,设置 `GENERATE_NEW_SAVE=true`,同时指定存档名 `SAVE_NAME`:
|
||||
要生成新地图,请设置 `GENERATE_NEW_SAVE=true` 并指定 `SAVE_NAME`:
|
||||
|
||||
```shell
|
||||
sudo docker run -d \
|
||||
@ -144,20 +197,19 @@ sudo docker run -d \
|
||||
-e GENERATE_NEW_SAVE=true \
|
||||
-e SAVE_NAME=replaceme \
|
||||
--name factorio \
|
||||
--restart=always \
|
||||
--restart=unless-stopped \
|
||||
factoriotools/factorio
|
||||
```
|
||||
|
||||
### Mods-模组
|
||||
|
||||
将模组拷贝至 `mods` 目录下,然后重启服务端即可。
|
||||
将模组复制到 mods 文件夹中并重启服务端。
|
||||
|
||||
对于 `0.17` 及以上版本,新增 `UPDATE_MODES_ON_START` 环境变量,如果将其设置为 `true`,在服务端启动时将会更新所有的模组。请注意,应用此设置时,必须通过 docker secrets、环境变量或者在 `server-settings.json` 中填写相应字段来提供一个合法的 [Facotrio 用户名以及 Token](https://www.factorio.com/profile),否则服务端就不会启动。
|
||||
从 0.17 版本开始,添加了一个新的环境变量 `UPDATE_MODS_ON_START`,如果设置为 `true`,将在服务端启动时更新模组。如果设置了此选项,必须提供有效的 [Factorio 用户名和令牌](https://www.factorio.com/profile),否则服务端将不会启动。它们可以设置为 docker secrets、环境变量,或从 server-settings.json 文件中获取。
|
||||
|
||||
### Scenarios-场景
|
||||
|
||||
如果你希望新启动一个场景(而不是从某一个存档中启动),你需要通过另一个备选 `entrypoint` 来启动我们的 factorio-docker 镜像:通过运行以下命令,使用 `/factorio/entrypoints` 目录中的示例 entrypoint 文件来启动服务端。仔细观察后就能发现这只是在之前的命令基础上增加了 `--entrypoint` 设置并在最后新增了一个参数用来指示 `scenarios` 目录中想要启动的场景的文件名。
|
||||
|
||||
如果你想从全新开始启动场景(而不是从保存的地图),你需要从备用入口点启动 docker 镜像。为此,请使用存储在卷中 /factorio/entrypoints 目录中的示例入口点文件,并使用以下语法启动镜像。请注意,这是正常语法,添加了 --entrypoint 设置和末尾的附加参数,这是 Scenarios 文件夹中场景的名称。
|
||||
|
||||
```shell
|
||||
docker run -d \
|
||||
@ -165,7 +217,7 @@ docker run -d \
|
||||
-p 27015:27015/tcp \
|
||||
-v /opt/factorio:/factorio \
|
||||
--name factorio \
|
||||
--restart=always \
|
||||
--restart=unless-stopped \
|
||||
--entrypoint "/scenario.sh" \
|
||||
factoriotools/factorio \
|
||||
MyScenarioName
|
||||
@ -173,7 +225,7 @@ docker run -d \
|
||||
|
||||
### 将场景转换为常规地图
|
||||
|
||||
如果你想把你的场景导出为一个常规的地图存档,类似启动一个新的场景,我们可以通过一个备选 `entrypoint` 文件来达到这个效果:服务端在运行后会将场景转换成一个常规地图存档放置在你的 `saves` 目录中,然后你就可以像平常那样启动服务端了。
|
||||
如果你想将场景导出为保存的地图,可以使用类似于上述场景用法的示例入口点。Factorio 将运行一次,将场景转换为 saves 目录中的保存地图。然后使用标准选项重启 docker 镜像将加载该地图,就像上述场景示例刚启动的场景一样。
|
||||
|
||||
```shell
|
||||
docker run -d \
|
||||
@ -181,7 +233,7 @@ docker run -d \
|
||||
-p 27015:27015/tcp \
|
||||
-v /opt/factorio:/factorio \
|
||||
--name factorio \
|
||||
--restart=always \
|
||||
--restart=unless-stopped \
|
||||
--entrypoint "/scenario2map.sh" \
|
||||
factoriotools/factorio
|
||||
MyScenarioName
|
||||
@ -189,51 +241,51 @@ docker run -d \
|
||||
|
||||
### RCON
|
||||
|
||||
在 config/rconpw 文件中设置RCON密码。 如果 rconpw 文件不存在,将会自动生成含有随机密码的该文件。
|
||||
在 `rconpw` 文件中设置 RCON 密码。如果 `rconpw` 不存在,将生成随机密码。
|
||||
|
||||
如果想要更改密码,请停止服务端,编辑rconpw文件并重启服务端。
|
||||
要更改密码,请停止服务端,修改 `rconpw`,然后重启服务端。
|
||||
|
||||
如果想要禁用RCON,请不要在启动命令中加入 -p 27015:27015/tcp 参数,在宿主机(服务器)中停止暴露rcon端口,这时,RCON将继续在docker容器中运行,但不可达。
|
||||
要"禁用" RCON,请不要暴露端口 27015,即不使用 `-p 27015:27015/tcp` 启动服务端。RCON 仍在运行,但没有人可以连接到它。
|
||||
|
||||
|
||||
### 白名单 (0.15.3+)
|
||||
|
||||
创建文件 `config/server-whitelist.json` 然后将用户名加入到该json中。
|
||||
创建文件 `config/server-whitelist.json` 并添加白名单用户。
|
||||
|
||||
```json
|
||||
[
|
||||
"you",
|
||||
"friend"
|
||||
"you",
|
||||
"friend"
|
||||
]
|
||||
```
|
||||
|
||||
### 黑名单 (0.17.1+)
|
||||
|
||||
创建文件 `config/server-banlist.json` 然后将用户名加入到该json中。
|
||||
创建文件 `config/server-banlist.json` 并添加黑名单用户。
|
||||
|
||||
```json
|
||||
[
|
||||
"bad_person",
|
||||
"other_bad_person"
|
||||
"bad_person",
|
||||
"other_bad_person"
|
||||
]
|
||||
```
|
||||
|
||||
### 管理员列表 (0.17.1+)
|
||||
|
||||
创建文件 `config/server-adminlist.json` 然后将用户名加入到该json中。
|
||||
创建文件 `config/server-adminlist.json` 并添加管理员用户。
|
||||
|
||||
```json
|
||||
[
|
||||
"you",
|
||||
"friend"
|
||||
"you",
|
||||
"friend"
|
||||
]
|
||||
```
|
||||
|
||||
### 自定义配置文件 (0.17.x+)
|
||||
|
||||
原始的 factorio 服务端并不支持在配置文件中添加环境变量,这里提供一个变通办法:通过在 docker-compose 中使用 `envsubst` 命令,在服务端启动时根据环境变量来动态生成配置文件:
|
||||
开箱即用的 factorio 不支持配置文件中的环境变量。一个解决方法是使用 `envsubst`,它在启动期间从 docker-compose 中设置的环境变量动态生成配置文件:
|
||||
|
||||
下面的例子将用相应的环境变量来填充 `server-settings.json` 中的字段。
|
||||
替换 server-settings.json 的示例:
|
||||
|
||||
```yaml
|
||||
factorio_1:
|
||||
@ -249,26 +301,47 @@ factorio_1:
|
||||
entrypoint: /bin/sh -c "mkdir -p /factorio/config && envsubst < /server-settings.json > /factorio/config/server-settings.json && exec /docker-entrypoint.sh"
|
||||
```
|
||||
|
||||
`server-settings.json` 中可能提供一些供环境变量来替换的字段:
|
||||
然后 `server-settings.json` 文件可能包含这样的变量引用:
|
||||
|
||||
```json
|
||||
"name": "${INSTANCE_NAME}",
|
||||
"description": "${INSTANCE_DESC}",
|
||||
```
|
||||
|
||||
### 容器相关的细节
|
||||
### 环境变量
|
||||
|
||||
[保持简单](http://wiki.c2.com/?KeepItSimple)的哲学。
|
||||
这些是可以在容器运行时指定的环境变量。
|
||||
|
||||
+ 服务端应当可以自启动
|
||||
+ 在环境变量和配置文件中倾向于配置文件
|
||||
+ 只使用一个数据卷(挂载目录)
|
||||
| 变量名 | 描述 | 默认值 | 可用版本 |
|
||||
|---------------------|----------------------------------------------------------------|----------------|--------------|
|
||||
| GENERATE_NEW_SAVE | 如果在启动服务端之前不存在存档,则生成新存档 | false | 0.17+ |
|
||||
| LOAD_LATEST_SAVE | 为 true 时加载最新存档。否则加载 SAVE_NAME | true | 0.17+ |
|
||||
| PORT | 服务端监听的 UDP 端口 | 34197 | 0.15+ |
|
||||
| BIND | 服务端监听的 IP 地址(v4 或 v6)(IP\[:PORT]) | | 0.15+ |
|
||||
| RCON_PORT | rcon 服务端监听的 TCP 端口 | 27015 | 0.15+ |
|
||||
| SAVE_NAME | 存档文件使用的名称 | _autosave1 | 0.17+ |
|
||||
| TOKEN | factorio.com 令牌 | | 0.17+ |
|
||||
| UPDATE_MODS_ON_START| 是否在启动服务端之前更新模组 | | 0.17+ |
|
||||
| USERNAME | factorio.com 用户名 | | 0.17+ |
|
||||
| CONSOLE_LOG_LOCATION| 将控制台日志保存到指定位置 | | |
|
||||
| DLC_SPACE_AGE | 在 mod-list.json 中启用或禁用 DLC Space Age 的模组[^1] | true | 2.0.8+ |
|
||||
| MODS | 要使用的模组目录 | /factorio/mods | 2.0.8+ |
|
||||
|
||||
**注意**:所有环境变量都作为字符串进行比较
|
||||
|
||||
## 容器细节
|
||||
|
||||
理念是[保持简单](http://wiki.c2.com/?KeepItSimple)。
|
||||
|
||||
* 服务端应该自启动。
|
||||
* 优先使用配置文件而不是环境变量。
|
||||
* 使用一个数据卷。
|
||||
|
||||
### 数据卷
|
||||
|
||||
为了保持简单,我们的 docker 服务端只使用一个数据卷挂载到容器中的 `/factorio` 目录。其中包含了所有的配置,模组和存档。
|
||||
为了保持简单,容器使用挂载在 `/factorio` 的单个卷。此卷存储配置、模组和存档。
|
||||
|
||||
在这个数据卷中所有的文件应当被 uid 为 845 的 factorio 专有用户所拥有(为了安全)
|
||||
此卷中的文件应该由 factorio 用户拥有,uid 845。
|
||||
|
||||
```text
|
||||
factorio
|
||||
@ -286,20 +359,23 @@ factorio_1:
|
||||
`-- _autosave1.zip
|
||||
```
|
||||
|
||||
### Docker Compose
|
||||
## Docker Compose
|
||||
|
||||
[Docker Compose](https://docs.docker.com/compose/install/) 提供了一种便捷的容器运行方式。
|
||||
[Docker Compose](https://docs.docker.com/compose/install/) 是运行 Docker 容器的简便方法。
|
||||
|
||||
首先获取一个 [docker-compose.yml](https://github.com/factoriotools/factorio-docker/blob/master/0.17/docker-compose.yml) 文件。假设你准备使用我们提供的:
|
||||
* 需要 docker-engine >= 1.10.0
|
||||
* 需要 docker-compose >=1.6.0
|
||||
|
||||
首先获取一个 [docker-compose.yml](https://github.com/factoriotools/factorio-docker/blob/master/docker/docker-compose.yml) 文件。从此仓库获取:
|
||||
|
||||
```shell
|
||||
git clone https://github.com/factoriotools/factorio-docker.git
|
||||
cd docker_factorio_server/0.17
|
||||
cd factorio-docker/docker
|
||||
```
|
||||
|
||||
或者假设你想自己编写一个:
|
||||
或者创建你自己的:
|
||||
|
||||
```shell
|
||||
```yaml
|
||||
version: '2'
|
||||
services:
|
||||
factorio:
|
||||
@ -311,7 +387,7 @@ services:
|
||||
- /opt/factorio:/factorio
|
||||
```
|
||||
|
||||
现在通过 cd 命令进入到 `docker-compose.yml` 所在的目录然后运行下面的命令:
|
||||
现在 cd 到包含 docker-compose.yml 的目录并运行:
|
||||
|
||||
```shell
|
||||
sudo mkdir -p /opt/factorio
|
||||
@ -321,14 +397,14 @@ sudo docker-compose up -d
|
||||
|
||||
### 端口
|
||||
|
||||
- `34197/udp` - 游戏服务端(必要)。可以通过改变 `PORT` 环境变量来改变。
|
||||
- `27015/tcp` - RCON(可选)。
|
||||
* `34197/udp` - 游戏服务端(必需)。可以通过 `PORT` 环境变量更改。
|
||||
* `27015/tcp` - RCON(可选)。
|
||||
|
||||
## 局域网游戏
|
||||
|
||||
确保 `server-settings.json` 中的 `lan` 字段被设置为 `true`。
|
||||
确保 server-settings.json 中的 `lan` 设置为 `true`。
|
||||
|
||||
```shell
|
||||
```json
|
||||
"visibility":
|
||||
{
|
||||
"public": false,
|
||||
@ -336,7 +412,7 @@ sudo docker-compose up -d
|
||||
},
|
||||
```
|
||||
|
||||
在启动服务端时假如 `--network=host` 参数,从而客户端可以自动找到局域网游戏,参考 快速入门 章节。
|
||||
使用 `--network=host` 选项启动容器,以便客户端可以自动找到局域网游戏。参考快速入门来创建 `/opt/factorio` 目录。
|
||||
|
||||
```shell
|
||||
sudo docker run -d \
|
||||
@ -345,51 +421,70 @@ sudo docker run -d \
|
||||
-p 27015:27015/tcp \
|
||||
-v /opt/factorio:/factorio \
|
||||
--name factorio \
|
||||
--restart=always \
|
||||
--restart=unless-stopped \
|
||||
factoriotools/factorio
|
||||
```
|
||||
|
||||
## 在其他平台上部署
|
||||
## 部署到其他平台
|
||||
|
||||
### Vagrant
|
||||
|
||||
[Vagrant](https://www.vagrantup.com/) 是一种通过虚拟机来运行 Docker 的便捷方式。 在 [Factorio Vagrant box repository](https://github.com/dtandersen/factorio-lan-vagrant) 中有一个示例的 Vagrantfile。
|
||||
[Vagrant](https://www.vagrantup.com/) 是设置虚拟机(VM)运行 Docker 的简便方法。[Factorio Vagrant box 仓库](https://github.com/dtandersen/factorio-lan-vagrant)包含一个示例 Vagrantfile。
|
||||
|
||||
对于局域网游戏,Vagrant 虚拟机需要一个内部 IP 从而使游戏可达。一种方式是通过在一个空开网络中部署。虚拟机使用 DHCP 方式来获取一个 IP 地址。同时必须转发到 34197 端口。
|
||||
对于局域网游戏,VM 需要内部 IP 以便客户端连接。一种方法是使用公共网络。VM 使用 DHCP 获取 IP 地址。VM 还必须转发端口 34197。
|
||||
|
||||
```ruby
|
||||
config.vm.network "public_network"
|
||||
config.vm.network "forwarded_port", guest: 34197, host: 34197
|
||||
```
|
||||
|
||||
### AWS 部署
|
||||
### Amazon Web Services (AWS) 部署
|
||||
|
||||
如果你想找一个傻瓜教程,请看这个[仓库](https://github.com/m-chandler/factorio-spot-pricing)。这个仓库中包含一个可以让你在几分钟内在 AWS 上搭建服务端的 CloudFormation 模板。同时它支持 Spot Pricing 因此费用会非常便宜,而且你可以在不用的时候把服务器关掉。
|
||||
如果你正在寻找一种简单的方法将此部署到 Amazon Web Services 云,请查看 [Factorio Server Deployment (CloudFormation) 仓库](https://github.com/m-chandler/factorio-spot-pricing)。此仓库包含一个 CloudFormation 模板,可以让你在几分钟内在 AWS 上运行起来。它可选择使用 Spot Pricing,因此服务端非常便宜,你可以在不使用时轻松关闭它。
|
||||
|
||||
## 疑难杂症
|
||||
## 使用反向代理
|
||||
|
||||
### 我可以在服务器列表中看到我的服务器但就是无法连接
|
||||
如果你需要使用反向代理,可以使用以下 nginx 片段:
|
||||
|
||||
查看 log,如果有一行说 `Own address is RIGHT IP:WRONG PORT`,那么这个问题就有可能是 Docker Proxy 导致的。 如果 IP 和端口都是正确的,那么有可能是端口转发或者防火墙出了问题。
|
||||
```
|
||||
stream {
|
||||
server {
|
||||
listen 34197 udp reuseport;
|
||||
proxy_pass my.upstream.host:34197;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
在默认情况下,Docker 通过一个代理来转发网络请求。这个代理会改变 UDP 端口,因此会监测到上面的端口错误。更多细节请移步 *[Incorrect port detected for docker hosted server](https://forums.factorio.com/viewtopic.php?f=49&t=35255)*。
|
||||
如果你的 factorio 主机使用多个 IP 地址(IPv6 非常常见),你可能还需要将 Factorio 绑定到单个 IP(否则 UDP 代理可能会因 IP 不匹配而混乱)。要做到这一点,将 `BIND` 环境变量传递给容器:`docker run --network=host -e BIND=2a02:1234::5678 ...`
|
||||
|
||||
为了修复错误端口问题,在启动 Docker 服务时加上 `--userland-proxy=false`。这样一来 Docker 就会通过 iptables 来转发请求从而不走代理。可以通过设置 `DOCKER_OPTS` 环境变量或者改变 Docker systemd service 中的 `ExecStart` 字段来添加这一参数。不同的操作系统可能有不同的配置方式。
|
||||
## 疑难解答
|
||||
|
||||
### 我不用 34197 端口就没人可以连我的服务器
|
||||
### 我的服务端在服务端浏览器中列出,但没有人可以连接
|
||||
|
||||
如果一定要改端口,请使用 `PORT` 环境变量更改。例如 `docker run -e PORT=34198`。这样会更改端口监测中的目标端口。通过 `-p 34198:34197` 方式更改端口对于私人服务器来说是可行的,但这样一来服务器浏览器就没有办法检测到正确的端口了。
|
||||
检查日志。如果有一行显示 `Own address is RIGHT IP:WRONG PORT`,那么这可能是由 Docker 代理引起的。如果 IP 和端口是正确的,可能是端口转发或防火墙问题。
|
||||
|
||||
默认情况下,Docker 通过代理路由流量。代理更改源 UDP 端口,因此检测到错误的端口。有关详细信息,请参阅论坛帖子 *[docker 托管服务端检测到错误端口](https://forums.factorio.com/viewtopic.php?f=49&t=35255)*。
|
||||
|
||||
为了修复错误端口,使用 `--userland-proxy=false` 开关启动 Docker 服务。Docker 将使用 iptables 规则而不是代理路由流量。将开关添加到 `DOCKER_OPTS` 环境变量或 Docker systemd 服务定义中的 `ExecStart`。具体情况因操作系统而异。
|
||||
|
||||
### 当我在 34197 之外的端口上运行服务端时,没有人可以从服务端浏览器连接
|
||||
|
||||
使用 `PORT` 环境变量在不同端口上启动服务端,例如 `docker run -e "PORT=34198"`。这会更改用于端口检测的数据包的源端口。`-p 34198:34197` 对于私人服务端工作正常,但服务端浏览器检测到错误的端口。
|
||||
|
||||
## 贡献者
|
||||
|
||||
* [dtandersen](https://github.com/dtandersen) - Maintainer
|
||||
* [Fank](https://github.com/Fankserver) - Programmer of the Factorio watchdog that keeps the version up-to-date.
|
||||
* [SuperSandro2000](https://github.com/supersandro2000) - CI Guy, Maintainer and runner of the Factorio watchdog. Contributed version updates and wrote the Travis scripts.
|
||||
* [DBendit](https://github.com/DBendit/docker_factorio_server) - Coded admin list, ban list support and contributed version updates
|
||||
* [Zopanix](https://github.com/zopanix/docker_factorio_server) - Original Author
|
||||
* [Rfvgyhn](https://github.com/Rfvgyhn/docker-factorio) - Coded randomly generated RCON password
|
||||
* [gnomus](https://github.com/gnomus/docker_factorio_server) - Coded wite listing support
|
||||
* [bplein](https://github.com/bplein/docker_factorio_server) - Coded scenario support
|
||||
* [jaredledvina](https://github.com/jaredledvina/docker_factorio_server) - Contributed version updates
|
||||
* [carlbennett](https://github.com/carlbennett) - Contributed version updates and bugfixes
|
||||
* [Thrimbda](https://github.com/Thrimbda) - 中文翻译
|
||||
* [dtandersen](https://github.com/dtandersen) - 维护者
|
||||
* [Fank](https://github.com/Fankserver) - Factorio 监视程序的程序员,保持版本更新。
|
||||
* [SuperSandro2000](https://github.com/supersandro2000) - CI 负责人,维护者和 Factorio 监视程序的运行者。贡献版本更新并编写了 Travis 脚本。
|
||||
* [DBendit](https://github.com/DBendit/docker_factorio_server) - 编写了管理员列表、禁止列表支持并贡献版本更新
|
||||
* [Zopanix](https://github.com/zopanix/docker_factorio_server) - 原作者
|
||||
* [Rfvgyhn](https://github.com/Rfvgyhn/docker-factorio) - 编写了随机生成的 RCON 密码
|
||||
* [gnomus](https://github.com/gnomus/docker_factorio_server) - 编写了白名单支持
|
||||
* [bplein](https://github.com/bplein/docker_factorio_server) - 编写了场景支持
|
||||
* [jaredledvina](https://github.com/jaredledvina/docker_factorio_server) - 贡献版本更新
|
||||
* [carlbennett](https://github.com/carlbennett) - 贡献版本更新和错误修复
|
||||
|
||||
[^1]: Space Age 模组也可以通过使用它们的名称(用空格分隔)来单独启用。
|
||||
示例 1:使用 `true` 启用所有
|
||||
示例 2:通过列出模组名称启用所有 `space-age elevated-rails quality`
|
||||
示例 3:仅启用 Elevated rails `elevated-rails`
|
||||
|
304
buildinfo.json
304
buildinfo.json
@ -57,15 +57,307 @@
|
||||
"1.1.110"
|
||||
]
|
||||
},
|
||||
"2.0.9": {
|
||||
"sha256": "f499077b3e2c1313452c350f1faf17db31cae2a0fa738f69166e97c3caa3c86d",
|
||||
"2.0.13": {
|
||||
"sha256": "27b36901a39e593adf28418c0286142c6c7a9f83d156963c7369bd405a25c7d1",
|
||||
"tags": [
|
||||
"latest",
|
||||
"stable",
|
||||
"stable-2.0.9",
|
||||
"stable-2.0.13",
|
||||
"2.0",
|
||||
"2.0.13"
|
||||
]
|
||||
},
|
||||
"2.0.14": {
|
||||
"sha256": "5a4bc4c3b2a97ed1fc58eb796321e848dcc64435bd91013dd9c78a14a8ce8815",
|
||||
"tags": [
|
||||
"stable-2.0.14",
|
||||
"2.0",
|
||||
"2.0.14"
|
||||
]
|
||||
},
|
||||
"2.0.15": {
|
||||
"sha256": "70b441cb807811a60586c01107248c1d8d7ae043bd1f23675fc924fbaaa538d8",
|
||||
"tags": [
|
||||
"stable-2.0.15",
|
||||
"2.0",
|
||||
"2.0.15"
|
||||
]
|
||||
},
|
||||
"2.0.16": {
|
||||
"sha256": "f2069b4b746500d945eeb67ef7eda5e7aebe7fd0294c2af4e117af22a3bbaea3",
|
||||
"tags": [
|
||||
"2.0.16"
|
||||
]
|
||||
},
|
||||
"2.0.17": {
|
||||
"sha256": "183407f2fb21e05152442ffb5f15ffb283994339ca6a51b3559a257c30505e5e",
|
||||
"tags": [
|
||||
"2.0.17"
|
||||
]
|
||||
},
|
||||
"2.0.18": {
|
||||
"sha256": "f378a1dc8a545c13d8ca616cbe72d245aa3ce93e3f219d8d60d3c06c7df82dc0",
|
||||
"tags": [
|
||||
"2.0.18"
|
||||
]
|
||||
},
|
||||
"2.0.19": {
|
||||
"sha256": "2e27aca3a7f65b50916d14a62203b6861cbe657e8d2dbd8f813e0a606efce9c7",
|
||||
"tags": [
|
||||
"2.0.19"
|
||||
]
|
||||
},
|
||||
"2.0.20": {
|
||||
"sha256": "c4a901f2f1dbedbb41654560db4c6fab683a30c20334e805d4ef740c0416515a",
|
||||
"tags": [
|
||||
"stable-2.0.20",
|
||||
"2.0",
|
||||
"2.0.20"
|
||||
]
|
||||
},
|
||||
"2.0.21": {
|
||||
"sha256": "1d6d2785006d6a8d9d5fdcdaa7097a189ec35ba95f3521025dc4e046f7a1398e",
|
||||
"tags": [
|
||||
"stable-2.0.21",
|
||||
"2.0",
|
||||
"2.0.21"
|
||||
]
|
||||
},
|
||||
"2.0.22": {
|
||||
"sha256": "14c3eea7600fbe7f35bca52fe4c277e8f5e23b34c35ebebaa46c6752c750cb85",
|
||||
"tags": [
|
||||
"2.0.22"
|
||||
]
|
||||
},
|
||||
"2.0.23": {
|
||||
"sha256": "e819fc9ad6df061bf9d4bffc91988dd18d0e3982c8b1c22c0525d78bda3ef216",
|
||||
"tags": [
|
||||
"stable-2.0.23",
|
||||
"2.0",
|
||||
"2.0.23"
|
||||
]
|
||||
},
|
||||
"2.0.24": {
|
||||
"sha256": "4644acc4195391fe19a7468c546d10a494ce1a188964c79f20cb0fa050b67120",
|
||||
"tags": [
|
||||
"2.0.24"
|
||||
]
|
||||
},
|
||||
"2.0.25": {
|
||||
"sha256": "0d1698f1f29759ff27faa6a5d9c3804377cb1767f2692003a8e9d4c294845e5a",
|
||||
"tags": [
|
||||
"2.0.25"
|
||||
]
|
||||
},
|
||||
"2.0.26": {
|
||||
"sha256": "a401024039372a53b9a29b7deb4ac279cd9a34abe69426a109a13a9a1c599f1f",
|
||||
"tags": [
|
||||
"2.0.26"
|
||||
]
|
||||
},
|
||||
"2.0.27": {
|
||||
"sha256": "63c75ce74cd9d1e4b65ae9f98e9865abdbe3d600fb3259dcda5ea69a512b2993",
|
||||
"tags": [
|
||||
"2.0.27"
|
||||
]
|
||||
},
|
||||
"2.0.28": {
|
||||
"sha256": "ea9937b6adc7a18e17a4e1e64992ec389407497b36e68280bb14fcdd4c884dd3",
|
||||
"tags": [
|
||||
"stable-2.0.28",
|
||||
"2.0",
|
||||
"2.0.28"
|
||||
]
|
||||
},
|
||||
"2.0.29": {
|
||||
"sha256": "54088c9cacfddbce2e7bf90604fea095ff723e70d9bb056e1fb469b900a50f09",
|
||||
"tags": [
|
||||
"2.0.29"
|
||||
]
|
||||
},
|
||||
"2.0.30": {
|
||||
"sha256": "4137824a20e1f3298410432c85e62d0eb46b0dab1a8411c233699f890d4c1668",
|
||||
"tags": [
|
||||
"stable-2.0.30",
|
||||
"2.0",
|
||||
"2.0.30"
|
||||
]
|
||||
},
|
||||
"2.0.31": {
|
||||
"sha256": "0ee39ff6181ef41b606b7ba1ab5c04d8f81579ef56ec4947e4d74ce5d192b5d5",
|
||||
"tags": [
|
||||
"2.0.31"
|
||||
]
|
||||
},
|
||||
"2.0.32": {
|
||||
"sha256": "2a6102ae42dcc5e8fe923bd68bcd326a569e35912acde121301e5d4d2d856417",
|
||||
"tags": [
|
||||
"stable-2.0.32",
|
||||
"2.0",
|
||||
"2.0.32"
|
||||
]
|
||||
},
|
||||
"2.0.33": {
|
||||
"sha256": "9365a34d1724e5c9f592cc9da511485e2fa7da1c12df08029bce478586ba4b7b",
|
||||
"tags": [
|
||||
"2.0.33"
|
||||
]
|
||||
},
|
||||
"2.0.34": {
|
||||
"sha256": "9511462203ebb2763f9f8623bb17f3070041ae3cbd7d80284c1e9bb38c09fc40",
|
||||
"tags": [
|
||||
"2.0.34"
|
||||
]
|
||||
},
|
||||
"2.0.35": {
|
||||
"sha256": "31cd58eaf4b06cc0dc5d82640f7adf2366aa9da64133d2c228f1308f1060a990",
|
||||
"tags": [
|
||||
"2.0.35"
|
||||
]
|
||||
},
|
||||
"2.0.36": {
|
||||
"sha256": "e94567b986654f1f7c3ec5c8bd151e3768b4ab9ab9cc389f6b9fd8e0dab32ce2",
|
||||
"tags": [
|
||||
"2.0.36"
|
||||
]
|
||||
},
|
||||
"2.0.37": {
|
||||
"sha256": "5f105131fe4f48d47fd813f57b6bd275840a47b21e39b30d22bf5da30075a786",
|
||||
"tags": [
|
||||
"2.0.37"
|
||||
]
|
||||
},
|
||||
"2.0.38": {
|
||||
"sha256": "ad9650f7456aecc8adb5369eedb418507c7643bede0da60fc1a239878d4902de",
|
||||
"tags": [
|
||||
"2.0.38"
|
||||
]
|
||||
},
|
||||
"2.0.39": {
|
||||
"sha256": "0f8a3d0e43797b5ff4d8b85d7c334b095a3f07d9aa7f80b1e87f94939a93df34",
|
||||
"tags": [
|
||||
"stable-2.0.39",
|
||||
"2.0",
|
||||
"2.0.39"
|
||||
]
|
||||
},
|
||||
"2.0.40": {
|
||||
"sha256": "eac1f24afb68acbfcf1d72d2ad142e8584d77f2d100a3af743f106e50ac176d3",
|
||||
"tags": [
|
||||
"2.0.40"
|
||||
]
|
||||
},
|
||||
"2.0.41": {
|
||||
"sha256": "77ebccae8167fc1a9fc4da8c11e8410f6017b92b1a0913eb58ac5285c9eec399",
|
||||
"tags": [
|
||||
"stable-2.0.41",
|
||||
"2.0",
|
||||
"2.0.41"
|
||||
]
|
||||
},
|
||||
"2.0.42": {
|
||||
"sha256": "b5b8b8bdc915e67dbc1710cd3d6aa6802d397b7c0f47db07da8acf39d5bd6376",
|
||||
"tags": [
|
||||
"stable-2.0.42",
|
||||
"2.0",
|
||||
"2.0.42"
|
||||
]
|
||||
},
|
||||
"2.0.43": {
|
||||
"sha256": "bde6e167330c4439ce7df3ac519ea445120258ef676f1f6ad31d0c2816d3aee3",
|
||||
"tags": [
|
||||
"stable-2.0.43",
|
||||
"2.0",
|
||||
"2.0.43"
|
||||
]
|
||||
},
|
||||
"2.0.44": {
|
||||
"sha256": "9468c5e07080c01eb7a734036160bf806d62cafc11465a23150cfbd210e1036d",
|
||||
"tags": [
|
||||
"2.0.44"
|
||||
]
|
||||
},
|
||||
"2.0.45": {
|
||||
"sha256": "4fd7e04bb3ea7d12da8e1c3befc6b53b3c0064775c960a5a9db6a943f2259fc2",
|
||||
"tags": [
|
||||
"2.0.45"
|
||||
]
|
||||
},
|
||||
"2.0.46": {
|
||||
"sha256": "fc611b6d4078b5d9448284c2890f7e0b6b1f203d52f622c655d3600982489c3e",
|
||||
"tags": [
|
||||
"2.0.46"
|
||||
]
|
||||
},
|
||||
"2.0.47": {
|
||||
"sha256": "f0f320c77616a4794227eb637a70b557108f3141a4633276593220a768f49a26",
|
||||
"tags": [
|
||||
"stable-2.0.47",
|
||||
"2.0",
|
||||
"2.0.47"
|
||||
]
|
||||
},
|
||||
"2.0.48": {
|
||||
"sha256": "f0038835e96bbacc19d52d22d47469882d9ebe41a4e5213c0471020647a1ee2d",
|
||||
"tags": [
|
||||
"2.0.48"
|
||||
]
|
||||
},
|
||||
"2.0.49": {
|
||||
"sha256": "ef0648ca1ba44c145a3a3e4c174ccd276eb4a335155a20df1ae0e47156fa34ff",
|
||||
"tags": [
|
||||
"2.0.49"
|
||||
]
|
||||
},
|
||||
"2.0.50": {
|
||||
"sha256": "81d4aec735473c5bd2c87f09abcd793c31cb9a07d9fdf3c3d7275c78ebe4bc18",
|
||||
"tags": [
|
||||
"2.0.50"
|
||||
]
|
||||
},
|
||||
"2.0.51": {
|
||||
"sha256": "fc940dea67d25d3fd403531520e8afda2779ff1fa8050f535ac1351b7873a070",
|
||||
"tags": [
|
||||
"2.0.51"
|
||||
]
|
||||
},
|
||||
"2.0.52": {
|
||||
"sha256": "be8d6216890089890693d6d94f141f745d35c53e52c6b942f6c944f5c00c8c26",
|
||||
"tags": [
|
||||
"2.0.52"
|
||||
]
|
||||
},
|
||||
"2.0.53": {
|
||||
"sha256": "40a57076f80dbee0238dab62f16585def06f7d7e5b41f6b677be41b4d2cae811",
|
||||
"tags": [
|
||||
"2.0.53"
|
||||
]
|
||||
},
|
||||
"2.0.54": {
|
||||
"sha256": "ad47c541b70763552bcf597202ee84aaac727d0ba158873134dc163a3a0506f0",
|
||||
"tags": [
|
||||
"2.0.54"
|
||||
]
|
||||
},
|
||||
"2.0.55": {
|
||||
"sha256": "ef12a54d1556ae1f84ff99edc23706d13b7ad41f1c02d74ca1dfadf9448fcbae",
|
||||
"tags": [
|
||||
"stable-2.0.55",
|
||||
"2",
|
||||
"2.0",
|
||||
"2.0.9"
|
||||
"2.0.55",
|
||||
"stable"
|
||||
]
|
||||
},
|
||||
"2.0.57": {
|
||||
"sha256": "22b232afb77067c68a3afe087be6a0ee760479262598a12a709e1b03ea9508a6",
|
||||
"tags": [
|
||||
"2.0.57"
|
||||
]
|
||||
},
|
||||
"2.0.58": {
|
||||
"sha256": "be82e1aeba4169420e1b00c12a3e00ec2309a41327f9d6c335feec27bbc885e6",
|
||||
"tags": [
|
||||
"latest",
|
||||
"2.0.58"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
38
docker-compose.yml
Normal file
38
docker-compose.yml
Normal file
@ -0,0 +1,38 @@
|
||||
version: "2"
|
||||
services:
|
||||
factorio:
|
||||
container_name: factorio
|
||||
image: factoriotools/factorio:stable
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "34197:34197/udp"
|
||||
- "27015:27015/tcp"
|
||||
volumes:
|
||||
- ./data:/factorio
|
||||
environment:
|
||||
- UPDATE_MODS_ON_START=true
|
||||
|
||||
# Uncomment to enable autoupdate via watchtower
|
||||
#labels:
|
||||
# # Labels to allow watchtower autoupdate only if no players are online
|
||||
# - com.centurylinklabs.watchtower.enable=true
|
||||
# - com.centurylinklabs.watchtower.scope=factorio
|
||||
# - com.centurylinklabs.watchtower.lifecycle.pre-update="/players-online.sh"
|
||||
|
||||
# Uncomment the following files to use watchtower for updating the factorio container
|
||||
# Full documentation of watchtower: https://github.com/containrrr/watchtower
|
||||
#watchtower:
|
||||
# container_name: watchtower_factorio
|
||||
# image: containrrr/watchtower
|
||||
# restart: unless-stopped
|
||||
# volumes:
|
||||
# - /var/run/docker.sock:/var/run/docker.sock
|
||||
# environment:
|
||||
# # Only update containers which have the option 'watchtower.enable=true' set
|
||||
# - WATCHTOWER_TIMEOUT=30s
|
||||
# - WATCHTOWER_LABEL_ENABLE=true
|
||||
# - WATCHTOWER_POLL_INTERVAL=3600
|
||||
# - WATCHTOWER_LIFECYCLE_HOOKS=true
|
||||
# - WATCHTOWER_SCOPE=factorio
|
||||
# labels:
|
||||
# - com.centurylinklabs.watchtower.scope=factorio
|
@ -1,5 +1,14 @@
|
||||
FROM debian:stable-slim
|
||||
# build rcon client
|
||||
FROM debian:stable-slim AS rcon-builder
|
||||
RUN apt-get -q update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get -qy install build-essential
|
||||
|
||||
WORKDIR /src
|
||||
COPY rcon/ /src
|
||||
RUN make
|
||||
|
||||
# build factorio image
|
||||
FROM debian:stable-slim
|
||||
LABEL maintainer="https://github.com/factoriotools/factorio-docker"
|
||||
|
||||
ARG USER=factorio
|
||||
@ -81,6 +90,7 @@ RUN set -ox pipefail \
|
||||
|
||||
COPY files/*.sh /
|
||||
COPY files/config.ini /opt/factorio/config/config.ini
|
||||
COPY --from=rcon-builder /src/rcon /bin/rcon
|
||||
|
||||
VOLUME /factorio
|
||||
EXPOSE $PORT/udp $RCON_PORT/tcp
|
||||
|
@ -6,19 +6,23 @@ services:
|
||||
args:
|
||||
# Check buildinfo.json for supported versions and SHAs
|
||||
# https://github.com/factoriotools/factorio-docker/blob/master/buildinfo.json
|
||||
- VERSION=2.0.9
|
||||
- SHA256=f499077b3e2c1313452c350f1faf17db31cae2a0fa738f69166e97c3caa3c86d
|
||||
- VERSION=2.0.55
|
||||
- SHA256=ef12a54d1556ae1f84ff99edc23706d13b7ad41f1c02d74ca1dfadf9448fcbae
|
||||
ports:
|
||||
- "34197:34197/udp"
|
||||
- "27015:27015/tcp"
|
||||
volumes:
|
||||
- /opt/factorio:/factorio
|
||||
# environment:
|
||||
# - PUID=1000
|
||||
# - PGID=1000
|
||||
# - UPDATE_MODS_ON_START=true
|
||||
# - USERNAME=FactorioUsername
|
||||
# - TOKEN=FactorioToken
|
||||
# - PORT=34198
|
||||
# - PRESET=deathworld
|
||||
# - ADDR=::1
|
||||
# environment:
|
||||
# - PUID=1000
|
||||
# - PGID=1000
|
||||
# - UPDATE_MODS_ON_START=true
|
||||
# - USERNAME=FactorioUsername
|
||||
# - TOKEN=FactorioToken
|
||||
# - PORT=34198
|
||||
# - PRESET=deathworld
|
||||
# - 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"
|
||||
|
@ -4,6 +4,8 @@ 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"
|
||||
@ -26,18 +28,30 @@ disable_mod()
|
||||
# Enable or disable DLCs if configured
|
||||
if [[ ${DLC_SPACE_AGE:-} == "true" ]]; then
|
||||
# Define the DLC mods
|
||||
DLC_MODS=("elevated-rails" "quality" "space-age")
|
||||
|
||||
# Iterate over each DLC mod
|
||||
for MOD in "${DLC_MODS[@]}"; do
|
||||
enable_mod "$MOD"
|
||||
done
|
||||
else
|
||||
ENABLE_MODS=(${ALL_SPACE_AGE_MODS[@]})
|
||||
elif [[ ${DLC_SPACE_AGE:-} == "false" ]]; then
|
||||
# Define the DLC mods
|
||||
DLC_MODS=("elevated-rails" "quality" "space-age")
|
||||
DISABLE_MODS=(${ALL_SPACE_AGE_MODS[@]})
|
||||
else
|
||||
ENABLE_MODS=()
|
||||
DISABLE_MODS=()
|
||||
|
||||
# Iterate over each DLC mod
|
||||
for MOD in "${DLC_MODS[@]}"; do
|
||||
disable_mod "$MOD"
|
||||
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
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
set -eoux pipefail
|
||||
INSTALLED_DIRECTORY=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
|
||||
FACTORIO_VOL=/factorio
|
||||
LOAD_LATEST_SAVE="${LOAD_LATEST_SAVE:-true}"
|
||||
GENERATE_NEW_SAVE="${GENERATE_NEW_SAVE:-false}"
|
||||
@ -40,10 +41,10 @@ if [[ $NRTMPSAVES -gt 0 ]]; then
|
||||
fi
|
||||
|
||||
if [[ ${UPDATE_MODS_ON_START:-} == "true" ]]; then
|
||||
./docker-update-mods.sh
|
||||
${INSTALLED_DIRECTORY}/docker-update-mods.sh
|
||||
fi
|
||||
|
||||
./docker-dlc.sh
|
||||
${INSTALLED_DIRECTORY}/docker-dlc.sh
|
||||
|
||||
EXEC=""
|
||||
if [[ $(id -u) == 0 ]]; then
|
||||
|
11
docker/files/players-online.sh
Executable file
11
docker/files/players-online.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
PLAYERS=$(rcon /players)
|
||||
ONLINE_COUNT=$(echo "$PLAYERS" | grep -c " (online)$")
|
||||
|
||||
if [[ "$ONLINE_COUNT" -gt "0" ]]; then
|
||||
echo "$PLAYERS"
|
||||
# exit with 75 (EX_TEMPFAIL) so watchtower skips the update
|
||||
# https://containrrr.dev/watchtower/lifecycle-hooks/
|
||||
exit 75
|
||||
fi
|
13
docker/rcon/Makefile
Normal file
13
docker/rcon/Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
# Optimization
|
||||
OPT = -O3 -flto
|
||||
TARGET = rcon
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -std=c17 -Wall -Wextra -pedantic $(OPT)
|
||||
REMOVE = rm -f
|
||||
|
||||
all:
|
||||
$(CC) $(CFLAGS) main.c -o $(TARGET)
|
||||
|
||||
clean:
|
||||
$(REMOVE) $(TARGET)
|
217
docker/rcon/main.c
Normal file
217
docker/rcon/main.c
Normal file
@ -0,0 +1,217 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#define MIN_PACKET 10
|
||||
#define MAX_PACKET 4096
|
||||
#define MAX_BODY (MAX_PACKET - (3 * sizeof(uint32_t)) - 2)
|
||||
|
||||
#define RCON_HOST "127.0.0.1"
|
||||
|
||||
typedef enum {
|
||||
RCON_TYPE_RESPONSE = 0,
|
||||
RCON_TYPE_EXECCOMMAND = 2,
|
||||
RCON_TYPE_AUTH_RESPONSE = 2,
|
||||
RCON_TYPE_AUTH = 3,
|
||||
} packet_type;
|
||||
|
||||
typedef struct {
|
||||
uint32_t length;
|
||||
uint32_t id;
|
||||
packet_type type;
|
||||
char body[MAX_BODY];
|
||||
} packet;
|
||||
|
||||
int rcon_open(const char *port);
|
||||
void rcon_create(packet* pkt, packet_type type, const char* body);
|
||||
bool rcon_send(int rcon_socket, const packet* pkt);
|
||||
bool rcon_auth(int rcon_socket, const char* password);
|
||||
bool rcon_recv(int rcon_socket, packet* pkt, packet_type expected_type);
|
||||
char* combine_args(int argc, char* argv[]);
|
||||
char* read_password(const char* conf_dir);
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "error: missing command argument\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
srand((unsigned int)time(NULL));
|
||||
|
||||
const char* port = getenv("RCON_PORT");
|
||||
if (port == NULL) {
|
||||
fprintf(stderr, "error: missing $RCON_PORT env\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const char* conf_dir = getenv("CONFIG");
|
||||
if (conf_dir == NULL) {
|
||||
fprintf(stderr, "error: missing $CONFIG env");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int rcon_socket = rcon_open(port);
|
||||
if (rcon_socket == -1) {
|
||||
fprintf(stderr, "error: could not connect\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!rcon_auth(rcon_socket, read_password(conf_dir))) {
|
||||
fprintf(stderr, "error: login failed\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
packet pkt;
|
||||
rcon_create(&pkt, RCON_TYPE_EXECCOMMAND, combine_args(argc, argv));
|
||||
if (!rcon_send(rcon_socket, &pkt)) {
|
||||
fprintf(stderr, "error: send command failed\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (rcon_recv(rcon_socket, &pkt, RCON_TYPE_RESPONSE) && pkt.length > 0) {
|
||||
puts(pkt.body);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
char* combine_args(int argc, char* argv[]) {
|
||||
// combine all cli arguments
|
||||
char* command = malloc(MAX_BODY);
|
||||
memset(command, 0, MAX_BODY);
|
||||
strcat(command, argv[1]);
|
||||
|
||||
for (int idx = 2; idx < argc; idx++) {
|
||||
strcat(command, " ");
|
||||
strcat(command, argv[idx]);
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
char* read_password(const char* conf_dir) {
|
||||
char* path = malloc(strlen(conf_dir) + 64);
|
||||
strcpy(path, conf_dir);
|
||||
strcat(path, "/rconpw");
|
||||
|
||||
FILE* fptr = fopen(path, "r");
|
||||
fseek(fptr, 0, SEEK_END);
|
||||
long fsize = ftell(fptr);
|
||||
fseek(fptr, 0, SEEK_SET); /* same as rewind(f); */
|
||||
|
||||
char *password = malloc(fsize + 1);
|
||||
fread(password, fsize, 1, fptr);
|
||||
fclose(fptr);
|
||||
|
||||
password[fsize] = 0;
|
||||
if (password[fsize-1] == '\n') {
|
||||
password[fsize-1] = 0;
|
||||
}
|
||||
|
||||
return password;
|
||||
}
|
||||
|
||||
int rcon_open(const char *port) {
|
||||
struct sockaddr_in address = {
|
||||
.sin_family = AF_INET,
|
||||
.sin_port = htons(atoi(port))
|
||||
};
|
||||
inet_aton(RCON_HOST, &address.sin_addr);
|
||||
|
||||
int rcon_socket = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (connect(rcon_socket, (struct sockaddr*) &address, sizeof(address)) < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
return rcon_socket;
|
||||
}
|
||||
}
|
||||
|
||||
void rcon_create(packet* pkt, packet_type type, const char* body) {
|
||||
size_t body_length = strlen(body);
|
||||
if (body_length >= MAX_BODY - 2) {
|
||||
fprintf(stderr, "error: command to long");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
pkt->id = abs(rand());
|
||||
pkt->type = type;
|
||||
pkt->length = (uint32_t)(sizeof(pkt->id) + sizeof(pkt->type) + body_length + 2);
|
||||
|
||||
memset(pkt->body, 0, MAX_BODY);
|
||||
strncpy(pkt->body, body, MAX_BODY);
|
||||
}
|
||||
|
||||
bool rcon_recv(int rcon_socket, packet* pkt, packet_type expected_type) {
|
||||
memset(pkt, 0, sizeof(*pkt));
|
||||
|
||||
// Read response packet length
|
||||
ssize_t expected_length_bytes = sizeof(pkt->length);
|
||||
ssize_t rx_bytes = recv(rcon_socket, &(pkt->length), expected_length_bytes, 0);
|
||||
|
||||
if (rx_bytes == -1) {
|
||||
perror("error: socket error");
|
||||
return false;
|
||||
} else if (rx_bytes == 0) {
|
||||
fprintf(stderr, "error: no data recieved\n");
|
||||
return false;
|
||||
} else if (rx_bytes < expected_length_bytes || pkt->length < MIN_PACKET || pkt->length > MAX_PACKET) {
|
||||
fprintf(stderr, "error: invalid data\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
ssize_t received = 0;
|
||||
while (received < pkt->length) {
|
||||
rx_bytes = recv(rcon_socket, (char *)pkt + sizeof(pkt->length) + received, pkt->length - received, 0);
|
||||
if (rx_bytes < 0) {
|
||||
perror("error: socket error");
|
||||
return false;
|
||||
} else if (rx_bytes == 0) {
|
||||
fprintf(stderr, "error: connection lost\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
received += rx_bytes;
|
||||
}
|
||||
|
||||
return pkt->type == expected_type;
|
||||
}
|
||||
|
||||
bool rcon_send(int rcon_socket, const packet* pkt) {
|
||||
size_t length = sizeof(pkt->length) + pkt->length;
|
||||
char *ptr = (char*) pkt;
|
||||
|
||||
while (length > 0) {
|
||||
ssize_t ret = send(rcon_socket, ptr, length, 0);
|
||||
|
||||
if (ret == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ptr += ret;
|
||||
length -= ret;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rcon_auth(int rcon_socket, const char* password) {
|
||||
packet pkt;
|
||||
rcon_create(&pkt, RCON_TYPE_AUTH, password);
|
||||
|
||||
if (!rcon_send(rcon_socket, &pkt)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!rcon_recv(rcon_socket, &pkt, RCON_TYPE_AUTH_RESPONSE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -73,8 +73,8 @@ rm -f -- "$tmpfile"
|
||||
|
||||
# Update tag by stable
|
||||
cp buildinfo.json "$tmpfile"
|
||||
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] else . end)' "$tmpfile" > buildinfo.json
|
||||
if [[ "$stable_online_version" == "$stable_current_version" ]]; 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
|
||||
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
|
||||
fi
|
||||
|
Reference in New Issue
Block a user