factorio-docker/0.14/docker-entrypoint.sh

36 lines
896 B
Bash
Raw Normal View History

2016-11-01 21:31:24 +01:00
#!/bin/sh -x
set -euo pipefail
2016-10-27 01:15:09 +02:00
2016-11-01 21:31:24 +01:00
SAVES=/factorio/saves
CONFIG=/factorio/config
2016-10-25 18:49:23 +02:00
mkdir -p "$SAVES"
2016-10-27 01:15:09 +02:00
mkdir -p /factorio/mods
mkdir -p "$CONFIG"
2016-10-27 01:15:09 +02:00
2016-11-01 21:31:24 +01:00
if [ ! -f $CONFIG/rconpw ]; then
pwgen 15 1 >"$CONFIG/rconpw"
2016-10-31 20:59:57 +01:00
fi
if [ ! -f "$CONFIG/server-settings.json" ]; then
cp /opt/factorio/data/server-settings.example.json "$CONFIG/server-settings.json"
2016-10-27 01:15:09 +02:00
fi
if [ ! -f "$CONFIG/map-gen-settings.json" ]; then
cp /opt/factorio/data/map-gen-settings.example.json "$CONFIG/map-gen-settings.json"
2016-10-27 01:15:09 +02:00
fi
if ! find -L "$SAVES" -iname \*.zip -mindepth 1 -print | grep -q .; then
2016-10-26 06:57:49 +02:00
/opt/factorio/bin/x64/factorio \
--create "$SAVES/_autosave1.zip" \
--map-gen-settings "$CONFIG/map-gen-settings.json"
fi
2016-10-26 06:57:49 +02:00
exec /opt/factorio/bin/x64/factorio \
2016-10-26 19:46:34 +02:00
--port 34197 \
2016-10-26 06:57:49 +02:00
--start-server-load-latest \
2016-11-01 21:31:24 +01:00
--server-settings $CONFIG/server-settings.json \
2016-10-31 20:59:57 +01:00
--rcon-port 27015 \
--rcon-password "$(cat "$CONFIG/rconpw")"