Skip to content

Commit

Permalink
Merge pull request #21 from hub23/master
Browse files Browse the repository at this point in the history
Added server-settings.json usage
  • Loading branch information
zopanix authored Jul 19, 2016
2 parents b4e35e1 + 6c60f60 commit 8bdb4fc
Show file tree
Hide file tree
Showing 3 changed files with 204 additions and 3 deletions.
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ ENV FACTORIO_AUTOSAVE_INTERVAL=2 \
VERSION=0.13.9 \
FACTORIO_SHA1=34f37abc728670f5763bf0ce90dfe422f0dc5497 \
FACTORIO_WAITING=false \
FACTORIO_MODE=normal
FACTORIO_MODE=normal \
FACTORIO_SERVER_NAME= \
FACTORIO_SERVER_DESCRIPTION= \
FACTORIO_SERVER_MAX_PLAYERS= \
FACTORIO_SERVER_VISIBILITY= \
FACTORIO_USER_USERNAME= \
FACTORIO_USER_PASSWORD= \
# FACTORIO_USER_TOKEN= \
FACTORIO_SERVER_GAME_PASSWORD= \
FACTORIO_SERVER_VERIFY_IDENTITY=

RUN apk --update add bash curl && \
curl -sSL --cacert /opt/factorio.crt https://www.factorio.com/get-download/$VERSION/headless/linux64 -o /tmp/factorio_headless_x64_$VERSION.tar.gz && \
Expand Down
90 changes: 88 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ I'm keeping the image up to date. If you need to use an older version, checkout

How to use ?
-----

### I just want to play !
This runs factorio with default settings, and your save will be kept :
```
Expand All @@ -36,6 +37,7 @@ docker run -d \
zopanix/factorio
```
This will generate a new random map with default settings.

#### With map persistence
```
docker run -d \
Expand All @@ -45,6 +47,7 @@ docker run -d \
```
This will generate a new random map with default settings and save it onto the volume.
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.

#### Autosave interval
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.
```
Expand All @@ -54,6 +57,7 @@ docker run -d \
zopanix/factorio
```
Where [NUMBER] is the number of minutes between autosaves.

#### Autosave slots
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.
```
Expand All @@ -63,6 +67,7 @@ docker run -d \
zopanix/factorio
```
Where [NUMBER] is the number of autosave slots.

#### Mounting mod volume
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.
```
Expand All @@ -72,6 +77,7 @@ docker run -d \
zopanix/factorio
```
Where [PATH] is the path to the folder with your mods.

#### Allowing in-game commands
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".
```
Expand All @@ -80,6 +86,7 @@ docker run -d \
-p [PORT]:34197/udp \
zopanix/factorio
```

#### Activating no-auto-pause in the game when no one is on the server
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".
```
Expand All @@ -96,16 +103,82 @@ docker run -d \
--env FACTORIO_LATENCY_MS=[number] \
-p [PORT]:34197/udp \
zopanix/factorio
```

#### Factorio Mode
I don't know what it is, possibilities are : heavy, complete or none (don't do anything...)
```
docker run -d \
--env FACTORIO_MODE=[MODE] \
-p [PORT]:34197/udp \
zopanix/factorio
```

#### Factorio Server Name
Set Factorio Server Name (defaults to "Factorio Server")
```
docker run -d \
--env FACTORIO_SERVER_NAME=[NAME]
-p [PORT]:34197/udp \
zopanix/factorio
```

#### Factorio Server Description
Set Factorio Server Description (if not specified, no description will be set)
```
docker run -d \
--env FACTORIO_SERVER_DESCRIPTION=[DESCRIPTION]
-p [PORT]:34197/udp \
zopanix/factorio
```

#### Factorio Server Max Players
Set Factorio Server Max Players count (if not specified, maximum players is set to 255)
```
docker run -d \
--env FACTORIO_SERVER_MAX_PLAYERS=[NUMBER]
-p [PORT]:34197/udp \
zopanix/factorio
```

