zopanix / docker_factorio_server

Factorio Server in Docker
MIT License
31 stars 275 forks source link

Added the ability to set a Server Password #20

Closed hub23 closed 8 years ago

hub23 commented 8 years ago

By adding --server-settings /opt/server-settings.json parameter to the available new_smart_launch.sh factorio server commands, some settings are available. The defaults (/opt/factorio/data/server-settings.example.json in zopanix/factorio:0.13.8) for the server-settings.json to contain are:

  "name": "Name of the game as it will appear in the game listing",
  "description": "Description of the game that will appear in the listing",
  "tags": ["game", "tags"],
  "max_players": "0",
  "visibility": "public",
  "username": "",
  "password": "",
  "game_password": "",
  "verify_user_identity": true

Some comment values and braces are hidden in this comment.

If default values are missing from server-settings.json, the server wont start (Although I did not test one by one, just tested by removing "name", I assume all defaults are needed.).

In the server-settings.json contained in this repo, the following changes were made up to now:

  "game_password": "sometemppassword",
  "visibility": "hidden",
  "verify_user_identity": false

Other choices for visibility are lan and public, if set to public the server will be published on the official Factorio matching server. factorio.com login credentials are required for public listing.

Credentials can be supplied by setting username and password or token in server-settings.json file.

If verify_user_identity is true, user will need a valid factorio.com account to connect.

If the var FACTORIO_GAME_PASSWORD contains a value, an if condition in new_smart_launch.sh will execute the following:

factorio_command="$factorio_command --server-settings /opt/server-settings.json"

sed "s/sometemppassword/$FACTORIO_GAME_PASSWORD/g" /opt/server-settings.json > tmpfile; mv tmpfile /opt/server-settings.json

Also: my first forked repo and pull request :grinning:

hub23 commented 8 years ago

I will rebuild this and add another request later on.