Skip to content

Commit 8bdb4fc

Browse files
authored
Merge pull request #21 from hub23/master
Added server-settings.json usage
2 parents b4e35e1 + 6c60f60 commit 8bdb4fc

File tree

3 files changed

+204
-3
lines changed

3 files changed

+204
-3
lines changed

Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@ ENV FACTORIO_AUTOSAVE_INTERVAL=2 \
1717
VERSION=0.13.9 \
1818
FACTORIO_SHA1=34f37abc728670f5763bf0ce90dfe422f0dc5497 \
1919
FACTORIO_WAITING=false \
20-
FACTORIO_MODE=normal
20+
FACTORIO_MODE=normal \
21+
FACTORIO_SERVER_NAME= \
22+
FACTORIO_SERVER_DESCRIPTION= \
23+
FACTORIO_SERVER_MAX_PLAYERS= \
24+
FACTORIO_SERVER_VISIBILITY= \
25+
FACTORIO_USER_USERNAME= \
26+
FACTORIO_USER_PASSWORD= \
27+
# FACTORIO_USER_TOKEN= \
28+
FACTORIO_SERVER_GAME_PASSWORD= \
29+
FACTORIO_SERVER_VERIFY_IDENTITY=
2130

2231
RUN apk --update add bash curl && \
2332
curl -sSL --cacert /opt/factorio.crt https://www.factorio.com/get-download/$VERSION/headless/linux64 -o /tmp/factorio_headless_x64_$VERSION.tar.gz && \

README.md

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ I'm keeping the image up to date. If you need to use an older version, checkout
1717

1818
How to use ?
1919
-----
20+
2021
### I just want to play !
2122
This runs factorio with default settings, and your save will be kept :
2223
```
@@ -36,6 +37,7 @@ docker run -d \
3637
zopanix/factorio
3738
```
3839
This will generate a new random map with default settings.
40+
3941
#### With map persistence
4042
```
4143
docker run -d \
@@ -45,6 +47,7 @@ docker run -d \
4547
```
4648
This will generate a new random map with default settings and save it onto the volume.
4749
Replace [PATH] with a path to a folder on the host where the map will be saved. If existing saves exist it will take the latest one.
50+
4851
#### Autosave interval
4952
You can set the autosave interval. By default it is set at 2 minutes bud you can change it by launching the container with the "FACTORIO_AUTOSAVE_INTERVAL" variable to whatever suits you best.
5053
```
@@ -54,6 +57,7 @@ docker run -d \
5457
zopanix/factorio
5558
```
5659
Where [NUMBER] is the number of minutes between autosaves.
60+
5761
#### Autosave slots
5862
You can set the number of autosave slots. By default it is set at 3 slots bud you can change it by launching the container with the "FACTORIO_AUTOSAVE_SLOTS" variable to whatever suits you best.
5963
```
@@ -63,6 +67,7 @@ docker run -d \
6367
zopanix/factorio
6468
```
6569
Where [NUMBER] is the number of autosave slots.
70+
6671
#### Mounting mod volume
6772
As everybody knows about factorio is you can add mods to it. Now you can also do it in this docker image by mounting a volume.
6873
```
@@ -72,6 +77,7 @@ docker run -d \
7277
zopanix/factorio
7378
```
7479
Where [PATH] is the path to the folder with your mods.
80+
7581
#### Allowing in-game commands
7682
I've always disabled in-game commands because I think it is like cheating, however, you can enable them by setting the the "FACTORIO_ALLOW_COMMANDS" variable to "true".
7783
```
@@ -80,6 +86,7 @@ docker run -d \
8086
-p [PORT]:34197/udp \
8187
zopanix/factorio
8288
```
89+
8390
#### Activating no-auto-pause in the game when no one is on the server
8491
I do not recommend this feature, bud it can make the game more difficult if you're up for a challenge :-). Just set the "FACTORIO_NO_AUTO_PAUSE" variable to "true".
8592
```
@@ -96,16 +103,82 @@ docker run -d \
96103
--env FACTORIO_LATENCY_MS=[number] \
97104
-p [PORT]:34197/udp \
98105
zopanix/factorio
99-
100106
```
107+
101108
#### Factorio Mode
102109
I don't know what it is, possibilities are : heavy, complete or none (don't do anything...)
103110
```
104111
docker run -d \
105112
--env FACTORIO_MODE=[MODE] \
106113
-p [PORT]:34197/udp \
107114
zopanix/factorio
115+
```
116+
117+
#### Factorio Server Name
118+
Set Factorio Server Name (defaults to "Factorio Server")
119+
```
120+
docker run -d \
121+
--env FACTORIO_SERVER_NAME=[NAME]
122+
-p [PORT]:34197/udp \
123+
zopanix/factorio
124+
```
108125

