factorio/bin/entrypoint.sh

25 lines
1,019 B
Bash
Raw Normal View History

#!/usr/bin/env bash
set -ex
2017-04-30 21:58:44 +02:00
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
2017-04-30 21:58:44 +02:00
# Create savefile, if none exists
[ ! -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}
# "$@"
2017-04-30 21:58:44 +02:00
cd ${RUN_DIR}
2017-04-30 21:58:44 +02:00
exec ${FACTORIO_BIN} --start-server ${WORLDNAME} "$@"