Use default configuration if none defined

This commit is contained in:
paul 2024-02-23 15:18:50 +01:00
parent 919226b2b5
commit c431878633

View file

@ -1,15 +1,23 @@
#!/bin/bash
set -e
#!/usr/bin/env bash
set -ex
BASE_DIR=/opt/factorio
RUN_DIR=${BASE_DIR}/headless/factorio
FACTORIO_BIN=${RUN_DIR}/bin/x64/factorio
WORLDNAME=${BASE_DIR}/saves/world.zip
MAP_GEN_SETTINGS=${BASE_DIR}/settings/map-gen-settings.json
MAP_SETTINGS=${BASE_DIR}/settings/map-settings.json
SERVER_SETTINGS=${BASE_DIR}/settings/server-settings.json
# Create savefile, if none exists
[ ! -f ${WORLDNAME} ] && ${FACTORIO_BIN} --create ${WORLDNAME} "$@"
[ ! -f ${MAP_GEN_SETTINGS} ] && wget -O ${MAP_GEN_SETTINGS} "https://raw.githubusercontent.com/wube/factorio-data/master/map-gen-settings.example.json"
[ ! -f ${MAP_SETTINGS} ] && wget -O ${MAP_SETTINGS} "https://raw.githubusercontent.com/wube/factorio-data/master/map-settings.example.json"
[ ! -f ${SERVER_SETTINGS} ] && wget -O ${SERVER_SETTINGS} "https://github.com/wube/factorio-data/blob/master/server-settings.example.json"
[ ! -f ${WORLDNAME} ] && \
${FACTORIO_BIN} --create ${WORLDNAME} --map-gen-settings ${MAP_GEN_SETTINGS} --map-settings ${MAP_SETTINGS}
# "$@"
cd ${RUN_DIR}