45 lines
850 B
Bash
Executable File
45 lines
850 B
Bash
Executable File
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
SAVE_FILE="/factorio/saves/world.zip"
|
|
SETTINGS_FILE="/factorio/config/server-settings.json"
|
|
|
|
mkdir -p \
|
|
/factorio/saves \
|
|
/factorio/config
|
|
|
|
if [ ! -f "$SETTINGS_FILE" ]; then
|
|
cat > "$SETTINGS_FILE" <<'EOF'
|
|
{
|
|
"name": "Factorio Server",
|
|
"description": "Automatically generated Factorio world",
|
|
"max_players": 10,
|
|
"visibility": {
|
|
"public": false,
|
|
"lan": true
|
|
},
|
|
"game_password": "",
|
|
"allow_commands": "admins-only",
|
|
"autosave_interval": 10,
|
|
"autosave_slots": 3,
|
|
"auto_pause": true
|
|
}
|
|
EOF
|
|
fi
|
|
|
|
if [ ! -f "$SAVE_FILE" ]; then
|
|
echo "Save file not found. Creating a new Factorio world..."
|
|
|
|
/opt/factorio/bin/x64/factorio \
|
|
--create "$SAVE_FILE"
|
|
|
|
echo "New world created: $SAVE_FILE"
|
|
else
|
|
echo "Using existing world: $SAVE_FILE"
|
|
fi
|
|
|
|
exec /opt/factorio/bin/x64/factorio "$@"
|