diff options
Diffstat (limited to 'roles/factorio/files')
-rw-r--r-- | roles/factorio/files/factorio.service | 17 | ||||
-rw-r--r-- | roles/factorio/files/run.sh | 14 |
2 files changed, 31 insertions, 0 deletions
diff --git a/roles/factorio/files/factorio.service b/roles/factorio/files/factorio.service new file mode 100644 index 0000000..f7f53bb --- /dev/null +++ b/roles/factorio/files/factorio.service @@ -0,0 +1,17 @@ +# vi: ft=systemd +[Unit] +Description=Factorio dedicated server +After=network-online.target +Wants=network-online.target + +[Service] +Type=simple +User=factorio +Group=factorio +Restart=on-failure +RestartSec=30s +WorkingDirectory=/opt/factorio +ExecStart=/opt/factorio/run.sh + +[Install] +WantedBy=multi-user.target diff --git a/roles/factorio/files/run.sh b/roles/factorio/files/run.sh new file mode 100644 index 0000000..d5eeacc --- /dev/null +++ b/roles/factorio/files/run.sh @@ -0,0 +1,14 @@ +#!/bin/bash +trap '' TERM + +source cfg.sh || exit 1 + +mkdir -p ./saves + +if [ ! -f "./saves/$SAVEFILE.zip" ]; then + factorio/bin/x64/factorio --create "./saves/$SAVEFILE.zip" \ + --map-gen-settings ./mapgen-config.json \ + --map-settings ./map-config.json || exit 1 +fi + +factorio/bin/x64/factorio --start-server "./saves/$SAVEFILE.zip" --server-settings server-config.json |