#### Factorio Server Visibility
[//]: # (Set Factorio Server Visibility (if set to public, factorio.com User Login and Password or Token are required))
Set Factorio Server Visibility (if set to public, factorio.com User Login and Password are required)
```
docker run -d \
--env FACTORIO_SERVER_VISIBILITY=[hidden,lan,public]
-p [PORT]:34197/udp \
zopanix/factorio
```

#### Factorio Server factorio.com Login
[//]: # (Set factorio.com User Login and Password or Token required for public server visibility)
[//]: # ( --env FACTORIO_USER_TOKEN=[TOKEN])
Set factorio.com User Login and Password required for public server visibility
```
docker run -d \
--env FACTORIO_USER_USERNAME=[USERNAME]
--env FACTORIO_USER_PASSWORD=[PASSWORD]
-p [PORT]:34197/udp \
zopanix/factorio
```

#### Factorio Server Game Password
Set Factorio Server Game Password (if not specified, no password will be set)
```
docker run -d \
--env FACTORIO_SERVER_GAME_PASSWORD=[GAME-PASSWORD]
-p [PORT]:34197/udp \
zopanix/factorio
```

#### Factorio Server Verify User Identity
Set Verify User Identity to true to require factorio.com account for user to login (defaults to false)
```
docker run -d \
--env FACTORIO_SERVER_VERIFY_IDENTITY=[false,true]
-p [PORT]:34197/udp \
zopanix/factorio
```

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

### Factorio RCON Console Password
#### Factorio RCON Console Password
This allows you to set a password for RCON (if not specified, it will be random)
```
docker run -d \
Expand All @@ -128,6 +201,19 @@ docker run -d \
zopanix/factorio
```

#### Authorization Error
If your container exits with the following error:
```
Info HttpSharedState.cpp:83: Status code: 401
Info AuthServerConnector.cpp:40: Error in communication with auth server: code(401) message({
"message": "Username and password don't match",
"status": 401
})
Info AuthServerConnector.cpp:68: Auth server authorization error (Username and password don't match)
Error Util.cpp:57: Unknown error
```
Check supplied Username and Password for mistakes.

#### Waiting for ready
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.

Expand Down
106 changes: 106 additions & 0 deletions new_smart_launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,88 @@ then
fi
# Setting initial command
factorio_command="/opt/factorio/bin/x64/factorio"
# Include server-settings.json if one or more variables are populated
# removed FACTORIO_USER_TOKEN condition cause of bug (https://github.com/zopanix/docker_factorio_server/issues/23)
if [ "$FACTORIO_SERVER_NAME" ] \
|| [ "$FACTORIO_SERVER_DESCRIPTION" ] \
|| [ "$FACTORIO_SERVER_MAX_PLAYERS" ] \
|| [ "$FACTORIO_SERVER_VISIBILITY" ] \
|| [ "$FACTORIO_USER_USERNAME" ] \
|| [ "$FACTORIO_USER_PASSWORD" ] \
|| [ "$FACTORIO_SERVER_GAME_PASSWORD" ] \
|| [ "$FACTORIO_SERVER_VERIFY_IDENTITY" ]
then
factorio_command="$factorio_command --server-settings /opt/factorio/server-settings.json"
# Set Server Name default value if not set by user param
if [ -z $FACTORIO_SERVER_NAME ]
then
FACTORIO_SERVER_NAME="Factorio Server $VERSION"
fi
# Set Visibility default value if not set by user param
if [ -z $FACTORIO_SERVER_VISIBILITY ]
then
FACTORIO_SERVER_VISIBILITY="hidden"
fi
# Set Verify User Identity default value if not set by user param
if [ -z $FACTORIO_SERVER_VERIFY_IDENTITY ]
then
FACTORIO_SERVER_VERIFY_IDENTITY="false"
fi
# Check for supplied credentials if visibility is set to public
if [ "$FACTORIO_SERVER_VISIBILITY" == "public" ]
then
if [ -z $FACTORIO_USER_USERNAME ]
then
echo "###"
echo "# Server Visibility is set to public but no factorio.com Username is supplied!"
echo "# Append: --env FACTORIO_USER_USERNAME=[USERNAME]"
echo "# Defaulting back to Server Visibility: hidden"
echo "###"
FACTORIO_SERVER_VISIBILITY="hidden"
fi
if [ "$FACTORIO_USER_USERNAME" ]
then
# if [ -z $FACTORIO_USER_PASSWORD ] && [ -z $FACTORIO_USER_TOKEN ]
if [ -z $FACTORIO_USER_PASSWORD ]
then
echo "###"
# echo "# Server Visibility is set to public but neither factorio.com Password or Token is supplied!"
echo "# Server Visibility is set to public but neither factorio.com Password is supplied!"
echo "# Append: --env FACTORIO_USER_PASSWORD=[PASSWORD]"
# echo "# or --env FACTORIO_USER_TOKEN=[TOKEN]"
echo "# Defaulting back to Server Visibility: hidden"
echo "###"
FACTORIO_SERVER_VISIBILITY="hidden"
fi
fi
fi
fi
# Populate server-settings.json
SERVER_SETTINGS=/opt/factorio/server-settings.json
cat << EOF > $SERVER_SETTINGS
{
"name": "$FACTORIO_SERVER_NAME",
"description": "$FACTORIO_SERVER_DESCRIPTION",
"max_players": "$FACTORIO_SERVER_MAX_PLAYERS",
"_comment_visibility": ["public: Game will be published on the official Factorio matching server",
"lan: Game will be broadcast on LAN",
"hidden: Game will not be published anywhere"],
"visibility": "$FACTORIO_SERVER_VISIBILITY",
"_comment_credentials": "Your factorio.com login credentials. Required for games with visibility public",
"username": "$FACTORIO_USER_USERNAME",
"password": "$FACTORIO_USER_PASSWORD",
"_comment_token": "Authentication token. May be used instead of 'password' above.",
"token": "$FACTORIO_USER_TOKEN",
"game_password": "$FACTORIO_SERVER_GAME_PASSWORD",
"_comment_verify_user_identity": "When set to true, the server will only allow clients that have a valid Factorio.com account",
"verify_user_identity": $FACTORIO_SERVER_VERIFY_IDENTITY
}
EOF
# Setting heavy mode option
if [ "$FACTORIO_MODE" == "heavy" ]
then
Expand Down Expand Up @@ -55,6 +137,30 @@ then
echo "###"
fi
factorio_command="$factorio_command --rcon-password $FACTORIO_RCON_PASSWORD"
# Show server-settings.json config
# removed FACTORIO_USER_TOKEN condition cause of bug (https://github.com/zopanix/docker_factorio_server/issues/23)
if [ "$FACTORIO_SERVER_NAME" ] \
|| [ "$FACTORIO_SERVER_DESCRIPTION" ] \
|| [ "$FACTORIO_SERVER_MAX_PLAYERS" ] \
|| [ "$FACTORIO_SERVER_VISIBILITY" ] \
|| [ "$FACTORIO_USER_USERNAME" ] \
|| [ "$FACTORIO_USER_PASSWORD" ] \
|| [ "$FACTORIO_SERVER_GAME_PASSWORD" ] \
|| [ "$FACTORIO_SERVER_VERIFY_IDENTITY" ]
then
echo "###"
echo "# Server Config:"
echo "# Server Name = '$FACTORIO_SERVER_NAME'"
echo "# Server Description = '$FACTORIO_SERVER_DESCRIPTION'"
echo "# Server Password = '$FACTORIO_SERVER_GAME_PASSWORD'"
echo "# Max Players = '$FACTORIO_SERVER_MAX_PLAYERS'"
echo "# Server Visibility = '$FACTORIO_SERVER_VISIBILITY'"
echo "# Verify User Identify = '$FACTORIO_SERVER_VERIFY_IDENTITY'"
echo "# Factorio Username = '$FACTORIO_USER_USERNAME'"
echo "# Factorio Password = '$FACTORIO_USER_PASSWORD'"
# echo "# Factorio User Token = '$FACTORIO_USER_TOKEN'"
echo "###"
fi
# TODO Adding this because of bug, will need to be removed once bug in factorio is fixed
cd /opt/factorio/saves
# Handling save settings
Expand Down

0 comments on commit 8bdb4fc

Please sign in to comment.