Update Factorio/README.md
This commit is contained in:
parent
22a81912b8
commit
9c6dfdf8f8
1 changed files with 168 additions and 1 deletions
|
@ -1 +1,168 @@
|
|||
Factorio Scripts
|
||||
# Factorio Multi-Server Manager
|
||||
|
||||
This project provides a robust, automated solution for managing multiple [Factorio](https://factorio.com/) headless servers on Linux. It includes scripts for updating Factorio, orchestrating server processes, monitoring server health, and sending notifications—all driven by a single configuration file.
|
||||
|
||||
---
|
||||
|
||||
## Features
|
||||
|
||||
- **Automatic Update Checks:** Detects and installs new Factorio releases.
|
||||
- **Multi-Server Management:** Start, stop, and restart multiple servers as defined in a single INI config.
|
||||
- **Screen Integration:** Each server runs in its own `screen` session for easy process management and detachment.
|
||||
- **Health Monitoring:** Detects and restarts crashed or missing servers.
|
||||
- **Discord Notifications:** Sends update notifications to a Discord webhook.
|
||||
- **Colorful, Informative Output:** Terminal output is styled for clarity and quick status checks.
|
||||
- **Graceful Shutdowns:** Ensures servers save and shut down cleanly before updates or restarts.
|
||||
- **Mod Support:** Handles mod directory and mod settings propagation.
|
||||
|
||||
---
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
/home/factorio/
|
||||
├── factcheck.sh # Main health check and update script
|
||||
├── new_screen_start.sh # Server start/stop/update orchestrator
|
||||
├── servers-config.ini # INI file listing all managed servers
|
||||
├── factorio/ # Factorio installation directory
|
||||
├── mods/
|
||||
│ └── default/ # Default mod directory for servers
|
||||
└── servers/
|
||||
├── server1/
|
||||
├── server2/
|
||||
└── ... # One directory per server, each with its own config and saves
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Setup & Reproduction
|
||||
|
||||
### 1. Dependencies
|
||||
|
||||
- Linux (tested on Ubuntu/Debian)
|
||||
- [screen](https://www.gnu.org/software/screen/)
|
||||
- [jq](https://stedolan.github.io/jq/)
|
||||
- [curl](https://curl.se/)
|
||||
- [wget](https://www.gnu.org/software/wget/)
|
||||
- [Factorio headless server](https://factorio.com/download-headless)
|
||||
|
||||
Install dependencies (example for Ubuntu):
|
||||
```sh
|
||||
sudo apt update
|
||||
sudo apt install screen jq curl wget
|
||||
```
|
||||
|
||||
### 2. Directory Preparation
|
||||
|
||||
- Place all scripts in `/home/factorio/`
|
||||
- Place the Factorio headless server in `/home/factorio/factorio/`
|
||||
- Each server should have its own directory under `/home/factorio/servers/`
|
||||
- Mods should be in `/home/factorio/mods/default/`
|
||||
- Ensure all scripts are executable:
|
||||
```sh
|
||||
chmod +x /home/factorio/factcheck.sh /home/factorio/new_screen_start.sh
|
||||
```
|
||||
|
||||
### 3. Configuration
|
||||
|
||||
Edit `servers-config.ini` to define your servers. Example:
|
||||
```ini
|
||||
[test]
|
||||
port=34198
|
||||
settings=/home/factorio/servers/test/server-settings.json
|
||||
config=/home/factorio/servers/test/config.ini
|
||||
mod_directory=/home/factorio/mods/default
|
||||
use_whitelist=false
|
||||
|
||||
[private]
|
||||
port=55557
|
||||
settings=/home/factorio/servers/private/server-settings.json
|
||||
config=/home/factorio/servers/private/config.ini
|
||||
mod_directory=/home/factorio/mods/default
|
||||
use_whitelist=true
|
||||
```
|
||||
- Comment out any server blocks you do not want managed by prefixing with `;`.
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
### Health Check, Update, and Auto-Restart
|
||||
|
||||
Run the main script to check for updates, ensure all servers are running, and restart any that are down:
|
||||
```sh
|
||||
./factcheck.sh
|
||||
```
|
||||
|
||||
### Manual Server Management
|
||||
|
||||
- **Start/Restart All Servers:**
|
||||
```sh
|
||||
./new_screen_start.sh
|
||||
```
|
||||
(Stops and starts each server sequentially.)
|
||||
|
||||
- **Stop All Servers:**
|
||||
```sh
|
||||
./new_screen_start.sh --stop
|
||||
```
|
||||
|
||||
- **Update Factorio and Mods:**
|
||||
```sh
|
||||
./new_screen_start.sh --update
|
||||
```
|
||||
(Stops all servers, updates Factorio if needed, then restarts all servers.)
|
||||
|
||||
- **Help:**
|
||||
```sh
|
||||
./new_screen_start.sh --help
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tips & Best Practices
|
||||
|
||||
- **Automate Health Checks:**
|
||||
Add `factcheck.sh` to a cron job for regular health checks and updates.
|
||||
Example (runs every 15 minutes):
|
||||
```
|
||||
*/15 * * * * /home/factorio/factcheck.sh >> /home/factorio/factcheck.log 2>&1
|
||||
```
|
||||
|
||||
- **Discord Webhook:**
|
||||
The update script sends notifications to a Discord webhook. Change the webhook URL in `factcheck.sh` to your own server if desired.
|
||||
|
||||
- **Logs:**
|
||||
Server logs are monitored for readiness and clean shutdowns. Check `/home/factorio/servers/<server>/factorio-current.log` for details.
|
||||
|
||||
- **Screen Sessions:**
|
||||
Each server runs in a named `screen` session. Use `screen -ls` to list sessions and `screen -r <session>` to attach.
|
||||
|
||||
- **Mod Management:**
|
||||
Place shared mods in `/home/factorio/mods/default/`. The scripts will propagate mod settings as needed.
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **Server Not Starting:**
|
||||
Check that the Factorio binary is present and executable at `/home/factorio/factorio/bin/x64/factorio`.
|
||||
- **Permissions:**
|
||||
Ensure the `factorio` user has ownership and execute permissions for all relevant files and directories.
|
||||
- **Config Errors:**
|
||||
Double-check paths in `servers-config.ini` for typos or missing files.
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
MIT License (or specify your own)
|
||||
|
||||
---
|
||||
|
||||
## Credits
|
||||
|
||||
Created by ClayGarth.com and contributors.
|
||||
Inspired by the Factorio community and designed for reliability and ease of use.
|
||||
|
||||
---
|
||||
|
|
Loading…
Add table
Reference in a new issue