126+
#### Factorio Server Description
127+
Set Factorio Server Description (if not specified, no description will be set)
128+
```
129+
docker run -d \
130+
--env FACTORIO_SERVER_DESCRIPTION=[DESCRIPTION]
131+
-p [PORT]:34197/udp \
132+
zopanix/factorio
133+
```
134+
135+
#### Factorio Server Max Players
136+
Set Factorio Server Max Players count (if not specified, maximum players is set to 255)
137+
```
138+
docker run -d \
139+
--env FACTORIO_SERVER_MAX_PLAYERS=[NUMBER]
140+
-p [PORT]:34197/udp \
141+
zopanix/factorio
142+
```
143+
144+
#### Factorio Server Visibility
145+
[//]: # (Set Factorio Server Visibility (if set to public, factorio.com User Login and Password or Token are required))
146+
Set Factorio Server Visibility (if set to public, factorio.com User Login and Password are required)
147+
```
148+
docker run -d \
149+
--env FACTORIO_SERVER_VISIBILITY=[hidden,lan,public]
150+
-p [PORT]:34197/udp \
151+
zopanix/factorio
152+
```
153+
154+
#### Factorio Server factorio.com Login
155+
[//]: # (Set factorio.com User Login and Password or Token required for public server visibility)
156+
[//]: # ( --env FACTORIO_USER_TOKEN=[TOKEN])
157+
Set factorio.com User Login and Password required for public server visibility
158+
```
159+
docker run -d \
160+
--env FACTORIO_USER_USERNAME=[USERNAME]
161+
--env FACTORIO_USER_PASSWORD=[PASSWORD]
162+
-p [PORT]:34197/udp \
163+
zopanix/factorio
164+
```
165+
166+
#### Factorio Server Game Password
167+
Set Factorio Server Game Password (if not specified, no password will be set)
168+
```
169+
docker run -d \
170+
--env FACTORIO_SERVER_GAME_PASSWORD=[GAME-PASSWORD]
171+
-p [PORT]:34197/udp \
172+
zopanix/factorio
173+
```
174+
175+
#### Factorio Server Verify User Identity
176+
Set Verify User Identity to true to require factorio.com account for user to login (defaults to false)
177+
```
178+
docker run -d \
179+
--env FACTORIO_SERVER_VERIFY_IDENTITY=[false,true]
180+
-p [PORT]:34197/udp \
181+
zopanix/factorio
109182
```
110183

111184
#### Factorio RCON Console Port
@@ -119,7 +192,7 @@ docker run -d \
119192
Where PORT_RCON is the port you want to use.
120193
By default a random password is set bud ... see below
121194

122-
### Factorio RCON Console Password
195+
#### Factorio RCON Console Password
123196
This allows you to set a password for RCON (if not specified, it will be random)
124197
```
125198
docker run -d \
@@ -128,6 +201,19 @@ docker run -d \
128201
zopanix/factorio
129202
```
130203

204+
#### Authorization Error
205+
If your container exits with the following error:
206+
```
207+
Info HttpSharedState.cpp:83: Status code: 401
208+
Info AuthServerConnector.cpp:40: Error in communication with auth server: code(401) message({
209+
"message": "Username and password don't match",
210+
"status": 401
211+
})
212+
Info AuthServerConnector.cpp:68: Auth server authorization error (Username and password don't match)
213+
Error Util.cpp:57: Unknown error
214+
```
215+
Check supplied Username and Password for mistakes.
216+
131217
#### Waiting for ready
132218
This is a beta feature which has nothing to do with factorio... leave it as it is for the moment. I'm working with some collegues on something new which should work very well and please a lot of people.
133219

new_smart_launch.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,88 @@ then
2121
fi
2222
# Setting initial command
2323
factorio_command="/opt/factorio/bin/x64/factorio"
24+
# Include server-settings.json if one or more variables are populated
25+
# removed FACTORIO_USER_TOKEN condition cause of bug (https://github.com/zopanix/docker_factorio_server/issues/23)
26+
if [ "$FACTORIO_SERVER_NAME" ] \
27+
|| [ "$FACTORIO_SERVER_DESCRIPTION" ] \
28+
|| [ "$FACTORIO_SERVER_MAX_PLAYERS" ] \
29+
|| [ "$FACTORIO_SERVER_VISIBILITY" ] \
30+
|| [ "$FACTORIO_USER_USERNAME" ] \
31+
|| [ "$FACTORIO_USER_PASSWORD" ] \
32+
|| [ "$FACTORIO_SERVER_GAME_PASSWORD" ] \
33+
|| [ "$FACTORIO_SERVER_VERIFY_IDENTITY" ]
34+
then
35+
factorio_command="$factorio_command --server-settings /opt/factorio/server-settings.json"
36+
# Set Server Name default value if not set by user param
37+
if [ -z $FACTORIO_SERVER_NAME ]
38+
then
39+
FACTORIO_SERVER_NAME="Factorio Server $VERSION"
40+
fi
41+
# Set Visibility default value if not set by user param
42+
if [ -z $FACTORIO_SERVER_VISIBILITY ]
43+
then
44+
FACTORIO_SERVER_VISIBILITY="hidden"
45+
fi
46+
# Set Verify User Identity default value if not set by user param
47+
if [ -z $FACTORIO_SERVER_VERIFY_IDENTITY ]
48+
then
49+
FACTORIO_SERVER_VERIFY_IDENTITY="false"
50+
fi
51+
# Check for supplied credentials if visibility is set to public
52+
if [ "$FACTORIO_SERVER_VISIBILITY" == "public" ]
53+
then
54+
if [ -z $FACTORIO_USER_USERNAME ]
55+
then
56+
echo "###"
57+
echo "# Server Visibility is set to public but no factorio.com Username is supplied!"
58+
echo "# Append: --env FACTORIO_USER_USERNAME=[USERNAME]"
59+
echo "# Defaulting back to Server Visibility: hidden"
60+
echo "###"
61+
FACTORIO_SERVER_VISIBILITY="hidden"
62+
fi
63+
if [ "$FACTORIO_USER_USERNAME" ]
64+
then
65+
# if [ -z $FACTORIO_USER_PASSWORD ] && [ -z $FACTORIO_USER_TOKEN ]
66+
if [ -z $FACTORIO_USER_PASSWORD ]
67+
then
68+
echo "###"
69+
# echo "# Server Visibility is set to public but neither factorio.com Password or Token is supplied!"
70+
echo "# Server Visibility is set to public but neither factorio.com Password is supplied!"
71+
echo "# Append: --env FACTORIO_USER_PASSWORD=[PASSWORD]"
72+
# echo "# or --env FACTORIO_USER_TOKEN=[TOKEN]"
73+
echo "# Defaulting back to Server Visibility: hidden"
74+
echo "###"
75+
FACTORIO_SERVER_VISIBILITY="hidden"
76+
fi
77+
fi
78+
fi
79+
fi
80+
# Populate server-settings.json
81+
SERVER_SETTINGS=/opt/factorio/server-settings.json
82+
cat << EOF > $SERVER_SETTINGS
83+
{
84+
"name": "$FACTORIO_SERVER_NAME",
85+
"description": "$FACTORIO_SERVER_DESCRIPTION",
86+
"max_players": "$FACTORIO_SERVER_MAX_PLAYERS",
87+
88+
"_comment_visibility": ["public: Game will be published on the official Factorio matching server",
89+
"lan: Game will be broadcast on LAN",
90+
"hidden: Game will not be published anywhere"],
91+
"visibility": "$FACTORIO_SERVER_VISIBILITY",
92+
93+
"_comment_credentials": "Your factorio.com login credentials. Required for games with visibility public",
94+
"username": "$FACTORIO_USER_USERNAME",
95+
"password": "$FACTORIO_USER_PASSWORD",
96+
97+
"_comment_token": "Authentication token. May be used instead of 'password' above.",
98+
"token": "$FACTORIO_USER_TOKEN",
99+
100+
"game_password": "$FACTORIO_SERVER_GAME_PASSWORD",
101+
102+
"_comment_verify_user_identity": "When set to true, the server will only allow clients that have a valid Factorio.com account",
103+
"verify_user_identity": $FACTORIO_SERVER_VERIFY_IDENTITY
104+
}
105+
EOF
24106
# Setting heavy mode option
25107
if [ "$FACTORIO_MODE" == "heavy" ]
26108
then
@@ -55,6 +137,30 @@ then
55137
echo "###"
56138
fi
57139
factorio_command="$factorio_command --rcon-password $FACTORIO_RCON_PASSWORD"
140+
# Show server-settings.json config
141+
# removed FACTORIO_USER_TOKEN condition cause of bug (https://github.com/zopanix/docker_factorio_server/issues/23)
142+
if [ "$FACTORIO_SERVER_NAME" ] \
143+
|| [ "$FACTORIO_SERVER_DESCRIPTION" ] \
144+
|| [ "$FACTORIO_SERVER_MAX_PLAYERS" ] \
145+
|| [ "$FACTORIO_SERVER_VISIBILITY" ] \
146+
|| [ "$FACTORIO_USER_USERNAME" ] \
147+
|| [ "$FACTORIO_USER_PASSWORD" ] \
148+
|| [ "$FACTORIO_SERVER_GAME_PASSWORD" ] \
149+
|| [ "$FACTORIO_SERVER_VERIFY_IDENTITY" ]
150+
then
151+
echo "###"
152+
echo "# Server Config:"
153+
echo "# Server Name = '$FACTORIO_SERVER_NAME'"
154+
echo "# Server Description = '$FACTORIO_SERVER_DESCRIPTION'"
155+
echo "# Server Password = '$FACTORIO_SERVER_GAME_PASSWORD'"
156+
echo "# Max Players = '$FACTORIO_SERVER_MAX_PLAYERS'"
157+
echo "# Server Visibility = '$FACTORIO_SERVER_VISIBILITY'"
158+
echo "# Verify User Identify = '$FACTORIO_SERVER_VERIFY_IDENTITY'"
159+
echo "# Factorio Username = '$FACTORIO_USER_USERNAME'"
160+
echo "# Factorio Password = '$FACTORIO_USER_PASSWORD'"
161+
# echo "# Factorio User Token = '$FACTORIO_USER_TOKEN'"
162+
echo "###"
163+
fi
58164
# TODO Adding this because of bug, will need to be removed once bug in factorio is fixed
59165
cd /opt/factorio/saves
60166
# Handling save settings

0 commit comments

Comments
 (0)