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