Start-up script?

This commit is contained in:
Hyatt 2019-10-30 21:15:34 -05:00
parent d456e4c123
commit 848119b018
Signed by: nhyatt
GPG Key ID: C50D0BBB5BC40BEA

View File

@ -20,10 +20,17 @@ FROM alpine:3.10
MAINTAINER The_Spider <spider@smoothnet.org>
ENV PORT=34197 \\
RCON_PORT=27015 \\
SAVES=/factorio/saves \\
CONFIG=/factorio/config \\
MODS=/factorio/mods \\
SCENARIOS=/factorio/scenarios \\
SCRIPT_OUTPUT=/factorio/script-output
RUN \\
apk add --update --no-cache \\
pwgen \\
su-exec \\
binutils \\
gettext \\
libintl \\
@ -65,7 +72,35 @@ RUN \\
${FactorioFileName} && \\
addgroup -g 1000 -S factorio && \\
adduser -u 1000 -G factorio -s /bin/sh -SDH factorio && \\
chown -R factorio:factorio /opt/factorio /factorio
chown -R factorio:factorio /opt/factorio /factorio && \\
printf '%s\\n' \\
"#!/bin/sh -x" \\
"set -e" \\
"id" \\
"mkdir -p /factorio \${SAVES} \${CONFIG} \${MODS} \${SCENARIOS} \${SCRIPT_OUTPUT}" \\
"[ ! -f \"\${CONFIG}/rconpw\" ] && printf '%s' \"\$(pwgen 15 1)\" > \${CONFIG}/rconpw" \\
"[ ! -f \"\${CONFIG}/server-settings.json\" ] && cp /opt/factorio/data/server-settings.example.json \${CONFIG}/server-settings.json" \\
"[ ! -f \"\${CONFIG}/map-gen-settings.json\" ] && cp /opt/factorio/data/map-gen-settings.example.json \${CONFIG}/map-gen-settings.json" \\
"[ ! -f \"\${CONFIG}/map-settings.json\" ] && cp /opt/factorio/data/map-settings.example.json \${CONFIG}/map-settings.json" \\
"find -L \${SAVES} -iname \\*.tmp.zip -mindepth 1 -print | grep -q .; then rm -f \${SAVES}/*.tmp.zip" \\
"if ! find -L \${SAVES} -iname \\*.tmp.zip -mindepth 1 -print | grep -q .; then" \\
" /opt/factorio/bin/x64/factorio \\" \\
" --create \${SAVES}/_autosave1.zip \\" \\
" --map-gen-settings \${CONFIG}/map-gen-settings.json \\" \\
" --map-settings \${CONFIG}/map-settings.json" \\
"fi" \\
"/opt/factorio/bin/x64/factorio \\" \\
" --port \${PORT} \\" \\
" --start-server-load-latest \\" \\
" --server-settings \${CONFIG}/server-settings.json \\" \\
" --server-banlist \${CONFIG}/server-banlist.json \\" \\
" --rcon-port \${RCON_PORT} \\" \\
" --server-whitelist \${CONFIG}/server-whitelist.json \\" \\
" --use-server-whitelist \\" \\
" --server-adminlist \${CONFIG}/server-adminlist.json \\" \\
" --rcon-password \"\$(cat \${CONFIG}/rconpw)\" \\" \\
" --server-id /factorio/config/server-id.json \\" \\
" $@"
"""
podTemplate(