mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2024-11-07 03:07:24 +01:00
Merge pull request #115 from bplein/master
Add Scenarios Folder, Alternate Entrypoints Folder
This commit is contained in:
commit
5ddb9ab472
@ -7,6 +7,8 @@ ARG GROUP=factorio
|
||||
ARG PUID=845
|
||||
ARG PGID=845
|
||||
|
||||
VOLUME /factorio
|
||||
|
||||
ENV PORT=34197 \
|
||||
RCON_PORT=27015 \
|
||||
VERSION=0.16.29 \
|
||||
@ -21,18 +23,22 @@ RUN mkdir -p /opt /factorio && \
|
||||
tar xf /tmp/factorio_headless_x64_$VERSION.tar.xz --directory /opt && \
|
||||
chmod ugo=rwx /opt/factorio && \
|
||||
rm /tmp/factorio_headless_x64_$VERSION.tar.xz && \
|
||||
ln -s /factorio/saves /opt/factorio/saves && \
|
||||
ln -s /factorio/mods /opt/factorio/mods && \
|
||||
ln -s -f /factorio/saves /opt/factorio/saves && \
|
||||
ln -s -f /factorio/mods /opt/factorio/mods && \
|
||||
ln -s -f /factorio/scenarios /opt/factorio/scenarios && \
|
||||
ln -s -f /factorio/entrypoints /opt/factorio/entrypoints && \
|
||||
apk del .build-deps && \
|
||||
addgroup -g $PGID -S $GROUP && \
|
||||
adduser -u $PUID -G $GROUP -s /bin/sh -SDH $USER && \
|
||||
chown -R $USER:$GROUP /opt/factorio /factorio
|
||||
|
||||
VOLUME /factorio
|
||||
|
||||
|
||||
EXPOSE $PORT/udp $RCON_PORT/tcp
|
||||
|
||||
COPY ./docker-entrypoint.sh /
|
||||
COPY ./scenario2map.sh /factorio/entrypoints
|
||||
COPY ./scenario.sh /factorio/entrypoints
|
||||
|
||||
USER $USER
|
||||
|
||||
|
@ -6,10 +6,18 @@ id
|
||||
|
||||
SAVES=/factorio/saves
|
||||
CONFIG=/factorio/config
|
||||
MODS=/factorio/mods
|
||||
SCENARIOS=/factorio/scenarios
|
||||
ENTRYPOINTS=/factorio/entrypoints
|
||||
|
||||
mkdir -p $SAVES
|
||||
mkdir -p /factorio/mods
|
||||
mkdir -p $CONFIG
|
||||
mkdir -p $MODS
|
||||
mkdir -p $SCENARIOS
|
||||
mkdir -p $ENTRYPOINTS
|
||||
|
||||
#symbolic link the default entrypoint to the entrypoints directory so it can be inspected and copied to new entrypoints
|
||||
ln -s -f /docker-entrypoint.sh $ENTRYPOINTS/docker-entrypoint.sh
|
||||
|
||||
#chown -R factorio /factorio
|
||||
|
||||
|
49
0.16/scenario.sh
Executable file
49
0.16/scenario.sh
Executable file
@ -0,0 +1,49 @@
|
||||
#!/bin/sh -x
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "No argument supplied"
|
||||
fi
|
||||
SCENARIO=$1
|
||||
|
||||
set -e
|
||||
|
||||
id
|
||||
|
||||
SAVES=/factorio/saves
|
||||
CONFIG=/factorio/config
|
||||
MODS=/factorio/mods
|
||||
SCENARIOS=/factorio/scenarios
|
||||
|
||||
mkdir -p $SAVES
|
||||
mkdir -p $CONFIG
|
||||
mkdir -p $MODS
|
||||
mkdir -p $SCENARIOS
|
||||
|
||||
#chown -R factorio /factorio
|
||||
|
||||
if [ ! -f $CONFIG/rconpw ]; then
|
||||
echo $(pwgen 15 1) > $CONFIG/rconpw
|
||||
fi
|
||||
|
||||
if [ ! -f $CONFIG/server-settings.json ]; then
|
||||
cp /opt/factorio/data/server-settings.example.json $CONFIG/server-settings.json
|
||||
fi
|
||||
|
||||
if [ ! -f $CONFIG/map-gen-settings.json ]; then
|
||||
cp /opt/factorio/data/map-gen-settings.example.json $CONFIG/map-gen-settings.json
|
||||
fi
|
||||
|
||||
if [ ! -f $CONFIG/map-settings.json ]; then
|
||||
cp /opt/factorio/data/map-settings.example.json $CONFIG/map-settings.json
|
||||
fi
|
||||
|
||||
|
||||
exec /opt/factorio/bin/x64/factorio \
|
||||
--port $PORT \
|
||||
--start-server-load-scenario $SCENARIO \
|
||||
--server-settings $CONFIG/server-settings.json \
|
||||
--server-whitelist $CONFIG/server-whitelist.json \
|
||||
--server-banlist $CONFIG/server-banlist.json \
|
||||
--rcon-port $RCON_PORT \
|
||||
--rcon-password "$(cat $CONFIG/rconpw)" \
|
||||
--server-id /factorio/config/server-id.json
|
37
0.16/scenario2map.sh
Executable file
37
0.16/scenario2map.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh -x
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "No argument supplied"
|
||||
fi
|
||||
SCENARIO=$1
|
||||
|
||||
set -e
|
||||
|
||||
id
|
||||
|
||||
SAVES=/factorio/saves
|
||||
CONFIG=/factorio/config
|
||||
MODS=/factorio/mods
|
||||
SCENARIOS=/factorio/scenarios
|
||||
|
||||
mkdir -p $SAVES
|
||||
mkdir -p $CONFIG
|
||||
mkdir -p $MODS
|
||||
mkdir -p $SCENARIOS
|
||||
|
||||
#chown -R factorio /factorio
|
||||
|
||||
if [ ! -f $CONFIG/server-settings.json ]; then
|
||||
cp /opt/factorio/data/server-settings.example.json $CONFIG/server-settings.json
|
||||
fi
|
||||
|
||||
if [ ! -f $CONFIG/map-gen-settings.json ]; then
|
||||
cp /opt/factorio/data/map-gen-settings.example.json $CONFIG/map-gen-settings.json
|
||||
fi
|
||||
|
||||
if [ ! -f $CONFIG/map-settings.json ]; then
|
||||
cp /opt/factorio/data/map-settings.example.json $CONFIG/map-settings.json
|
||||
fi
|
||||
|
||||
exec /opt/factorio/bin/x64/factorio \
|
||||
--scenario2map $SCENARIO
|
32
README.md
32
README.md
@ -113,6 +113,38 @@ To generate a new map stop the server, delete all of the saves and restart the s
|
||||
Copy mods into the mods folder and restart the server.
|
||||
|
||||
|
||||
## Scenarios
|
||||
|
||||
If you want to launch a scenario from a clean start (not from a saved map) you'll need to start the docker image from an alternate entrypoint. To do this, use the example entrypoint file stored in the /factorio/entrypoints directory in the volume, and launch the image with the following syntax. Note that this is the normal syntax with the addition of the --entrypoint setting AND the additional argument at the end, which is the name of the Scenario in the Scenarios folder.
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
-p 34197:34197/udp \
|
||||
-p 27015:27015/tcp \
|
||||
-v /opt/factorio:/factorio \
|
||||
--name factorio \
|
||||
--restart=always \
|
||||
--entrypoint "/factorio/entrypoints/scenario.sh" \
|
||||
dtandersen/factorio \
|
||||
MyScenarioName
|
||||
```
|
||||
|
||||
## Converting Scenarios to Regular Maps
|
||||
|
||||
If you would like to export your scenario to a saved map, you can use the example entrypoint similar to the Scenario usag above. Factorio will run once, converting the Scenario to a saved Map in your saves directory. A restart of the docker image using the standard options will then load that map, just as if the scenario were just started by the Scenarios example noted above.
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
-p 34197:34197/udp \
|
||||
-p 27015:27015/tcp \
|
||||
-v /opt/factorio:/factorio \
|
||||
--name factorio \
|
||||
--restart=always \
|
||||
--entrypoint "/factorio/entrypoints/scenario2map.sh" \
|
||||
dtandersen/factorio
|
||||
MyScenarioName
|
||||
```
|
||||
|
||||
## RCON
|
||||
|
||||
Set the RCON password in the `rconpw` file. A random password is generated if `rconpw` doesn't exist.
|
||||
|
Loading…
Reference in New Issue
Block a user