script needs to use variables

This commit is contained in:
Hyatt 2022-01-28 10:08:16 -06:00
parent 4883e7db39
commit b4665a0b48
Signed by: nhyatt
GPG Key ID: C50D0BBB5BC40BEA

View File

@ -8,37 +8,37 @@ def factorioScript = """#!/bin/sh
set -e set -e
id id
[ ! -d "/data/saves" ] && mkdir -p /data/saves [ ! -d "\${SAVES}" ] && mkdir -p "\${SAVES}"
[ ! -d "/data/config" ] && mkdir -p /data/config [ ! -d "\${CONFIG}" ] && mkdir -p "\${CONFIG}"
[ ! -d "/data/mods" ] && mkdir -p /data/mods [ ! -d "\${MODS}" ] && mkdir -p "\${MODS}"
[ ! -d "/data/scenarios" ] && mkdir -p /data/scenarios [ ! -d "\${SCENARIOS}" ] && mkdir -p "\${SCENARIOS}"
[ ! -d "/data/script-output" ] && mkdir -p /data/script-output [ ! -d "\${SCRIPT_OUTPUT}" ] && mkdir -p "\${SCRIPT_OUTPUT}"
[ ! -f "/data/config/rconpw" ] && printf '%s' "\$(pwgen 15 1)" > /data/config/rconpw [ ! -f "\${CONFIG}/rconpw" ] && printf '%s' "\$(pwgen 15 1)" > "\${CONFIG}/rconpw"
[ ! -f "/data/config/server-settings.json" ] && cp /opt/factorio/data/server-settings.example.json /data/config/server-settings.json [ ! -f "\${CONFIG}/server-settings.json" ] && cp /opt/factorio/data/server-settings.example.json "\${CONFIG}/server-settings.json"
[ ! -f "/data/config/map-gen-settings.json" ] && cp /opt/factorio/data/map-gen-settings.example.json /data/config/map-gen-settings.json [ ! -f "\${CONFIG}/map-gen-settings.json" ] && cp /opt/factorio/data/map-gen-settings.example.json "\${CONFIG}/map-gen-settings.json"
[ ! -f "/data/config/map-settings.json" ] && cp /opt/factorio/data/map-settings.example.json /data/config/map-settings.json [ ! -f "\${CONFIG}/map-settings.json" ] && cp /opt/factorio/data/map-settings.example.json "\${CONFIG}/map-settings.json"
if find -L /data/saves -iname \\*.tmp.zip -mindepth 1 -print | grep -q .; then if find -L "\${SAVES}" -iname \\*.tmp.zip -mindepth 1 -print | grep -q .; then
rm -f /data/saves/*.tmp.zip rm -f \${SAVES}/*.tmp.zip
fi fi
if ! find -L /data/saves -iname \\*.zip -mindepth 1 -print | grep -q .; then if ! find -L "\${SAVES}" -iname \\*.zip -mindepth 1 -print | grep -q .; then
/opt/factorio/bin/x64/factorio \\ /opt/factorio/bin/x64/factorio \\
--create /data/saves/_autosave1.zip \\ --create "\${SAVES}/_autosave1.zip" \\
--map-gen-settings /data/config/map-gen-settings.json \\ --map-gen-settings "\${CONFIG}/map-gen-settings.json" \\
--map-settings /data/config/map-settings.json --map-settings "\${CONFIG}/map-settings.json"
fi fi
/opt/factorio/bin/x64/factorio \\ /opt/factorio/bin/x64/factorio \\
--port \${PORT} \\ --port \${PORT} \\
--start-server-load-latest \\ --start-server-load-latest \\
--server-settings /data/config/server-settings.json \\ --server-settings "\${CONFIG}/server-settings.json" \\
--server-banlist /data/config/server-banlist.json \\ --server-banlist "\${CONFIG}/server-banlist.json" \\
--rcon-port \${RCON_PORT} \\ --rcon-port \${RCON_PORT} \\
--server-whitelist /data/config/server-whitelist.json \\ --server-whitelist "\${CONFIG}/server-whitelist.json" \\
--use-server-whitelist \\ --use-server-whitelist \\
--server-adminlist /data/config/server-adminlist.json \\ --server-adminlist "\${CONFIG}/server-adminlist.json" \\
--rcon-password "\$(cat /data/config/rconpw)" \\ --rcon-password "\$(cat "\${CONFIG}/rconpw")" \\
--server-id /factorio/config/server-id.json \\ --server-id /factorio/config/server-id.json \\
\${@} \${@}
""" """