Open psihius opened 7 years ago
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
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.
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
I think there needs to be a base file and ability to override certain values if needed. Mostly these are:
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.