diff --git a/README.md b/README.md index d826e8bc..4a38f77f 100644 --- a/README.md +++ b/README.md @@ -257,16 +257,21 @@ The `server-settings.json` file may then contain the variable references like th These are the environment variables which can be specified at container run time. -| Variable Name | Description | Default | Available in | -| - | - | - | - | -| GENERATE_NEW_SAVE | Generate a new save if one does not exist before starting the server | false | 0.17+ | -| LOAD_LATEST_SAVE | Load latest when true. Otherwise load SAVE_NAME | true | 0.17+ | -| PORT | UDP port the server listens on | 34197 | 0.15+ | -| RCON_PORT | TCP port the rcon server listens on | 27015 | 0.15+ | -| SAVE_NAME | Name to use for the save file | _autosave1 | 0.17+ | -| TOKEN | factorio.com token | | 0.17+ | -| UPDATE_MODS_ON_START | If mods should be updated before starting the server | | 0.17+ | -| USERNAME | factorio.com username | | 0.17+ | | +| Variable Name | Description | Default | Available in | +| -------------------- | -------------------------------------------------------------------- | ------------------------------------ | ------------ | +| GENERATE_NEW_SAVE | Generate a new save if one does not exist before starting the server | `false` | 0.17+ | +| LOAD_LATEST_SAVE | Load latest when true. Otherwise load SAVE_NAME | `true` | 0.17+ | +| PORT | UDP port the server listens on | `34197` | 0.15+ | +| RCON_PORT | TCP port the rcon server listens on | `27015` | 0.15+ | +| SAVE_NAME | Name to use for the save file | `_autosave1` | 0.17+ | +| TOKEN | factorio.com token | | 0.17+ | +| UPDATE_MODS_ON_START | If mods should be updated before starting the server | | 0.17+ | +| USERNAME | factorio.com username | | 0.17+ | +| ADMINLIST_FILE | Path to server adminlist file | `/server-adminlist.json` | | +| BANLIST_FILE | Path to server banlist file | `/server-banlist.json` | | +| SERVER_ID_FILE | Path to server ID file | `/server-id.json` | | +| SERVER_SETTINGS_FILE | Path to server settings file | `/server-settings.json` | | +| WHITELIST_FILE | Path to server whitelist file | `/server-whitelist.json` | | **Note:** All environment variables are compared as strings diff --git a/docker/files/docker-entrypoint.sh b/docker/files/docker-entrypoint.sh index ccd7273c..7e6820da 100755 --- a/docker/files/docker-entrypoint.sh +++ b/docker/files/docker-entrypoint.sh @@ -13,14 +13,26 @@ mkdir -p "$MODS" mkdir -p "$SCENARIOS" mkdir -p "$SCRIPTOUTPUT" +# Initialize Factorio server configuration files location variables... +SERVER_ADMINLIST_FILE="${SERVER_ADMINLIST_FILE:-$CONFIG/server-adminlist.json}" +SERVER_BANLIST_FILE="${SERVER_BANLIST_FILE:-$CONFIG/server-banlist.json}" +SERVER_ID_FILE="${SERVER_ID_FILE:-$CONFIG/server-id.json}" +SERVER_SETTINGS_FILE="${SERVER_SETTINGS_FILE:-$CONFIG/server-settings.json}" +SERVER_WHITELIST_FILE="${SERVER_WHITELIST_FILE:-$CONFIG/server-whitelist.json}" +mkdir -p "$(dirname "$SERVER_ADMINLIST_FILE")" +mkdir -p "$(dirname "$SERVER_BANLIST_FILE")" +mkdir -p "$(dirname "$SERVER_ID_FILE")" +mkdir -p "$(dirname "$SERVER_SETTINGS_FILE")" +mkdir -p "$(dirname "$SERVER_WHITELIST_FILE")" + if [[ ! -f $CONFIG/rconpw ]]; then # Generate a new RCON password if none exists pwgen 15 1 >"$CONFIG/rconpw" fi -if [[ ! -f $CONFIG/server-settings.json ]]; then +if [[ ! -f $SERVER_SETTINGS_FILE ]]; then # Copy default settings if server-settings.json doesn't exist - cp /opt/factorio/data/server-settings.example.json "$CONFIG/server-settings.json" + cp /opt/factorio/data/server-settings.example.json "$SERVER_SETTINGS_FILE" fi if [[ ! -f $CONFIG/map-gen-settings.json ]]; then @@ -78,14 +90,14 @@ fi FLAGS=(\ --port "$PORT" \ - --server-settings "$CONFIG/server-settings.json" \ - --server-banlist "$CONFIG/server-banlist.json" \ + --rcon-password "$(cat "$CONFIG/rconpw")" \ --rcon-port "$RCON_PORT" \ - --server-whitelist "$CONFIG/server-whitelist.json" \ + --server-adminlist "$SERVER_ADMINLIST_FILE" \ + --server-banlist "$SERVER_BANLIST_FILE" \ + --server-id "$SERVER_ID_FILE" \ + --server-settings "$SERVER_SETTINGS_FILE" \ + --server-whitelist "$SERVER_WHITELIST_FILE" \ --use-server-whitelist \ - --server-adminlist "$CONFIG/server-adminlist.json" \ - --rcon-password "$(cat "$CONFIG/rconpw")" \ - --server-id /factorio/config/server-id.json \ ) if [[ $LOAD_LATEST_SAVE == true ]]; then