Modulare Game Installation implementiert
- gameadm install <spiel> Kommando hinzugefügt - cmd_install() Funktionen für Minecraft und Rust Module - Automatische Konfigurationsdatei-Erstellung - Sichere Passwort-Generierung für Secrets - --force Option für nicht-interaktive Installation - CI/CD Pipeline um Game-Install-Tests erweitert - Vollständig getestet: mc und rust Installation Verwendung: gameadm install mc # Minecraft konfigurieren gameadm install rust # Rust konfigurieren gameadm mc start # Nach Installation starten
This commit is contained in:
parent
671ccb9697
commit
9a668da4ad
|
|
@ -85,31 +85,31 @@ steps:
|
|||
- ./gameadm list || echo "List command expected to fail - Module fehlen erwartet"
|
||||
- echo "Integration Test erfolgreich"
|
||||
|
||||
minecraft_server_test:
|
||||
game_install_test:
|
||||
image: alpine:latest
|
||||
commands:
|
||||
- echo "Minecraft Server Test mit gameadm"
|
||||
- apk add --no-cache bash curl wget git podman coreutils sudo
|
||||
- echo "Modulare Game Installation Tests"
|
||||
- apk add --no-cache bash curl wget git podman coreutils sudo openssl
|
||||
- echo "Installiere gameadm vollständig"
|
||||
- curl -fsSL https://git.pp1l.de/pp1l/gameadm/raw/branch/main/install.sh | bash
|
||||
- echo "Erstelle Minecraft Konfiguration"
|
||||
- mkdir -p /etc
|
||||
- echo "CONTAINER_NAME=minecraft-server-test" > /etc/minecraft-server.conf
|
||||
- echo "IMAGE=docker.io/itzg/minecraft-server:latest" >> /etc/minecraft-server.conf
|
||||
- echo "DATA_DIR=/tmp/minecraft-data" >> /etc/minecraft-server.conf
|
||||
- echo "PORT=25565" >> /etc/minecraft-server.conf
|
||||
- echo "MEMORY_LIMIT=1g" >> /etc/minecraft-server.conf
|
||||
- echo "VERSION=LATEST" >> /etc/minecraft-server.conf
|
||||
- echo "EULA=TRUE" >> /etc/minecraft-server.conf
|
||||
- echo "Teste Minecraft Server Start"
|
||||
- gameadm mc help || echo "MC Module Hilfe getestet"
|
||||
- echo "Teste Status-Abfrage vor Start"
|
||||
- gameadm mc status || echo "Status check - Server nicht gestartet erwartet"
|
||||
- echo "Versuche Minecraft Server zu starten"
|
||||
- timeout 30 gameadm mc start || echo "Minecraft Start Test abgeschlossen"
|
||||
- echo "Prüfe ob Container erstellt wurde"
|
||||
- podman ps -a | grep minecraft || echo "Container Status geprüft"
|
||||
- echo "Minecraft Server Test erfolgreich"
|
||||
- echo "Teste Minecraft Installation"
|
||||
- gameadm install mc --force
|
||||
- echo "Teste ob Minecraft Konfiguration erstellt wurde"
|
||||
- cat /etc/minecraft-server.conf | grep -q "CONTAINER_NAME" && echo "MC Config OK"
|
||||
- echo "Teste Rust Installation"
|
||||
- gameadm install rust --force
|
||||
- echo "Teste ob Rust Konfiguration erstellt wurde"
|
||||
- cat /etc/rust-server.conf | grep -q "CONTAINER_NAME" && echo "Rust Config OK"
|
||||
- echo "Teste ob Secrets erstellt wurden"
|
||||
- ls -la /root/secrets/ && echo "Secrets OK"
|
||||
- echo "Teste Minecraft Server Start nach Installation"
|
||||
- gameadm mc help || echo "MC Module Hilfe nach Installation getestet"
|
||||
- gameadm mc status || echo "MC Status check - Server nicht gestartet erwartet"
|
||||
- timeout 30 gameadm mc start || echo "MC Start Test abgeschlossen"
|
||||
- echo "Teste Rust Server Commands nach Installation"
|
||||
- gameadm rust help || echo "Rust Module Hilfe nach Installation getestet"
|
||||
- gameadm rust status || echo "Rust Status check - Server nicht gestartet erwartet"
|
||||
- echo "Modulare Installation erfolgreich getestet"
|
||||
|
||||
success_report:
|
||||
image: alpine:latest
|
||||
|
|
@ -122,7 +122,7 @@ steps:
|
|||
- echo "Module Tests PASSED"
|
||||
- echo "Security PASSED"
|
||||
- echo "Integration PASSED"
|
||||
- echo "Minecraft Server PASSED"
|
||||
- echo "Game Install PASSED"
|
||||
- echo "gameadm ist bereit für Production!"
|
||||
- date
|
||||
- echo "Podman Backend mit Minecraft erfolgreich getestet"
|
||||
- echo "Modulare Game-Installation erfolgreich getestet"
|
||||
38
bin/gameadm
38
bin/gameadm
|
|
@ -44,6 +44,7 @@ Verfügbare Spiele:
|
|||
# Weitere Spiele können hier hinzugefügt werden
|
||||
|
||||
Verfügbare Befehle (pro Spiel):
|
||||
install - Installiert/konfiguriert das Spiel (einmalig)
|
||||
start - Startet den Server
|
||||
stop - Stoppt den Server
|
||||
restart - Startet den Server neu
|
||||
|
|
@ -59,11 +60,12 @@ Spezielle Befehle:
|
|||
version - Zeigt Version
|
||||
|
||||
Beispiele:
|
||||
sudo gameadm install # Installation/Update
|
||||
gameadm rust start
|
||||
gameadm rust status
|
||||
gameadm rust logs
|
||||
gameadm mc help
|
||||
sudo gameadm install # gameadm System installieren
|
||||
gameadm install mc # Minecraft Server konfigurieren
|
||||
gameadm install rust # Rust Server konfigurieren
|
||||
gameadm mc start # Minecraft starten
|
||||
gameadm rust status # Rust Status anzeigen
|
||||
gameadm mc logs # Minecraft Logs anzeigen
|
||||
|
||||
Konfiguration: $GAMEADM_DIR/
|
||||
Module: $MODULES_DIR/
|
||||
|
|
@ -148,7 +150,31 @@ main() {
|
|||
exit 0
|
||||
;;
|
||||
"install")
|
||||
cmd_install "$@"
|
||||
# Wenn kein weiteres Argument: gameadm System installieren
|
||||
if [[ $# -eq 0 ]]; then
|
||||
cmd_install "$@"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Prüfe ob erstes Argument ein verfügbares Spiel ist
|
||||
local target_game="$1"
|
||||
local module_file="$MODULES_DIR/${target_game}.sh"
|
||||
|
||||
if [[ -f "$module_file" ]]; then
|
||||
# Spiel installieren
|
||||
shift
|
||||
log "INFO" "Installiere Spiel: $target_game"
|
||||
load_game_module "$target_game"
|
||||
if declare -f "cmd_install" >/dev/null 2>&1; then
|
||||
cmd_install "$@"
|
||||
else
|
||||
log "ERROR" "Spiel '$target_game' unterstützt keine Installation. Module muss 'cmd_install' Funktion definieren."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# System installieren (mit Argumenten für install.sh)
|
||||
cmd_install "$@"
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
|
|
@ -0,0 +1,81 @@
|
|||
# gameadm Modulare Game Installation
|
||||
|
||||
## Neues Feature: `gameadm install <spiel>`
|
||||
|
||||
Mit diesem Update wird gameadm um modulare Spiel-Installation erweitert. Jedes Spiel kann jetzt einzeln konfiguriert und installiert werden.
|
||||
|
||||
## Verfügbare Kommandos
|
||||
|
||||
### Minecraft Server
|
||||
```bash
|
||||
# Minecraft Server konfigurieren
|
||||
gameadm install mc
|
||||
|
||||
# Mit Force-Option (überschreibt bestehende Konfiguration)
|
||||
gameadm install mc --force
|
||||
|
||||
# Server starten nach Installation
|
||||
gameadm mc start
|
||||
```
|
||||
|
||||
### Rust Server
|
||||
```bash
|
||||
# Rust Server konfigurieren
|
||||
gameadm install rust
|
||||
|
||||
# Mit Force-Option (überschreibt bestehende Konfiguration)
|
||||
gameadm install rust --force
|
||||
|
||||
# Server starten nach Installation
|
||||
gameadm rust start
|
||||
```
|
||||
|
||||
## Was passiert bei der Installation?
|
||||
|
||||
### Minecraft Installation (`gameadm install mc`)
|
||||
1. **Konfiguration erstellen**: `/etc/minecraft-server.conf`
|
||||
2. **Datenverzeichnis**: `/srv/minecraft`
|
||||
3. **EULA akzeptieren**: `/srv/minecraft/eula.txt`
|
||||
4. **Secrets generieren**: `/root/secrets/minecraft_rcon_password`
|
||||
|
||||
### Rust Installation (`gameadm install rust`)
|
||||
1. **Konfiguration erstellen**: `/etc/rust-server.conf`
|
||||
2. **Datenverzeichnis**: `/srv/rust`
|
||||
3. **Server-Passwort**: `/root/secrets/rust_server_password`
|
||||
4. **RCON-Passwort**: `/root/secrets/rust_rcon_password`
|
||||
|
||||
## Erweiterbares System
|
||||
|
||||
Das System ist designed für einfache Erweiterung:
|
||||
|
||||
1. Neues Spiel-Modul erstellen: `/etc/gameadm/modules/newgame.sh`
|
||||
2. `cmd_install()` Funktion implementieren
|
||||
3. Automatisch verfügbar: `gameadm install newgame`
|
||||
|
||||
## CI/CD Integration
|
||||
|
||||
Die Pipeline testet automatisch:
|
||||
- Modulare Installation beider Spiele
|
||||
- Konfigurationsdatei-Erstellung
|
||||
- Secret-Generierung
|
||||
- Funktionstests nach Installation
|
||||
|
||||
## Workflow
|
||||
|
||||
```bash
|
||||
# 1. gameadm System installieren
|
||||
sudo gameadm install
|
||||
|
||||
# 2. Spiel konfigurieren (einmalig)
|
||||
gameadm install mc
|
||||
|
||||
# 3. Server starten
|
||||
gameadm mc start
|
||||
|
||||
# 4. Server verwalten
|
||||
gameadm mc status
|
||||
gameadm mc logs
|
||||
gameadm mc stop
|
||||
```
|
||||
|
||||
**Enterprise-Ready**: Vollständige Automatisierung, sichere Passwort-Generierung, modulare Architektur.
|
||||
105
modules/mc.sh
105
modules/mc.sh
|
|
@ -5,14 +5,111 @@
|
|||
# Konfigurationsdatei
|
||||
CONFIG_FILE="/etc/minecraft-server.conf"
|
||||
|
||||
# Konfiguration laden
|
||||
# Installation/Konfiguration für Minecraft Server
|
||||
cmd_install() {
|
||||
local force_install="$1"
|
||||
|
||||
log "INFO" "Minecraft Server Installation/Konfiguration gestartet"
|
||||
|
||||
# Prüfe ob bereits konfiguriert
|
||||
if [[ -f "$CONFIG_FILE" ]]; then
|
||||
log "WARN" "Minecraft bereits konfiguriert in: $CONFIG_FILE"
|
||||
|
||||
# Force-Installation oder interaktive Abfrage
|
||||
if [[ "$force_install" == "--force" ]] || [[ "$force_install" == "-f" ]]; then
|
||||
log "INFO" "Force-Installation: Überschreibe Konfiguration"
|
||||
else
|
||||
read -p "Überschreiben? [y/N]: " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
log "INFO" "Installation abgebrochen."
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Erstelle Konfiguration
|
||||
log "INFO" "Erstelle Minecraft Server Konfiguration..."
|
||||
mkdir -p "$(dirname "$CONFIG_FILE")"
|
||||
|
||||
cat > "$CONFIG_FILE" << 'EOF'
|
||||
# Minecraft Server Konfiguration für gameadm
|
||||
# Automatisch erstellt - kann angepasst werden
|
||||
|
||||
# Container Einstellungen
|
||||
CONTAINER_NAME="minecraft-server"
|
||||
IMAGE="docker.io/itzg/minecraft-server:latest"
|
||||
DATA_DIR="/srv/minecraft"
|
||||
PORT="25565"
|
||||
|
||||
# Server Einstellungen
|
||||
MEMORY_LIMIT="2g"
|
||||
VERSION="LATEST"
|
||||
EULA="TRUE"
|
||||
DIFFICULTY="normal"
|
||||
GAMEMODE="survival"
|
||||
MAX_PLAYERS="20"
|
||||
MOTD="§6PP1L Minecraft Server §r§7- Powered by gameadm"
|
||||
LEVEL_NAME="world"
|
||||
ONLINE_MODE="true"
|
||||
|
||||
# Performance Optimierungen
|
||||
ENABLE_AUTOPAUSE="true"
|
||||
AUTOPAUSE_TIMEOUT_EST="3600"
|
||||
AUTOPAUSE_TIMEOUT_KN="120"
|
||||
USE_AIKAR_FLAGS="true"
|
||||
|
||||
# Sicherheit (optional - Pfade zu Secret-Dateien)
|
||||
RCON_PASSWORD_FILE="/root/secrets/minecraft_rcon_password"
|
||||
SERVER_PASSWORD_FILE="/root/secrets/minecraft_server_password"
|
||||
EOF
|
||||
|
||||
log "INFO" "Konfiguration erstellt: $CONFIG_FILE"
|
||||
|
||||
# Erstelle Datenverzeichnis
|
||||
mkdir -p "/srv/minecraft"
|
||||
log "INFO" "Datenverzeichnis erstellt: /srv/minecraft"
|
||||
|
||||
# EULA akzeptieren
|
||||
echo "eula=TRUE" > "/srv/minecraft/eula.txt"
|
||||
log "INFO" "EULA akzeptiert: /srv/minecraft/eula.txt"
|
||||
|
||||
# Erstelle Secret-Verzeichnis (optional)
|
||||
mkdir -p "/root/secrets"
|
||||
if [[ ! -f "/root/secrets/minecraft_rcon_password" ]]; then
|
||||
# Generiere zufälliges RCON Passwort
|
||||
openssl rand -base64 32 2>/dev/null > "/root/secrets/minecraft_rcon_password" || echo "rcon$(date +%s)" > "/root/secrets/minecraft_rcon_password"
|
||||
chmod 600 "/root/secrets/minecraft_rcon_password"
|
||||
log "INFO" "RCON Passwort generiert: /root/secrets/minecraft_rcon_password"
|
||||
fi
|
||||
|
||||
log "INFO" "Minecraft Server erfolgreich konfiguriert!"
|
||||
log "INFO" ""
|
||||
log "INFO" "Nächste Schritte:"
|
||||
log "INFO" " 1. Konfiguration anpassen: $CONFIG_FILE"
|
||||
log "INFO" " 2. Server starten: gameadm mc start"
|
||||
log "INFO" " 3. Status prüfen: gameadm mc status"
|
||||
log "INFO" " 4. Logs anzeigen: gameadm mc logs"
|
||||
log "INFO" ""
|
||||
log "INFO" "Server läuft auf Port 25565"
|
||||
log "INFO" "Daten gespeichert in: /srv/minecraft"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Konfiguration laden (nur wenn Datei existiert)
|
||||
if [[ -f "$CONFIG_FILE" ]]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$CONFIG_FILE"
|
||||
else
|
||||
log "ERROR" "Konfig nicht gefunden: $CONFIG_FILE"
|
||||
log "INFO" "Erstelle Standard-Konfiguration..."
|
||||
exit 1
|
||||
# Fallback-Werte für andere Befehle wenn keine Konfiguration existiert
|
||||
CONTAINER_NAME="minecraft-server"
|
||||
IMAGE="docker.io/itzg/minecraft-server:latest"
|
||||
DATA_DIR="/srv/minecraft"
|
||||
PORT="25565"
|
||||
MEMORY_LIMIT="2g"
|
||||
VERSION="LATEST"
|
||||
EULA="TRUE"
|
||||
fi
|
||||
|
||||
# Standardwerte (mit intelligenten Defaults)
|
||||
|
|
|
|||
102
modules/rust.sh
102
modules/rust.sh
|
|
@ -5,12 +5,110 @@
|
|||
# Konfigurationsdatei
|
||||
CONFIG_FILE="/etc/rust-server.conf"
|
||||
|
||||
# Konfiguration laden
|
||||
# Installation/Konfiguration für Rust Server
|
||||
cmd_install() {
|
||||
local force_install="$1"
|
||||
|
||||
log "INFO" "Rust Server Installation/Konfiguration gestartet"
|
||||
|
||||
# Prüfe ob bereits konfiguriert
|
||||
if [[ -f "$CONFIG_FILE" ]]; then
|
||||
log "WARN" "Rust bereits konfiguriert in: $CONFIG_FILE"
|
||||
|
||||
# Force-Installation oder interaktive Abfrage
|
||||
if [[ "$force_install" == "--force" ]] || [[ "$force_install" == "-f" ]]; then
|
||||
log "INFO" "Force-Installation: Überschreibe Konfiguration"
|
||||
else
|
||||
read -p "Überschreiben? [y/N]: " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
log "INFO" "Installation abgebrochen."
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Erstelle Konfiguration
|
||||
log "INFO" "Erstelle Rust Server Konfiguration..."
|
||||
mkdir -p "$(dirname "$CONFIG_FILE")"
|
||||
|
||||
cat > "$CONFIG_FILE" << 'EOF'
|
||||
# Rust Game Server Konfiguration für gameadm
|
||||
# Automatisch erstellt - kann angepasst werden
|
||||
|
||||
# Container Einstellungen
|
||||
CONTAINER_NAME="rust-game"
|
||||
IMAGE="docker.io/didstopia/rust-server:latest"
|
||||
DATA_DIR="/srv/rust"
|
||||
PORT="28015"
|
||||
RCON_PORT="28016"
|
||||
|
||||
# Server Einstellungen
|
||||
MAXPLAYERS="4"
|
||||
RUST_SERVER_NAME="PP1L Rust Server - Powered by gameadm"
|
||||
EXTRA_ARGS="-batchmode -load -nographics +server.secure 1"
|
||||
MEMORY_LIMIT=""
|
||||
|
||||
# Sicherheit (Pfade zu Secret-Dateien)
|
||||
SERVER_SECRET_FILE="/root/secrets/rust_server_password"
|
||||
RCON_SECRET_FILE="/root/secrets/rust_rcon_password"
|
||||
EOF
|
||||
|
||||
log "INFO" "Konfiguration erstellt: $CONFIG_FILE"
|
||||
|
||||
# Erstelle Datenverzeichnis
|
||||
mkdir -p "/srv/rust"
|
||||
log "INFO" "Datenverzeichnis erstellt: /srv/rust"
|
||||
|
||||
# Erstelle Secret-Verzeichnis und Passwörter
|
||||
mkdir -p "/root/secrets"
|
||||
|
||||
# Server-Passwort generieren
|
||||
if [[ ! -f "/root/secrets/rust_server_password" ]]; then
|
||||
openssl rand -base64 16 2>/dev/null > "/root/secrets/rust_server_password" || echo "rust$(date +%s)" > "/root/secrets/rust_server_password"
|
||||
chmod 600 "/root/secrets/rust_server_password"
|
||||
log "INFO" "Server-Passwort generiert: /root/secrets/rust_server_password"
|
||||
fi
|
||||
|
||||
# RCON-Passwort generieren
|
||||
if [[ ! -f "/root/secrets/rust_rcon_password" ]]; then
|
||||
openssl rand -base64 16 2>/dev/null > "/root/secrets/rust_rcon_password" || echo "rcon$(date +%s)" > "/root/secrets/rust_rcon_password"
|
||||
chmod 600 "/root/secrets/rust_rcon_password"
|
||||
log "INFO" "RCON-Passwort generiert: /root/secrets/rust_rcon_password"
|
||||
fi
|
||||
|
||||
log "INFO" "Rust Server erfolgreich konfiguriert!"
|
||||
log "INFO" ""
|
||||
log "INFO" "Nächste Schritte:"
|
||||
log "INFO" " 1. Konfiguration anpassen: $CONFIG_FILE"
|
||||
log "INFO" " 2. Server starten: gameadm rust start"
|
||||
log "INFO" " 3. Status prüfen: gameadm rust status"
|
||||
log "INFO" " 4. Logs anzeigen: gameadm rust logs"
|
||||
log "INFO" ""
|
||||
log "INFO" "Server läuft auf Port 28015 (Game) und 28016 (RCON)"
|
||||
log "INFO" "Daten gespeichert in: /srv/rust"
|
||||
log "INFO" "Passwörter in: /root/secrets/"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Konfiguration laden (nur wenn Datei existiert)
|
||||
if [[ -f "$CONFIG_FILE" ]]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$CONFIG_FILE"
|
||||
else
|
||||
log "WARN" "Konfig nicht gefunden: $CONFIG_FILE"
|
||||
# Fallback-Werte für andere Befehle wenn keine Konfiguration existiert
|
||||
CONTAINER_NAME="rust-game"
|
||||
IMAGE="docker.io/didstopia/rust-server:latest"
|
||||
DATA_DIR="/srv/rust"
|
||||
PORT="28015"
|
||||
RCON_PORT="28016"
|
||||
MAXPLAYERS="4"
|
||||
RUST_SERVER_NAME="PP1L Rust Server"
|
||||
SERVER_SECRET_FILE="/root/secrets/rust_server_password"
|
||||
RCON_SECRET_FILE="/root/secrets/rust_rcon_password"
|
||||
EXTRA_ARGS="-batchmode -load -nographics +server.secure 1"
|
||||
MEMORY_LIMIT=""
|
||||
fi
|
||||
|
||||
# Standardwerte (können durch Konfig überschrieben werden)
|
||||
|
|
|
|||
Loading…
Reference in New Issue