Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out a way to do a general "server-settings.json" and override the values per instance #8

Open
psihius opened this issue May 1, 2017 · 3 comments

Comments

@psihius
Copy link
Member

psihius commented May 1, 2017

I think there needs to be a base file and ability to override certain values if needed. Mostly these are:

  • Game name
  • Game Description
  • Password
  • Max players

Everything else is basically the same - I do not change other settings from instance to instance.
The basic premise here is that I need to add a person to the default admin list and right now I will have to go through each instance config file and add him in. Also, I need to copy the config file each time.
We can just have a template file with bash variable substitutions and write it to the instance folder with each start/restart of the service, that way all the updates are going to be propagated each server update.

@maikelwever
Copy link
Contributor

I'm not experienced enough with bash to make this work in bash, would it be fine to introduce a dependency on Python and make a Python script which does this?

I'd suggest we create these new init.conf variables:

GAME_NAME="FactorioMMO main server"
GAME_DESCRIPTION="All are welcome!"
GAME_PASSWORD="asdasd"
GAME_MAX_PLAYERS=42

@maikelwever
Copy link
Contributor

Oh and if we're going this way, why not also include the user token with these so we can get rid of server-settings.json altogether.

@psihius
Copy link
Member Author

psihius commented May 1, 2017

Yes, we can actually put the whole "server-settings.json" file settings into the init.conf and generate the file from it. That would be ideal and give full control and ability to override specific options on an instance level only,

As far as bash goes - i'm not an expert too - it is quite basic:

cat >/etc/factorio/$INSTANCE_NAME/server-settings.json <<EOF
{
  "name": "${GAME_NAME}",
  "description": "${GAME_DESCRIPTION}",
  "tags": [${GAME_TAGS}],

  "_comment_max_players": "Maximum number of players allowed, admins can join even a full server. 0 means unlimited.",
  "max_players": ${GAME_PLAYERS},

  "_comment_visibility": ["public: Game will be published on the official Factorio matching server",
                          "lan: Game will be broadcast on LAN"],
  "visibility":
  {
    "public": true,
    "lan": true
  },

  "_comment_credentials": "Your factorio.com login credentials. Required for games with visibility public",
  "username": "$GAME_USERNAME",
  "password": ""$GAME_USER_PASSWORD,

  "_comment_token": "Authentication token. May be used instead of 'password' above.",
  "token": "$GAME_TOKEN",

  "game_password": "${GAME_PASSWORD}",

  ..........

  "admins": [${GAME_ADMIN_LIST}]
}

EOF

And you define those in the global init.conf with default values and then override what you need in the instance specific file how you need it.
GAME_NAME=.....

The only thing I do not know right now is how to deal with lists that are GAME_ADMIN_LIST and GAME_KEYWORDS as you need to provide a list as "mmo", "factoriommo" for it to be correct and I don't think you can use GAME_KEYWORDS="mmo","factoriommo" type syntax in the config file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants