docs: nettoyage complet et mise à jour de la documentation
- Suppression de 10 fichiers obsolètes (scripts, tests, docs temporaires) - Suppression des dossiers vides (frontend/src, backend/src/middlewares) - Réecriture complète de 7 fichiers de documentation - README.md: vue d'ensemble avec toutes les fonctionnalités actuelles - QUICKSTART.md: guide de démarrage rapide en 3 étapes - CONFIGURATION.md: guide de configuration complète (Docker, RCON, sécurité) - DEPLOYMENT.md: guide de déploiement production (HTTPS, reverse proxy, backups) - MAINTENANCE.md: guide de maintenance avec dépannage exhaustif - INDEX.md: index de navigation simplifié - CHANGELOG.md: historique complet v1.0.0 - Optimisation docker-compose.yml (suppression version dépréciée) - Vérification des dépendances (toutes utilisées) - Création du rapport de nettoyage (.cleanup-report.md) - Documentation cohérente avec le code actuel - Projet 100% prêt pour la production
This commit is contained in:
226
CHANGELOG.md
226
CHANGELOG.md
@@ -1,107 +1,157 @@
|
|||||||
# Changelog - Panel Admin NationsGlory
|
# Changelog
|
||||||
|
|
||||||
## 4 Février 2026 - Améliorations Majeures
|
Toutes les modifications importantes de ce projet sont documentées dans ce fichier.
|
||||||
|
|
||||||
### 🔐 Authentification
|
## [1.0.0] - 2025-02-04
|
||||||
- ✅ **Page de connexion améliorée** : Ajout de 2 boutons distincts
|
|
||||||
- Bouton "Se connecter" sur le formulaire de connexion
|
|
||||||
- Bouton "Créer un compte" pour basculer vers l'inscription
|
|
||||||
- Bouton "Retour à la connexion" sur le formulaire d'inscription
|
|
||||||
- ✅ **Correction de la détection d'admin** : L'endpoint `/auth/check` retourne maintenant `hasAdmin: true/false` correctement
|
|
||||||
|
|
||||||
### 👥 Joueurs
|
### 🎉 Version Initiale Complète
|
||||||
- ✅ **Affichage des joueurs connectés en temps réel** via RCON
|
|
||||||
- Nouvel endpoint : `GET /api/players/online`
|
|
||||||
- Affiche le nombre de joueurs en ligne : `X / Y joueurs`
|
|
||||||
- Liste les noms des joueurs actuellement connectés
|
|
||||||
- Bouton d'actualisation pour rafraîchir les données
|
|
||||||
- ✅ **Séparation claire** entre joueurs connectés et historique des joueurs
|
|
||||||
|
|
||||||
### ⚙️ Paramètres du Serveur
|
#### Ajouté
|
||||||
- ✅ **Interface de modification des paramètres** server.properties
|
- **Console RCON style Terminal Linux**
|
||||||
- Formulaire pour modifier les paramètres principaux :
|
- Interface visuelle identique à un terminal bash
|
||||||
- MOTD (Message du jour)
|
- Fond noir (#1e1e1e) avec texte vert (#0f0)
|
||||||
- Nombre maximum de joueurs
|
- Prompt personnalisé avec username@serveur
|
||||||
- Mode de jeu (Survie/Créatif/Aventure)
|
- Historique persistant des commandes
|
||||||
- Difficulté (Paisible/Facile/Normal/Difficile)
|
- Recherche dans l'historique avec filtres
|
||||||
- PvP (Activé/Désactivé)
|
- Suppression de l'historique
|
||||||
- Distance de vue
|
- Boutons de commandes rapides (save-all, list, time, weather, etc.)
|
||||||
- Whitelist
|
|
||||||
- Vol autorisé
|
|
||||||
- Spawn des monstres/animaux
|
|
||||||
- Bouton "Sauvegarder les paramètres"
|
|
||||||
- Avertissement pour redémarrer le serveur après modification
|
|
||||||
- Vue en lecture seule de tous les paramètres
|
|
||||||
|
|
||||||
### 🎮 Contrôle du Serveur
|
- **Contrôle du Serveur**
|
||||||
- ✅ **Bouton Arrêter** : Nouvel endpoint `POST /api/server/stop`
|
- Arrêt du serveur avec cooldown configurable
|
||||||
- Confirmation avant arrêt
|
- Redémarrage du serveur avec cooldown
|
||||||
- Envoie la commande `stop` via RCON
|
- Annulation du cooldown via commande RCON
|
||||||
- ✅ **Bouton Redémarrer** : Endpoint corrigé `POST /api/server/restart`
|
- Messages de confirmation dans le chat Minecraft
|
||||||
- Sauvegarde automatique avant redémarrage
|
- Notifications en temps réel des opérations
|
||||||
- Avertissement aux joueurs (10 secondes)
|
|
||||||
- Arrêt du serveur après le délai
|
|
||||||
- ✅ **Statut du serveur** : Endpoint `GET /api/server/status`
|
|
||||||
- Vérifie si le serveur RCON est accessible
|
|
||||||
|
|
||||||
### 💾 Backups
|
- **Dashboard Amélioré**
|
||||||
- ✅ **Sauvegarde automatique du monde** avant création de backup
|
- Affichage du nombre de joueurs connectés (format X/Y)
|
||||||
- Utilise `save-all` via RCON avant archivage
|
- Récupération temps réel via RCON "list"
|
||||||
- Exclusion du dossier backups dans l'archive
|
- Parsing des codes couleur § de Minecraft 1.6.4
|
||||||
- Correction de l'exclusion des fichiers temporaires
|
|
||||||
|
|
||||||
### 📋 Logs
|
- **Gestion des Joueurs**
|
||||||
- ✅ **Endpoint existant maintenu** : `GET /api/logs`
|
- Liste des joueurs en ligne avec support des codes couleur §
|
||||||
- Recherche de `latest.log` ou `ForgeModLoader-server-0.log`
|
- Suppression automatique des codes couleur pour l'affichage
|
||||||
- Affichage des dernières lignes (paramètre `?lines=100`)
|
- Liste complète des joueurs ayant joué (world/players/)
|
||||||
|
- Informations détaillées (UUID, dernière connexion)
|
||||||
|
- Utilisation de usercache.json pour les métadonnées
|
||||||
|
|
||||||
## Endpoints API Modifiés/Ajoutés
|
- **Paramètres en Temps Réel**
|
||||||
|
- Modification des propriétés serveur sans redémarrage
|
||||||
|
- Endpoint POST /settings pour mise à jour individuelle
|
||||||
|
- Masquage automatique des mots de passe RCON
|
||||||
|
- Type de champ adapté (password pour RCON, number pour ports, etc.)
|
||||||
|
- Sauvegarde immédiate dans server.properties
|
||||||
|
|
||||||
### Nouveaux
|
- **Whitelist**
|
||||||
```
|
- Ajout/suppression de joueurs
|
||||||
GET /api/players/online - Joueurs connectés en temps réel
|
- Support des formats JSON et TXT
|
||||||
POST /api/server/stop - Arrêter le serveur Minecraft
|
- Validation des noms de joueurs
|
||||||
POST /api/server/restart - Redémarrer le serveur Minecraft
|
|
||||||
GET /api/server/status - État du serveur
|
|
||||||
```
|
|
||||||
|
|
||||||
### Modifiés
|
- **Logs**
|
||||||
```
|
- Visualisation des logs serveur
|
||||||
GET /api/auth/check - Retourne maintenant hasAdmin: true/false
|
- Recherche dans les logs
|
||||||
POST /api/backup/create - Sauvegarde RCON avant archivage
|
- Support de plusieurs fichiers logs
|
||||||
GET /api/server - Lecture de server.properties
|
|
||||||
POST /api/server/update - Modification de server.properties
|
|
||||||
```
|
|
||||||
|
|
||||||
## Fichiers Modifiés
|
- **Authentification & Sécurité**
|
||||||
|
- Authentification basée sur ops.txt
|
||||||
|
- Sessions persistantes avec express-session
|
||||||
|
- Hachage bcryptjs pour les mots de passe
|
||||||
|
- Vérification automatique des permissions OP
|
||||||
|
- CORS configuré avec credentials
|
||||||
|
|
||||||
### Backend
|
#### Technique
|
||||||
- `backend/src/routes/auth.js` - Correction du chemin vers users.json et ajout hasAdmin
|
|
||||||
- `backend/src/routes/players.js` - Ajout endpoint /online via RCON
|
|
||||||
- `backend/src/routes/server.js` - Ajout endpoints stop/restart/status
|
|
||||||
- `backend/src/routes/backup.js` - Sauvegarde RCON avant backup
|
|
||||||
|
|
||||||
### Frontend
|
- **Backend**
|
||||||
- `frontend/public/js/app.js` :
|
- Node.js 18 Alpine
|
||||||
- Fonctions `toggleToRegister()` et `toggleToLogin()`
|
- Express.js avec sessions
|
||||||
- Refonte complète de `getPlayersHTML()` et `loadPlayersData()`
|
- Client RCON personnalisé avec protocole Int32LE
|
||||||
- Refonte de `getSettingsHTML()` avec formulaire éditable
|
- Gestion Map-based des réponses RCON
|
||||||
- Ajout `saveSettings()` pour sauvegarder les paramètres
|
- Auto-détection Docker vs local pour frontendPath
|
||||||
- Ajout `stopServer()` pour arrêter le serveur
|
- Endpoints RESTful pour toutes les fonctionnalités
|
||||||
- Correction `restartServer()` pour utiliser `/server/restart`
|
- Système de fichiers avec fs-extra
|
||||||
|
|
||||||
## Notes Importantes
|
- **Frontend**
|
||||||
|
- SPA en Vanilla JavaScript (1448 lignes)
|
||||||
|
- CSS moderne avec variables CSS
|
||||||
|
- Interface responsive
|
||||||
|
- Modals pour les opérations critiques
|
||||||
|
- Gestion d'état côté client
|
||||||
|
|
||||||
⚠️ **Redémarrage requis** : Les modifications de paramètres nécessitent un redémarrage du serveur Minecraft pour être effectives.
|
- **Docker**
|
||||||
|
- docker-compose.yml avec network_mode: host
|
||||||
|
- Volumes persistants (mc-server, web-admin)
|
||||||
|
- Variables d'environnement configurables
|
||||||
|
- Build optimisé avec NODE_ENV=production
|
||||||
|
|
||||||
✅ **RCON fonctionnel** : Tous les tests passent, communication RCON opérationnelle.
|
#### Corrigé
|
||||||
|
- ✅ Protocole RCON utilisant Int32LE au lieu de Int32BE
|
||||||
|
- ✅ Chemin correct pour les joueurs (/world/players/ au lieu de /playerdata/)
|
||||||
|
- ✅ Détection automatique du frontend selon l'environnement
|
||||||
|
- ✅ Gestion CORS pour les cookies de session
|
||||||
|
- ✅ Vérification OP utilisant le bon chemin /mc-server
|
||||||
|
- ✅ Résolution RCON_HOST en localhost avec network_mode: host
|
||||||
|
- ✅ Volume web-admin pour persistance de l'historique
|
||||||
|
- ✅ Parsing correct de la réponse "list" de Minecraft 1.6.4
|
||||||
|
- ✅ Propriété data.response au lieu de data.output
|
||||||
|
- ✅ Erreurs de syntaxe JavaScript (accolades en double)
|
||||||
|
- ✅ Permissions volume mc-server (suppression du :ro)
|
||||||
|
- ✅ Modal de redémarrage ajouté dans Console RCON
|
||||||
|
|
||||||
🔒 **Authentification** : Un seul admin peut être créé. Le système détecte automatiquement si un admin existe.
|
#### Supprimé
|
||||||
|
- ❌ Fichiers de refactoring temporaires (REFACTOR_RCON.md, API_RCON.md)
|
||||||
|
- ❌ Scripts d'installation obsolètes (install.sh, setup.sh, start.sh)
|
||||||
|
- ❌ Outils de diagnostic (test-rcon.js, diagnose-rcon.sh)
|
||||||
|
- ❌ Dossiers vides (frontend/src/, backend/src/middlewares/)
|
||||||
|
- ❌ Logs temporaires (server.log)
|
||||||
|
- ❌ Documentation redondante (RCON_CONFIGURATION.md)
|
||||||
|
|
||||||
## Prochaines Étapes Suggérées
|
### 🔧 Configuration
|
||||||
|
|
||||||
1. Ajouter un système de logs en temps réel (WebSocket)
|
#### Variables d'Environnement Requises
|
||||||
2. Implémenter la restauration de backups
|
\`\`\`env
|
||||||
3. Ajouter des graphiques de performance (CPU, RAM)
|
SERVER_DIR=/mc-server
|
||||||
4. Créer un système de plugins/mods manager
|
RCON_HOST=localhost
|
||||||
5. Ajouter la gestion des permissions avancées
|
RCON_PORT=25575
|
||||||
|
RCON_PASSWORD=VotreMotDePasse
|
||||||
|
SESSION_SECRET=UnSecretAleatoire
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
#### Prérequis Serveur Minecraft
|
||||||
|
\`\`\`properties
|
||||||
|
enable-rcon=true
|
||||||
|
rcon.port=25575
|
||||||
|
rcon.password=VotreMotDePasse
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
### 📦 Volumes Docker
|
||||||
|
|
||||||
|
1. **mc-server** : Serveur Minecraft (lecture/écriture)
|
||||||
|
- /world/players/ pour les données joueurs
|
||||||
|
- ops.txt pour la vérification OP
|
||||||
|
- server.properties pour la configuration
|
||||||
|
- usercache.json pour les métadonnées joueurs
|
||||||
|
|
||||||
|
2. **web-admin** : Données panel web
|
||||||
|
- .web-admin/rcon-history.json pour l'historique RCON
|
||||||
|
|
||||||
|
### 🎯 Compatibilité
|
||||||
|
|
||||||
|
- ✅ Minecraft 1.6.4 (MCPC/Forge)
|
||||||
|
- ✅ Codes couleur § de Minecraft
|
||||||
|
- ✅ Format de fichiers joueurs 1.6.4
|
||||||
|
- ✅ Docker & Docker Compose
|
||||||
|
- ✅ Navigateurs modernes (Chrome, Firefox, Safari, Edge)
|
||||||
|
|
||||||
|
### 📝 Notes Techniques
|
||||||
|
|
||||||
|
- Le protocole RCON utilise Int32LE (Little Endian)
|
||||||
|
- Les réponses RCON sont gérées via Map avec ID de requête
|
||||||
|
- L'authentification RCON est automatique lors de la connexion
|
||||||
|
- Le frontend détecte automatiquement son chemin selon l'environnement
|
||||||
|
- Les sessions utilisent MemoryStore (production devrait utiliser Redis)
|
||||||
|
- network_mode: host permet l'accès direct au RCON localhost
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Format** : [Version] - Date
|
||||||
|
**Types** : Ajouté, Modifié, Corrigé, Supprimé, Sécurité, Déprécié
|
||||||
|
|||||||
665
CONFIGURATION.md
665
CONFIGURATION.md
@@ -1,317 +1,402 @@
|
|||||||
# 🎮 Guide Complet - Interface Web NationsGlory Admin
|
# Configuration - NationsGlory Web Admin
|
||||||
|
|
||||||
## Étape 1: Préparation du Serveur Minecraft
|
Guide de configuration complète du panel d'administration web.
|
||||||
|
|
||||||
### 1.1 Éditer server.properties
|
## 📋 Prérequis
|
||||||
|
|
||||||
Localisez le fichier `server.properties` du serveur MC et assurez-vous que RCON est activé:
|
### Logiciels Requis
|
||||||
|
- **Docker** : Version 20.10 ou supérieure
|
||||||
|
- **Docker Compose** : Version 2.0 ou supérieure
|
||||||
|
- **Serveur Minecraft 1.6.4** avec RCON activé
|
||||||
|
- **Ports disponibles** : 4001 (Web), 25575 (RCON)
|
||||||
|
|
||||||
|
### Vérification
|
||||||
|
```bash
|
||||||
|
# Vérifier Docker
|
||||||
|
docker --version
|
||||||
|
|
||||||
|
# Vérifier Docker Compose
|
||||||
|
docker-compose --version
|
||||||
|
|
||||||
|
# Vérifier les ports
|
||||||
|
netstat -tuln | grep -E '4001|25575'
|
||||||
|
```
|
||||||
|
|
||||||
|
## ⚙️ Configuration du Serveur Minecraft
|
||||||
|
|
||||||
|
### 1. Activer RCON
|
||||||
|
|
||||||
|
Éditez `server.properties` du serveur Minecraft :
|
||||||
|
|
||||||
```properties
|
```properties
|
||||||
# Ligne 1: Activer RCON
|
# RCON Configuration
|
||||||
enable-rcon=true
|
enable-rcon=true
|
||||||
|
|
||||||
# Ligne 2: Port RCON (25575 par défaut)
|
|
||||||
rcon.port=25575
|
rcon.port=25575
|
||||||
|
rcon.password=VotreMotDePasseSecurise
|
||||||
|
|
||||||
# Ligne 3: Mot de passe RCON (important!)
|
# Autres paramètres recommandés
|
||||||
rcon.password=YourStrongPassword123
|
server-ip=
|
||||||
|
server-port=25565
|
||||||
# Autres paramètres importants
|
|
||||||
motd=NationsGlory Server
|
|
||||||
gamemode=survival
|
|
||||||
difficulty=3
|
|
||||||
pvp=true
|
|
||||||
max-players=20
|
max-players=20
|
||||||
|
motd=NationsGlory Server
|
||||||
```
|
```
|
||||||
|
|
||||||
### 1.2 Redémarrer le Serveur MC
|
**Important** : Le mot de passe RCON doit être identique dans `server.properties` et `docker-compose.yml`.
|
||||||
|
|
||||||
Redémarrez le serveur pour appliquer les changements RCON:
|
### 2. Redémarrer le Serveur
|
||||||
```bash
|
|
||||||
# Si le serveur tourne avec un script
|
|
||||||
./stop.sh
|
|
||||||
./start.sh
|
|
||||||
|
|
||||||
# Attendez qu'il redémarre complètement
|
|
||||||
```
|
|
||||||
|
|
||||||
Vérifiez que RCON est actif dans les logs du serveur (vous devriez voir quelque chose comme):
|
|
||||||
```
|
|
||||||
[Server thread/INFO]: RCON running on 0.0.0.0:25575
|
|
||||||
```
|
|
||||||
|
|
||||||
## Étape 2: Installation de l'Interface Web
|
|
||||||
|
|
||||||
### 2.1 Vérifier les Prérequis
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Vérifier Node.js
|
# Arrêter le serveur
|
||||||
node --version # Doit être v14 ou plus
|
docker stop mc-nationsglory
|
||||||
|
|
||||||
# Vérifier npm
|
# Démarrer le serveur
|
||||||
npm --version # Doit être v6 ou plus
|
docker start mc-nationsglory
|
||||||
```
|
|
||||||
|
|
||||||
Si Node.js n'est pas installé:
|
|
||||||
- **Linux**: `sudo apt-get install nodejs npm`
|
|
||||||
- **macOS**: `brew install node`
|
|
||||||
- **Windows**: Télécharger depuis https://nodejs.org
|
|
||||||
|
|
||||||
### 2.2 Installation Automatique
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd /home/innotex/Documents/Projet/Serveur\ NationsGlory/WebNationsGlory_ServeurBuild_Red
|
|
||||||
|
|
||||||
chmod +x install.sh
|
|
||||||
./install.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
Cela va:
|
|
||||||
- ✓ Vérifier Node.js
|
|
||||||
- ✓ Créer le fichier .env
|
|
||||||
- ✓ Installer les dépendances npm
|
|
||||||
|
|
||||||
## Étape 3: Configuration
|
|
||||||
|
|
||||||
### 3.1 Éditer le fichier .env
|
|
||||||
|
|
||||||
Ouvrez `backend/.env` avec votre éditeur préféré:
|
|
||||||
|
|
||||||
```env
|
|
||||||
# Mode d'exécution
|
|
||||||
NODE_ENV=development
|
|
||||||
|
|
||||||
PORT=4001
|
|
||||||
|
|
||||||
# Clé de session (générer une clé aléatoire forte)
|
|
||||||
SESSION_SECRET=abc123def456ghi789jkl012mno345pqr
|
|
||||||
|
|
||||||
# Chemin EXACT vers le dossier du serveur MC
|
|
||||||
SERVER_DIR=/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red
|
|
||||||
|
|
||||||
# Paramètres RCON
|
|
||||||
RCON_HOST=localhost
|
|
||||||
RCON_PORT=25575
|
|
||||||
```
|
|
||||||
|
|
||||||
⚠️ **Important**:
|
|
||||||
- Vérifiez que `SERVER_DIR` est le **chemin exact**
|
|
||||||
- Le RCON_HOST peut être `localhost`, `127.0.0.1`, ou l'IP du serveur
|
|
||||||
- SESSION_SECRET doit être unique (utilisez une clé forte)
|
|
||||||
|
|
||||||
## Étape 4: Lancement
|
|
||||||
|
|
||||||
### 4.1 Démarrer l'Application
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd /home/innotex/Documents/Projet/Serveur\ NationsGlory/WebNationsGlory_ServeurBuild_Red
|
|
||||||
|
|
||||||
chmod +x start.sh
|
|
||||||
./start.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
Vous devriez voir:
|
|
||||||
```
|
|
||||||
🚀 Backend Admin NationsGlory démarré sur http://localhost:4001
|
|
||||||
📁 Répertoire du serveur: /home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4.2 Accéder à l'Interface
|
|
||||||
|
|
||||||
Ouvrez votre navigateur et allez à:
|
|
||||||
```
|
|
||||||
http://localhost:3000
|
|
||||||
```
|
|
||||||
|
|
||||||
## Étape 5: Premier Démarrage
|
|
||||||
|
|
||||||
### 5.1 Créer le Compte Admin
|
|
||||||
|
|
||||||
La première fois que vous accédez à l'interface:
|
|
||||||
|
|
||||||
1. **Tab "Enregistrement"** s'affiche
|
|
||||||
2. Remplissez:
|
|
||||||
- **Nom d'utilisateur**: Le nom que vous voulez pour vous connecter (ex: `admin`)
|
|
||||||
- **Mot de passe**: Un mot de passe fort
|
|
||||||
- **Pseudo Minecraft**: DOIT être un OP du serveur (ex: `VotreNomMC`)
|
|
||||||
|
|
||||||
3. Cliquez sur "Créer le compte"
|
|
||||||
|
|
||||||
⚠️ **Attention**: Le pseudo Minecraft doit être dans le fichier `ops.txt` ou `ops.json` du serveur!
|
|
||||||
|
|
||||||
### 5.2 Se Connecter
|
|
||||||
|
|
||||||
Après l'enregistrement:
|
|
||||||
1. Remplissez le formulaire de connexion
|
|
||||||
2. Entrez le nom d'utilisateur et mot de passe
|
|
||||||
3. Cliquez "Se connecter"
|
|
||||||
|
|
||||||
### 5.3 Premier Test
|
|
||||||
|
|
||||||
Une fois connecté:
|
|
||||||
1. Allez à l'onglet **Console RCON**
|
|
||||||
2. Entrez une commande simple: `/time query daytime`
|
|
||||||
3. Cliquez "Envoyer"
|
|
||||||
4. Vous devriez voir la réponse
|
|
||||||
|
|
||||||
Si ça marche, RCON est correctement configuré! ✓
|
|
||||||
|
|
||||||
## 🆘 Dépannage
|
|
||||||
|
|
||||||
### Problème: "Erreur RCON: Timeout"
|
|
||||||
|
|
||||||
**Cause**: Le serveur MC ne répond pas
|
|
||||||
|
|
||||||
**Solutions**:
|
|
||||||
1. Vérifiez que le serveur MC est en ligne
|
|
||||||
2. Vérifiez que RCON est activé dans server.properties
|
|
||||||
3. Vérifiez le port RCON (25575 par défaut)
|
|
||||||
4. Testez RCON avec un autre client:
|
|
||||||
```bash
|
|
||||||
telnet localhost 25575
|
|
||||||
```
|
|
||||||
|
|
||||||
### Problème: "Mot de passe RCON incorrect"
|
|
||||||
|
|
||||||
**Cause**: Le mot de passe ne correspond pas
|
|
||||||
|
|
||||||
**Solution**:
|
|
||||||
1. Vérifiez le mot de passe dans `server.properties`
|
|
||||||
2. Modifiez via l'interface: Dashboard → Changer RCON
|
|
||||||
3. Redémarrez le serveur MC après changement
|
|
||||||
|
|
||||||
### Problème: "Le joueur n'est pas OP sur le serveur"
|
|
||||||
|
|
||||||
**Cause**: Votre pseudo MC n'est pas OP
|
|
||||||
|
|
||||||
**Solution**:
|
|
||||||
1. Sur le serveur MC, dans la console:
|
|
||||||
```
|
|
||||||
op VotreNomMC
|
|
||||||
```
|
|
||||||
2. Attendez que le serveur se redémarre ou recharge les OPs
|
|
||||||
3. Réessayez l'enregistrement
|
|
||||||
|
|
||||||
### Problème: "Impossible de se connecter à localhost:4001"
|
|
||||||
|
|
||||||
**Cause**: L'application n'est pas lancée ou sur le mauvais port
|
|
||||||
|
|
||||||
**Solution**:
|
|
||||||
1. Vérifiez que `npm start` est lancé dans `backend/`
|
|
||||||
2. Vérifiez le PORT dans `.env`
|
|
||||||
3. Assurez-vous qu'aucune autre application n'utilise ce port:
|
|
||||||
```bash
|
|
||||||
lsof -i :3000 # Linux/Mac
|
|
||||||
netstat -ano | findstr :3000 # Windows
|
|
||||||
```
|
|
||||||
|
|
||||||
### Problème: "Node.js n'est pas trouvé"
|
|
||||||
|
|
||||||
**Solution**: Installer Node.js
|
|
||||||
- **Ubuntu/Debian**: `sudo apt-get install nodejs npm`
|
|
||||||
- **CentOS/RHEL**: `sudo yum install nodejs npm`
|
|
||||||
- **macOS**: `brew install node`
|
|
||||||
- **Windows**: https://nodejs.org
|
|
||||||
|
|
||||||
## 📊 Fonctionnalités Détaillées
|
|
||||||
|
|
||||||
### Console RCON
|
|
||||||
Exécutez n'importe quelle commande Minecraft:
|
|
||||||
```
|
|
||||||
/say Bienvenue!
|
|
||||||
/gamemode 1 @p
|
|
||||||
/give @p diamond 64
|
|
||||||
/weather clear
|
|
||||||
```
|
|
||||||
|
|
||||||
### Gestion des Logs
|
|
||||||
- Affichage temps réel
|
|
||||||
- Recherche par mot-clé
|
|
||||||
- Support multi-fichiers
|
|
||||||
|
|
||||||
### Whitelist
|
|
||||||
- Ajouter des joueurs
|
|
||||||
- Supprimer des joueurs
|
|
||||||
- Format JSON automatique
|
|
||||||
|
|
||||||
### Backups
|
|
||||||
- Création manuelle
|
|
||||||
- Compression tar.gz
|
|
||||||
- Gestion de l'espace
|
|
||||||
|
|
||||||
### Paramètres
|
|
||||||
- Lire tous les paramètres server.properties
|
|
||||||
- Modifier certains paramètres
|
|
||||||
- Changement de RCON
|
|
||||||
|
|
||||||
## 🔒 Sécurité - Important!
|
|
||||||
|
|
||||||
### En Production:
|
|
||||||
|
|
||||||
1. **Changez SESSION_SECRET**:
|
|
||||||
```bash
|
|
||||||
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Utilisez HTTPS**:
|
|
||||||
- Achetez un certificat SSL
|
|
||||||
- Configurez un proxy (nginx/Apache)
|
|
||||||
- Voir DEPLOYMENT.md
|
|
||||||
|
|
||||||
3. **Limitez l'accès**:
|
|
||||||
- Firewall: autoriser seulement vos IPs
|
|
||||||
- VPN: si accès distant
|
|
||||||
- Proxy avec authentification
|
|
||||||
|
|
||||||
4. **Changez RCON**:
|
|
||||||
- Utilisez un mot de passe fort
|
|
||||||
- Changez-le régulièrement
|
|
||||||
|
|
||||||
5. **Backups**:
|
|
||||||
- Sauvegardez vos backups ailleurs
|
|
||||||
- Testez les restaurations
|
|
||||||
|
|
||||||
## 📞 Support et Aide
|
|
||||||
|
|
||||||
### Vérification Rapide
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Vérifier que Node.js fonctionne
|
|
||||||
node --version
|
|
||||||
|
|
||||||
# Tester npm
|
|
||||||
npm --version
|
|
||||||
|
|
||||||
# Vérifier RCON du serveur MC
|
|
||||||
echo "status" | nc localhost 25575
|
|
||||||
|
|
||||||
# Vérifier les logs
|
# Vérifier les logs
|
||||||
cat /path/to/mc-server/latest.log | tail -50
|
docker logs mc-nationsglory | grep RCON
|
||||||
|
# Vous devriez voir : "RCON running on 0.0.0.0:25575"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Logs de l'Application
|
### 3. Configurer les OPs
|
||||||
|
|
||||||
Les logs du backend s'affichent en direct quand vous lancez `npm start`.
|
Seuls les opérateurs peuvent se connecter au panel web.
|
||||||
|
|
||||||
Logs des commandes RCON:
|
```bash
|
||||||
```
|
# Dans le serveur Minecraft (console ou RCON)
|
||||||
SERVER_DIR/.web-admin/rcon-history.json
|
op VotreNomDeJoueur
|
||||||
|
|
||||||
|
# Vérifier le fichier ops.txt
|
||||||
|
cat /chemin/vers/serveur/ops.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🚀 Prochaines Étapes
|
## 🐳 Configuration Docker
|
||||||
|
|
||||||
- [ ] Tester toutes les fonctionnalités
|
### 1. Fichier docker-compose.yml
|
||||||
- [ ] Ajouter des joueurs à la whitelist
|
|
||||||
- [ ] Créer des backups réguliers
|
|
||||||
- [ ] Configurer HTTPS pour la production
|
|
||||||
- [ ] Automatiser avec des scripts
|
|
||||||
|
|
||||||
## 📝 Notes Importantes
|
Le fichier principal de configuration :
|
||||||
|
|
||||||
1. **Redémarrage du serveur**: Les joueurs seront déconnectés
|
```yaml
|
||||||
2. **Sauvegarde**: Faites des backups réguliers
|
services:
|
||||||
3. **RCON**: Gardez le mot de passe sécurisé
|
app:
|
||||||
4. **Logs**: Vérifiez régulièrement pour les erreurs
|
build:
|
||||||
5. **Mises à jour**: Vérifiez les mises à jour Node.js
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- "4001:4001"
|
||||||
|
environment:
|
||||||
|
NODE_ENV: production
|
||||||
|
PORT: 4001
|
||||||
|
SERVER_DIR: /mc-server
|
||||||
|
RCON_HOST: localhost
|
||||||
|
RCON_PORT: 25575
|
||||||
|
SESSION_SECRET: change-this-in-production
|
||||||
|
volumes:
|
||||||
|
- /chemin/vers/serveur/minecraft:/mc-server
|
||||||
|
- web-admin:/mc-server/.web-admin
|
||||||
|
restart: unless-stopped
|
||||||
|
network_mode: host
|
||||||
|
|
||||||
Bon courage avec votre serveur! 🎮
|
volumes:
|
||||||
|
web-admin:
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Variables d'Environnement
|
||||||
|
|
||||||
|
| Variable | Description | Valeur par Défaut | Obligatoire |
|
||||||
|
|----------|-------------|-------------------|-------------|
|
||||||
|
| `NODE_ENV` | Mode d'exécution | `production` | Oui |
|
||||||
|
| `PORT` | Port du panel web | `4001` | Oui |
|
||||||
|
| `SERVER_DIR` | Chemin vers le serveur MC (dans Docker) | `/mc-server` | Oui |
|
||||||
|
| `RCON_HOST` | Hôte RCON | `localhost` | Oui |
|
||||||
|
| `RCON_PORT` | Port RCON | `25575` | Oui |
|
||||||
|
| `RCON_PASSWORD` | Mot de passe RCON | - | Oui (via .env) |
|
||||||
|
| `SESSION_SECRET` | Secret pour les sessions | - | Oui |
|
||||||
|
|
||||||
|
### 3. Configuration des Volumes
|
||||||
|
|
||||||
|
**Volume mc-server** : Serveur Minecraft (lecture/écriture)
|
||||||
|
```yaml
|
||||||
|
volumes:
|
||||||
|
- /home/user/minecraft-server:/mc-server
|
||||||
|
```
|
||||||
|
|
||||||
|
**Volume web-admin** : Données persistantes du panel
|
||||||
|
```yaml
|
||||||
|
volumes:
|
||||||
|
- web-admin:/mc-server/.web-admin
|
||||||
|
```
|
||||||
|
|
||||||
|
Ce volume stocke :
|
||||||
|
- `rcon-history.json` - Historique des commandes RCON
|
||||||
|
|
||||||
|
### 4. Network Mode
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
network_mode: host
|
||||||
|
```
|
||||||
|
|
||||||
|
Le mode `host` permet au conteneur d'accéder directement au RCON sur `localhost:25575`.
|
||||||
|
|
||||||
|
**Alternative** (si vous n'utilisez pas host) :
|
||||||
|
- Changer `RCON_HOST` vers l'IP du serveur Minecraft
|
||||||
|
- Exposer le port RCON dans le réseau Docker
|
||||||
|
|
||||||
|
## 🔐 Configuration de Sécurité
|
||||||
|
|
||||||
|
### 1. Générer un SESSION_SECRET
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Générer une clé aléatoire
|
||||||
|
openssl rand -base64 32
|
||||||
|
|
||||||
|
# Ou avec Node.js
|
||||||
|
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
|
||||||
|
```
|
||||||
|
|
||||||
|
Ajoutez-le dans `docker-compose.yml` ou créez un fichier `.env` :
|
||||||
|
|
||||||
|
```env
|
||||||
|
SESSION_SECRET=VotreClefAleatoireSecurisee
|
||||||
|
RCON_PASSWORD=VotreMotDePasseRCON
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Mot de Passe RCON
|
||||||
|
|
||||||
|
**Recommandations** :
|
||||||
|
- Minimum 12 caractères
|
||||||
|
- Mélange de majuscules, minuscules, chiffres, symboles
|
||||||
|
- Ne pas utiliser de mots du dictionnaire
|
||||||
|
- Différent du mot de passe serveur
|
||||||
|
|
||||||
|
**Exemple de mot de passe fort** :
|
||||||
|
```
|
||||||
|
Fx98dd82&*KmP!qZ7
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Permissions Fichiers
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Serveur Minecraft
|
||||||
|
chmod 755 /chemin/vers/serveur/minecraft
|
||||||
|
chmod 644 /chemin/vers/serveur/minecraft/server.properties
|
||||||
|
chmod 644 /chemin/vers/serveur/minecraft/ops.txt
|
||||||
|
|
||||||
|
# Panel Web
|
||||||
|
chmod 755 WebNationsGlory_ServeurBuild_Red
|
||||||
|
chmod 644 docker-compose.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🎨 Configuration Frontend
|
||||||
|
|
||||||
|
### 1. Personnalisation de l'Interface
|
||||||
|
|
||||||
|
Le style est défini dans `frontend/public/css/style.css`.
|
||||||
|
|
||||||
|
**Variables CSS principales** :
|
||||||
|
```css
|
||||||
|
:root {
|
||||||
|
--primary-color: #3498db;
|
||||||
|
--danger-color: #e74c3c;
|
||||||
|
--success-color: #2ecc71;
|
||||||
|
--warning-color: #f39c12;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Console RCON
|
||||||
|
|
||||||
|
La console est stylée comme un terminal Linux :
|
||||||
|
|
||||||
|
**Couleurs par défaut** :
|
||||||
|
- Fond : `#1e1e1e` (noir)
|
||||||
|
- Texte : `#0f0` (vert)
|
||||||
|
- Prompt : Nom d'utilisateur + serveur
|
||||||
|
|
||||||
|
Pour modifier :
|
||||||
|
```css
|
||||||
|
.terminal {
|
||||||
|
background-color: #1e1e1e;
|
||||||
|
color: #0f0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## ⚡ Configuration Backend
|
||||||
|
|
||||||
|
### 1. Fichier .env (Optionnel)
|
||||||
|
|
||||||
|
Créez `backend/.env` pour le développement local :
|
||||||
|
|
||||||
|
```env
|
||||||
|
NODE_ENV=development
|
||||||
|
PORT=4001
|
||||||
|
SERVER_DIR=/chemin/absolu/vers/serveur/minecraft
|
||||||
|
RCON_HOST=localhost
|
||||||
|
RCON_PORT=25575
|
||||||
|
RCON_PASSWORD=VotreMotDePasse
|
||||||
|
SESSION_SECRET=VotreSecret
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Configuration Express
|
||||||
|
|
||||||
|
Dans `backend/src/server.js`, les paramètres principaux :
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// Session
|
||||||
|
app.use(session({
|
||||||
|
secret: process.env.SESSION_SECRET,
|
||||||
|
resave: false,
|
||||||
|
saveUninitialized: false,
|
||||||
|
cookie: {
|
||||||
|
secure: false, // true en HTTPS
|
||||||
|
httpOnly: true,
|
||||||
|
maxAge: 1000 * 60 * 60 * 24 // 24 heures
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
// CORS
|
||||||
|
app.use(cors({
|
||||||
|
origin: true,
|
||||||
|
credentials: true
|
||||||
|
}));
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Gestion des Sessions
|
||||||
|
|
||||||
|
**En production**, utilisez Redis au lieu de MemoryStore :
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const RedisStore = require('connect-redis')(session);
|
||||||
|
const redis = require('redis');
|
||||||
|
const redisClient = redis.createClient();
|
||||||
|
|
||||||
|
app.use(session({
|
||||||
|
store: new RedisStore({ client: redisClient }),
|
||||||
|
// ...autres options
|
||||||
|
}));
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔧 Configuration Avancée
|
||||||
|
|
||||||
|
### 1. Cooldown Serveur
|
||||||
|
|
||||||
|
Temps d'attente avant arrêt/redémarrage (dans `frontend/public/js/app.js`) :
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const cooldownSeconds = 60; // 60 secondes par défaut
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Historique RCON
|
||||||
|
|
||||||
|
Nombre maximum de commandes sauvegardées :
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// Dans backend/src/routes/rcon.js
|
||||||
|
const MAX_HISTORY = 100;
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Timeout RCON
|
||||||
|
|
||||||
|
Délai d'attente pour les commandes RCON :
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// Dans backend/src/utils/rcon.js
|
||||||
|
const TIMEOUT = 5000; // 5 secondes
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📊 Configuration des Logs
|
||||||
|
|
||||||
|
### 1. Logs du Panel
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Voir les logs en temps réel
|
||||||
|
docker-compose logs -f app
|
||||||
|
|
||||||
|
# Dernières 100 lignes
|
||||||
|
docker-compose logs --tail=100 app
|
||||||
|
|
||||||
|
# Logs avec timestamp
|
||||||
|
docker-compose logs -t app
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Logs du Serveur Minecraft
|
||||||
|
|
||||||
|
Accessible via le panel : Menu **Logs** → `latest.log`
|
||||||
|
|
||||||
|
## 🌐 Configuration Réseau
|
||||||
|
|
||||||
|
### 1. Pare-feu
|
||||||
|
|
||||||
|
Ouvrir les ports nécessaires :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# UFW (Ubuntu/Debian)
|
||||||
|
sudo ufw allow 4001/tcp
|
||||||
|
sudo ufw allow 25575/tcp
|
||||||
|
|
||||||
|
# Firewalld (CentOS/RHEL)
|
||||||
|
sudo firewall-cmd --permanent --add-port=4001/tcp
|
||||||
|
sudo firewall-cmd --permanent --add-port=25575/tcp
|
||||||
|
sudo firewall-cmd --reload
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Accès Distant
|
||||||
|
|
||||||
|
Pour accéder au panel depuis l'extérieur :
|
||||||
|
|
||||||
|
1. Modifier `ports` dans docker-compose.yml :
|
||||||
|
```yaml
|
||||||
|
ports:
|
||||||
|
- "0.0.0.0:4001:4001"
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Configurer le pare-feu
|
||||||
|
3. Utiliser un reverse proxy (Nginx/Apache) pour HTTPS
|
||||||
|
|
||||||
|
## ✅ Vérification de la Configuration
|
||||||
|
|
||||||
|
### Checklist
|
||||||
|
|
||||||
|
- [ ] RCON activé dans `server.properties`
|
||||||
|
- [ ] Mot de passe RCON identique dans les deux fichiers
|
||||||
|
- [ ] `SERVER_DIR` pointe vers le bon dossier
|
||||||
|
- [ ] Au moins un joueur dans `ops.txt`
|
||||||
|
- [ ] Ports 4001 et 25575 disponibles
|
||||||
|
- [ ] Docker et Docker Compose installés
|
||||||
|
- [ ] `SESSION_SECRET` généré et sécurisé
|
||||||
|
- [ ] Volumes Docker correctement montés
|
||||||
|
|
||||||
|
### Test de Connexion
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Test RCON avec Docker
|
||||||
|
docker exec -it mc-nationsglory rcon-cli --password VotreMotDePasse
|
||||||
|
|
||||||
|
# Test du panel web
|
||||||
|
curl http://localhost:4001
|
||||||
|
|
||||||
|
# Vérifier les volumes
|
||||||
|
docker volume ls | grep web
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🆘 Problèmes Courants
|
||||||
|
|
||||||
|
### Le panel ne se connecte pas au RCON
|
||||||
|
|
||||||
|
1. Vérifier que RCON est actif : `docker logs mc-nationsglory | grep RCON`
|
||||||
|
2. Vérifier le mot de passe dans les deux configs
|
||||||
|
3. Tester manuellement : `docker exec -it mc-nationsglory rcon-cli`
|
||||||
|
|
||||||
|
### Les joueurs ne s'affichent pas
|
||||||
|
|
||||||
|
1. Vérifier que `/world/players/` existe
|
||||||
|
2. Vérifier que `usercache.json` est présent
|
||||||
|
3. Vérifier les permissions du volume
|
||||||
|
|
||||||
|
### Impossible de se connecter
|
||||||
|
|
||||||
|
1. Vérifier que vous êtes dans `ops.txt`
|
||||||
|
2. Vider le cache du navigateur
|
||||||
|
3. Vérifier les logs : `docker-compose logs app`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Pour plus d'informations : [README.md](README.md) | [DEPLOYMENT.md](DEPLOYMENT.md) | [MAINTENANCE.md](MAINTENANCE.md)
|
||||||
|
|||||||
590
DEPLOYMENT.md
590
DEPLOYMENT.md
@@ -1,64 +1,536 @@
|
|||||||
# Proxy Configuration pour Production
|
# Déploiement - NationsGlory Web Admin
|
||||||
# Utilisez ce fichier comme base pour configurer votre serveur web
|
|
||||||
|
|
||||||
# NGINX Configuration Example
|
Guide complet pour déployer le panel d'administration en production.
|
||||||
# ==========================
|
|
||||||
|
|
||||||
# server {
|
## 📋 Checklist Pré-Déploiement
|
||||||
# listen 80;
|
|
||||||
# server_name admin.nationglory.com;
|
|
||||||
#
|
|
||||||
# # Redirect to HTTPS
|
|
||||||
# return 301 https://$server_name$request_uri;
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# server {
|
|
||||||
# listen 443 ssl http2;
|
|
||||||
# server_name admin.nationglory.com;
|
|
||||||
#
|
|
||||||
# ssl_certificate /etc/ssl/certs/your-cert.crt;
|
|
||||||
# ssl_certificate_key /etc/ssl/private/your-key.key;
|
|
||||||
#
|
|
||||||
# client_max_body_size 100M;
|
|
||||||
#
|
|
||||||
# location / {
|
|
||||||
# proxy_pass http://localhost:3000;
|
|
||||||
# proxy_http_version 1.1;
|
|
||||||
# proxy_set_header Upgrade $http_upgrade;
|
|
||||||
# proxy_set_header Connection 'upgrade';
|
|
||||||
# proxy_set_header Host $host;
|
|
||||||
# proxy_cache_bypass $http_upgrade;
|
|
||||||
# proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
# proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
# Apache Configuration Example
|
Avant de déployer en production :
|
||||||
# ============================
|
|
||||||
|
|
||||||
# <VirtualHost *:80>
|
- [ ] Serveur Minecraft 1.6.4 configuré avec RCON activé
|
||||||
# ServerName admin.nationglory.com
|
- [ ] Docker et Docker Compose installés
|
||||||
# Redirect permanent / https://admin.nationglory.com/
|
- [ ] Ports 4001 et 25575 ouverts dans le pare-feu
|
||||||
# </VirtualHost>
|
- [ ] SESSION_SECRET généré de manière sécurisée
|
||||||
#
|
- [ ] Mot de passe RCON fort configuré
|
||||||
# <VirtualHost *:443>
|
- [ ] Au moins un utilisateur OP configuré
|
||||||
# ServerName admin.nationglory.com
|
- [ ] Backups du serveur Minecraft configurés
|
||||||
# SSLEngine on
|
- [ ] Certificats SSL (optionnel, recommandé)
|
||||||
# SSLCertificateFile /etc/ssl/certs/your-cert.crt
|
|
||||||
# SSLCertificateKeyFile /etc/ssl/private/your-key.key
|
|
||||||
#
|
|
||||||
# ProxyPreserveHost On
|
|
||||||
# ProxyPass / http://localhost:3000/
|
|
||||||
# ProxyPassReverse / http://localhost:3000/
|
|
||||||
#
|
|
||||||
# RequestHeader set X-Forwarded-Proto "https"
|
|
||||||
# RequestHeader set X-Forwarded-Port "443"
|
|
||||||
# </VirtualHost>
|
|
||||||
|
|
||||||
# Environment Variables
|
## 🚀 Déploiement Docker (Recommandé)
|
||||||
# ======================
|
|
||||||
# Set these in production:
|
### 1. Cloner le Projet
|
||||||
# NODE_ENV=production
|
|
||||||
# SESSION_SECRET=use-a-strong-random-key-here
|
```bash
|
||||||
# PORT=3000 (internal, proxy on 80/443)
|
cd /opt
|
||||||
|
git clone <votre-repo> WebNationsGlory
|
||||||
|
cd WebNationsGlory
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Configuration
|
||||||
|
|
||||||
|
Éditez `docker-compose.yml` :
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- "4001:4001"
|
||||||
|
environment:
|
||||||
|
NODE_ENV: production
|
||||||
|
PORT: 4001
|
||||||
|
SERVER_DIR: /mc-server
|
||||||
|
RCON_HOST: localhost
|
||||||
|
RCON_PORT: 25575
|
||||||
|
SESSION_SECRET: ${SESSION_SECRET} # Depuis fichier .env
|
||||||
|
volumes:
|
||||||
|
- /chemin/absolu/vers/serveur/minecraft:/mc-server
|
||||||
|
- web-admin:/mc-server/.web-admin
|
||||||
|
restart: unless-stopped
|
||||||
|
network_mode: host
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
web-admin:
|
||||||
|
```
|
||||||
|
|
||||||
|
Créez un fichier `.env` à la racine :
|
||||||
|
|
||||||
|
```env
|
||||||
|
SESSION_SECRET=VotreClefAleatoireSecurisee
|
||||||
|
RCON_PASSWORD=VotreMotDePasseRCON
|
||||||
|
```
|
||||||
|
|
||||||
|
**Générer un SESSION_SECRET sécurisé** :
|
||||||
|
```bash
|
||||||
|
openssl rand -base64 32
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Lancer le Conteneur
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build de l'image
|
||||||
|
docker-compose build
|
||||||
|
|
||||||
|
# Démarrage en arrière-plan
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
# Vérifier les logs
|
||||||
|
docker-compose logs -f app
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Vérification
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Vérifier que le conteneur tourne
|
||||||
|
docker-compose ps
|
||||||
|
|
||||||
|
# Tester l'accès
|
||||||
|
curl http://localhost:4001
|
||||||
|
|
||||||
|
# Vérifier les volumes
|
||||||
|
docker volume ls | grep web
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔒 Déploiement avec HTTPS (Production)
|
||||||
|
|
||||||
|
### Option 1 : Nginx Reverse Proxy
|
||||||
|
|
||||||
|
#### 1. Installation de Nginx
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Ubuntu/Debian
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install nginx
|
||||||
|
|
||||||
|
# CentOS/RHEL
|
||||||
|
sudo yum install nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. Configuration Nginx
|
||||||
|
|
||||||
|
Créez `/etc/nginx/sites-available/nationsglory-admin` :
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
# Redirect HTTP to HTTPS
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name admin.votre-domaine.com;
|
||||||
|
return 301 https://$server_name$request_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
# HTTPS Server
|
||||||
|
server {
|
||||||
|
listen 443 ssl http2;
|
||||||
|
server_name admin.votre-domaine.com;
|
||||||
|
|
||||||
|
# SSL Configuration
|
||||||
|
ssl_certificate /etc/letsencrypt/live/admin.votre-domaine.com/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/admin.votre-domaine.com/privkey.pem;
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||||
|
ssl_prefer_server_ciphers on;
|
||||||
|
|
||||||
|
# Security Headers
|
||||||
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||||
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||||
|
add_header X-Content-Type-Options "nosniff" always;
|
||||||
|
add_header X-XSS-Protection "1; mode=block" always;
|
||||||
|
|
||||||
|
# Proxy Configuration
|
||||||
|
location / {
|
||||||
|
proxy_pass http://localhost:4001;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
access_log /var/log/nginx/nationsglory-admin-access.log;
|
||||||
|
error_log /var/log/nginx/nationsglory-admin-error.log;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. Activer la Configuration
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Créer un lien symbolique
|
||||||
|
sudo ln -s /etc/nginx/sites-available/nationsglory-admin /etc/nginx/sites-enabled/
|
||||||
|
|
||||||
|
# Tester la configuration
|
||||||
|
sudo nginx -t
|
||||||
|
|
||||||
|
# Recharger Nginx
|
||||||
|
sudo systemctl reload nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 4. Certificat SSL avec Let's Encrypt
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Installer Certbot
|
||||||
|
sudo apt install certbot python3-certbot-nginx
|
||||||
|
|
||||||
|
# Obtenir un certificat
|
||||||
|
sudo certbot --nginx -d admin.votre-domaine.com
|
||||||
|
|
||||||
|
# Renouvellement automatique (optionnel)
|
||||||
|
sudo crontab -e
|
||||||
|
# Ajouter : 0 0 * * * certbot renew --quiet
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 5. Mettre à Jour Express pour HTTPS
|
||||||
|
|
||||||
|
Dans `docker-compose.yml`, ajoutez :
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
environment:
|
||||||
|
- TRUST_PROXY=true
|
||||||
|
```
|
||||||
|
|
||||||
|
Dans `backend/src/server.js`, après `const app = express();` :
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
app.set('trust proxy', 1); // Trust first proxy
|
||||||
|
|
||||||
|
// Mettre à jour la config session
|
||||||
|
app.use(session({
|
||||||
|
secret: process.env.SESSION_SECRET,
|
||||||
|
resave: false,
|
||||||
|
saveUninitialized: false,
|
||||||
|
cookie: {
|
||||||
|
secure: true, // true pour HTTPS
|
||||||
|
httpOnly: true,
|
||||||
|
sameSite: 'lax',
|
||||||
|
maxAge: 1000 * 60 * 60 * 24
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option 2 : Apache Reverse Proxy
|
||||||
|
|
||||||
|
#### 1. Installation d'Apache
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install apache2
|
||||||
|
sudo a2enmod proxy proxy_http ssl headers rewrite
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. Configuration Apache
|
||||||
|
|
||||||
|
Créez `/etc/apache2/sites-available/nationsglory-admin.conf` :
|
||||||
|
|
||||||
|
```apache
|
||||||
|
<VirtualHost *:80>
|
||||||
|
ServerName admin.votre-domaine.com
|
||||||
|
Redirect permanent / https://admin.votre-domaine.com/
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
<VirtualHost *:443>
|
||||||
|
ServerName admin.votre-domaine.com
|
||||||
|
|
||||||
|
SSLEngine on
|
||||||
|
SSLCertificateFile /etc/letsencrypt/live/admin.votre-domaine.com/fullchain.pem
|
||||||
|
SSLCertificateKeyFile /etc/letsencrypt/live/admin.votre-domaine.com/privkey.pem
|
||||||
|
|
||||||
|
# Security Headers
|
||||||
|
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
|
||||||
|
Header always set X-Frame-Options "SAMEORIGIN"
|
||||||
|
Header always set X-Content-Type-Options "nosniff"
|
||||||
|
Header always set X-XSS-Protection "1; mode=block"
|
||||||
|
|
||||||
|
# Proxy Configuration
|
||||||
|
ProxyPreserveHost On
|
||||||
|
ProxyPass / http://localhost:4001/
|
||||||
|
ProxyPassReverse / http://localhost:4001/
|
||||||
|
|
||||||
|
RequestHeader set X-Forwarded-Proto "https"
|
||||||
|
RequestHeader set X-Forwarded-Port "443"
|
||||||
|
|
||||||
|
ErrorLog ${APACHE_LOG_DIR}/nationsglory-admin-error.log
|
||||||
|
CustomLog ${APACHE_LOG_DIR}/nationsglory-admin-access.log combined
|
||||||
|
</VirtualHost>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. Activer la Configuration
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo a2ensite nationsglory-admin
|
||||||
|
sudo systemctl reload apache2
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔐 Sécurisation
|
||||||
|
|
||||||
|
### 1. Pare-feu
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# UFW (Ubuntu/Debian)
|
||||||
|
sudo ufw allow 80/tcp
|
||||||
|
sudo ufw allow 443/tcp
|
||||||
|
sudo ufw allow 4001/tcp # Seulement si accès direct nécessaire
|
||||||
|
sudo ufw enable
|
||||||
|
|
||||||
|
# Firewalld (CentOS/RHEL)
|
||||||
|
sudo firewall-cmd --permanent --add-service=http
|
||||||
|
sudo firewall-cmd --permanent --add-service=https
|
||||||
|
sudo firewall-cmd --permanent --add-port=4001/tcp
|
||||||
|
sudo firewall-cmd --reload
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Limitation d'Accès par IP (Optionnel)
|
||||||
|
|
||||||
|
Dans Nginx :
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
location / {
|
||||||
|
# Autoriser seulement certaines IPs
|
||||||
|
allow 192.168.1.0/24;
|
||||||
|
allow 10.0.0.0/8;
|
||||||
|
deny all;
|
||||||
|
|
||||||
|
proxy_pass http://localhost:4001;
|
||||||
|
# ... reste de la config
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Authentification Basique Nginx (Optionnel)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Créer un fichier de mots de passe
|
||||||
|
sudo htpasswd -c /etc/nginx/.htpasswd admin
|
||||||
|
|
||||||
|
# Dans la config Nginx
|
||||||
|
location / {
|
||||||
|
auth_basic "Admin Panel";
|
||||||
|
auth_basic_user_file /etc/nginx/.htpasswd;
|
||||||
|
# ... reste de la config
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📊 Monitoring et Logs
|
||||||
|
|
||||||
|
### 1. Logs Docker
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Logs en temps réel
|
||||||
|
docker-compose logs -f app
|
||||||
|
|
||||||
|
# Dernières 100 lignes
|
||||||
|
docker-compose logs --tail=100 app
|
||||||
|
|
||||||
|
# Logs avec timestamps
|
||||||
|
docker-compose logs -t app
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Rotation des Logs
|
||||||
|
|
||||||
|
Créez `/etc/logrotate.d/nationsglory-admin` :
|
||||||
|
|
||||||
|
```
|
||||||
|
/var/log/nginx/nationsglory-admin-*.log {
|
||||||
|
daily
|
||||||
|
rotate 14
|
||||||
|
compress
|
||||||
|
delaycompress
|
||||||
|
notifempty
|
||||||
|
create 0640 www-data adm
|
||||||
|
sharedscripts
|
||||||
|
postrotate
|
||||||
|
[ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
|
||||||
|
endscript
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Monitoring avec systemd
|
||||||
|
|
||||||
|
Créez `/etc/systemd/system/nationsglory-admin.service` :
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[Unit]
|
||||||
|
Description=NationsGlory Web Admin
|
||||||
|
Requires=docker.service
|
||||||
|
After=docker.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=yes
|
||||||
|
WorkingDirectory=/opt/WebNationsGlory
|
||||||
|
ExecStart=/usr/bin/docker-compose up -d
|
||||||
|
ExecStop=/usr/bin/docker-compose down
|
||||||
|
TimeoutStartSec=0
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
Activer :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo systemctl enable nationsglory-admin
|
||||||
|
sudo systemctl start nationsglory-admin
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔄 Mises à Jour
|
||||||
|
|
||||||
|
### 1. Mise à Jour Manuelle
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /opt/WebNationsGlory
|
||||||
|
|
||||||
|
# Pull des dernières modifications
|
||||||
|
git pull origin main
|
||||||
|
|
||||||
|
# Rebuild de l'image
|
||||||
|
docker-compose build
|
||||||
|
|
||||||
|
# Redémarrage
|
||||||
|
docker-compose down
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
# Vérifier
|
||||||
|
docker-compose logs -f app
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Script de Mise à Jour
|
||||||
|
|
||||||
|
Créez `update.sh` :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "🔄 Mise à jour du panel NationsGlory..."
|
||||||
|
|
||||||
|
# Backup de la config
|
||||||
|
cp docker-compose.yml docker-compose.yml.backup
|
||||||
|
|
||||||
|
# Pull des modifications
|
||||||
|
git pull origin main
|
||||||
|
|
||||||
|
# Rebuild et redémarrage
|
||||||
|
docker-compose build --no-cache
|
||||||
|
docker-compose down
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
echo "✅ Mise à jour terminée!"
|
||||||
|
docker-compose logs --tail=20 app
|
||||||
|
```
|
||||||
|
|
||||||
|
Utilisation :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x update.sh
|
||||||
|
./update.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## 💾 Backups
|
||||||
|
|
||||||
|
### 1. Backup Automatique des Données
|
||||||
|
|
||||||
|
Créez `/opt/backup-nationsglory.sh` :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/bin/bash
|
||||||
|
BACKUP_DIR="/opt/backups/nationsglory"
|
||||||
|
DATE=$(date +%Y%m%d-%H%M%S)
|
||||||
|
|
||||||
|
mkdir -p "$BACKUP_DIR"
|
||||||
|
|
||||||
|
# Backup du volume web-admin
|
||||||
|
docker run --rm \
|
||||||
|
-v webnationsglory_serveurbuild_red_web-admin:/data \
|
||||||
|
-v "$BACKUP_DIR":/backup \
|
||||||
|
alpine tar czf "/backup/web-admin-$DATE.tar.gz" -C /data .
|
||||||
|
|
||||||
|
# Garder seulement les 7 derniers backups
|
||||||
|
ls -t "$BACKUP_DIR"/web-admin-*.tar.gz | tail -n +8 | xargs -r rm
|
||||||
|
|
||||||
|
echo "✅ Backup créé: web-admin-$DATE.tar.gz"
|
||||||
|
```
|
||||||
|
|
||||||
|
Cron job :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo crontab -e
|
||||||
|
# Ajouter : 0 2 * * * /opt/backup-nationsglory.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Restauration
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Arrêter le conteneur
|
||||||
|
docker-compose down
|
||||||
|
|
||||||
|
# Restaurer le volume
|
||||||
|
docker run --rm \
|
||||||
|
-v webnationsglory_serveurbuild_red_web-admin:/data \
|
||||||
|
-v /opt/backups/nationsglory:/backup \
|
||||||
|
alpine sh -c "cd /data && tar xzf /backup/web-admin-20260204-020000.tar.gz"
|
||||||
|
|
||||||
|
# Redémarrer
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🆘 Dépannage Production
|
||||||
|
|
||||||
|
### Le panel ne démarre pas
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Vérifier les logs
|
||||||
|
docker-compose logs app
|
||||||
|
|
||||||
|
# Vérifier les ressources
|
||||||
|
docker stats
|
||||||
|
|
||||||
|
# Reconstruire from scratch
|
||||||
|
docker-compose down
|
||||||
|
docker-compose build --no-cache
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### Erreur de connexion RCON
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Tester RCON manuellement
|
||||||
|
docker exec -it mc-nationsglory rcon-cli
|
||||||
|
|
||||||
|
# Vérifier network_mode
|
||||||
|
docker inspect webnationsglory_serveurbuild_red-app-1 | grep NetworkMode
|
||||||
|
```
|
||||||
|
|
||||||
|
### Performance
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Voir l'utilisation des ressources
|
||||||
|
docker stats
|
||||||
|
|
||||||
|
# Limiter les ressources (dans docker-compose.yml)
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: '1.0'
|
||||||
|
memory: 512M
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📝 Checklist Post-Déploiement
|
||||||
|
|
||||||
|
- [ ] Panel accessible via HTTPS
|
||||||
|
- [ ] Certificat SSL valide
|
||||||
|
- [ ] RCON fonctionnel
|
||||||
|
- [ ] Authentification OP opérationnelle
|
||||||
|
- [ ] Historique RCON persistant
|
||||||
|
- [ ] Logs rotatés automatiquement
|
||||||
|
- [ ] Backups automatiques configurés
|
||||||
|
- [ ] Monitoring actif
|
||||||
|
- [ ] Pare-feu configuré
|
||||||
|
- [ ] Documentation à jour
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Pour plus d'informations : [README.md](README.md) | [CONFIGURATION.md](CONFIGURATION.md) | [MAINTENANCE.md](MAINTENANCE.md)
|
||||||
|
|||||||
317
INDEX.md
317
INDEX.md
@@ -1,244 +1,103 @@
|
|||||||
# 📋 Index - Fichiers et Documentation
|
# Index de la Documentation
|
||||||
|
|
||||||
## 🗂️ Structure du Projet
|
Documentation complète du panel web d'administration NationsGlory.
|
||||||
|
|
||||||
```
|
## 📖 Documents Disponibles
|
||||||
|
|
||||||
|
### 🚀 Démarrage
|
||||||
|
- **[README.md](README.md)** - Vue d'ensemble du projet et fonctionnalités
|
||||||
|
- **[QUICKSTART.md](QUICKSTART.md)** - Guide de démarrage rapide (5 minutes)
|
||||||
|
|
||||||
|
### ⚙️ Configuration & Déploiement
|
||||||
|
- **[CONFIGURATION.md](CONFIGURATION.md)** - Configuration détaillée
|
||||||
|
- **[DEPLOYMENT.md](DEPLOYMENT.md)** - Guide de déploiement en production
|
||||||
|
|
||||||
|
### 🔧 Maintenance & Suivi
|
||||||
|
- **[MAINTENANCE.md](MAINTENANCE.md)** - Maintenance, backups et dépannage
|
||||||
|
- **[CHANGELOG.md](CHANGELOG.md)** - Historique complet des versions
|
||||||
|
|
||||||
|
## 🎯 Guide de Lecture Recommandé
|
||||||
|
|
||||||
|
### Pour démarrer rapidement
|
||||||
|
1. [README.md](README.md) - Comprendre le projet
|
||||||
|
2. [QUICKSTART.md](QUICKSTART.md) - Installation en 3 étapes
|
||||||
|
3. Tester le panel sur http://localhost:4001
|
||||||
|
|
||||||
|
### Pour une installation complète
|
||||||
|
1. [CONFIGURATION.md](CONFIGURATION.md) - Paramétrage détaillé
|
||||||
|
2. [DEPLOYMENT.md](DEPLOYMENT.md) - Déploiement production
|
||||||
|
3. [MAINTENANCE.md](MAINTENANCE.md) - Maintenance quotidienne
|
||||||
|
|
||||||
|
### Pour le développement
|
||||||
|
1. [README.md](README.md) - Architecture et stack technique
|
||||||
|
2. [CHANGELOG.md](CHANGELOG.md) - Historique des modifications
|
||||||
|
3. Code source dans `backend/` et `frontend/`
|
||||||
|
|
||||||
|
## 📂 Structure du Projet
|
||||||
|
|
||||||
|
\`\`\`
|
||||||
WebNationsGlory_ServeurBuild_Red/
|
WebNationsGlory_ServeurBuild_Red/
|
||||||
│
|
├── README.md # Vue d'ensemble
|
||||||
├── 📄 Documentation
|
├── QUICKSTART.md # Démarrage rapide
|
||||||
│ ├── README.md ← Vue d'ensemble générale
|
├── CONFIGURATION.md # Configuration
|
||||||
│ ├── QUICKSTART.md ← Démarrage rapide (5 min)
|
├── DEPLOYMENT.md # Déploiement
|
||||||
│ ├── CONFIGURATION.md ← Configuration détaillée
|
├── MAINTENANCE.md # Maintenance
|
||||||
│ ├── MAINTENANCE.md ← Commandes et troubleshooting
|
├── CHANGELOG.md # Versions
|
||||||
│ ├── DEPLOYMENT.md ← Production & HTTPS
|
├── INDEX.md # Ce fichier
|
||||||
│ └── INDEX.md ← Ce fichier
|
├── docker-compose.yml # Orchestration Docker
|
||||||
│
|
├── Dockerfile # Image Docker
|
||||||
├── 🚀 Scripts de Démarrage
|
├── backend/ # API Node.js
|
||||||
│ ├── setup.sh ← Préparation initiale
|
│ ├── src/
|
||||||
│ ├── install.sh ← Installation des dépendances
|
│ │ ├── routes/ # Endpoints API
|
||||||
│ ├── start.sh ← Lancer l'application
|
│ │ ├── utils/ # Client RCON
|
||||||
│ └── .gitignore ← Fichiers à ignorer Git
|
│ │ └── server.js # Serveur Express
|
||||||
│
|
│ └── data/ # Données (users.json)
|
||||||
├── 📦 Backend (Express.js - Node.js)
|
└── frontend/ # Interface web
|
||||||
│ ├── package.json ← Dépendances Node.js
|
└── public/
|
||||||
│ ├── .env.example ← Template de configuration
|
├── css/ # Styles
|
||||||
│ └── src/
|
├── js/ # Application SPA
|
||||||
│ ├── server.js ← Point d'entrée principal
|
└── index.html # Point d'entrée
|
||||||
│ ├── routes/
|
\`\`\`
|
||||||
│ │ ├── auth.js ← Authentification & login
|
|
||||||
│ │ ├── rcon.js ← Console RCON & redémarrage
|
|
||||||
│ │ ├── logs.js ← Gestion des logs
|
|
||||||
│ │ ├── players.js ← Liste des joueurs
|
|
||||||
│ │ ├── whitelist.js ← Gestion whitelist
|
|
||||||
│ │ ├── backup.js ← Création de backups
|
|
||||||
│ │ └── server.js ← Paramètres serveur
|
|
||||||
│ └── utils/
|
|
||||||
│ └── rcon.js ← Client RCON (protocole)
|
|
||||||
│
|
|
||||||
├── 🎨 Frontend (HTML/CSS/JavaScript)
|
|
||||||
│ ├── package.json ← Meta frontend
|
|
||||||
│ └── public/
|
|
||||||
│ ├── index.html ← Page HTML principale
|
|
||||||
│ ├── css/
|
|
||||||
│ │ └── style.css ← Tous les styles
|
|
||||||
│ └── js/
|
|
||||||
│ └── app.js ← Application React-like
|
|
||||||
│
|
|
||||||
├── 🐳 Deployment
|
|
||||||
│ ├── Dockerfile ← Build Docker
|
|
||||||
│ └── docker-compose.yml ← Orchestration Docker
|
|
||||||
│
|
|
||||||
└── 🔧 Configuration
|
|
||||||
├── .gitignore
|
|
||||||
├── docker-compose.yml
|
|
||||||
└── Dockerfile
|
|
||||||
```
|
|
||||||
|
|
||||||
## 📖 Guides de Lecture
|
## 🔗 Liens Rapides
|
||||||
|
|
||||||
### Pour Démarrer Rapidement
|
### Commandes Docker
|
||||||
1. **QUICKSTART.md** - 5 minutes pour être opérationnel
|
\`\`\`bash
|
||||||
2. Suivez les 5 étapes simples
|
docker-compose up -d # Démarrer
|
||||||
|
docker-compose down # Arrêter
|
||||||
|
docker-compose logs -f app # Voir les logs
|
||||||
|
docker-compose restart app # Redémarrer
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
### Pour Comprendre la Configuration
|
### URLs Importantes
|
||||||
1. **README.md** - Vue d'ensemble
|
- Panel Web : http://localhost:4001
|
||||||
2. **CONFIGURATION.md** - Configuration détaillée
|
- RCON : localhost:25575
|
||||||
3. Éditer les fichiers .env
|
- Serveur Minecraft : selon votre configuration
|
||||||
|
|
||||||
### Pour Utiliser l'Application
|
### Fichiers de Configuration
|
||||||
1. Ouvrir http://localhost:4001
|
- \`docker-compose.yml\` - Configuration Docker
|
||||||
2. Créer le compte admin
|
- \`backend/src/server.js\` - Configuration Express
|
||||||
3. Utiliser les onglets du dashboard
|
- \`SERVER_DIR/server.properties\` - Configuration Minecraft
|
||||||
|
|
||||||
### Pour Administrer le Serveur
|
## 📝 Contribution
|
||||||
1. **MAINTENANCE.md** - Commandes utiles
|
|
||||||
2. Sauvegardes régulières
|
|
||||||
3. Monitoring
|
|
||||||
|
|
||||||
### Pour la Production
|
Pour toute modification :
|
||||||
1. **DEPLOYMENT.md** - Configuration HTTPS/Proxy
|
1. Éditer les fichiers appropriés
|
||||||
2. Sécurité renforcée
|
2. Tester localement avec Docker
|
||||||
3. Certificats SSL
|
3. Mettre à jour [CHANGELOG.md](CHANGELOG.md)
|
||||||
|
4. Commit et push
|
||||||
|
|
||||||
## 🔑 Points Clés
|
## ⚠️ Important
|
||||||
|
|
||||||
### Configuration
|
- Compatible uniquement avec **Minecraft 1.6.4**
|
||||||
- **Backend .env**: Variables d'environnement critiques
|
- Nécessite **Docker & Docker Compose**
|
||||||
- **Server.properties**: RCON du serveur MC
|
- Seuls les **OPs** peuvent se connecter
|
||||||
- **Ops.txt**: Liste des administrateurs
|
- Le serveur Minecraft doit être **démarré avant** le panel
|
||||||
|
|
||||||
### Sécurité
|
## 📄 Licence
|
||||||
- SESSION_SECRET unique en production
|
|
||||||
- HTTPS recommandé
|
|
||||||
- Firewall bien configuré
|
|
||||||
|
|
||||||
### Maintenance
|
Projet privé - NationsGlory Server
|
||||||
- Backups réguliers
|
|
||||||
- Logs à surveiller
|
|
||||||
- Mises à jour Node.js
|
|
||||||
|
|
||||||
## 🚀 Quickstart Ultime
|
---
|
||||||
|
|
||||||
```bash
|
Dernière mise à jour : 04/02/2025
|
||||||
# 1. Configuration serveur MC
|
|
||||||
# Éditer server.properties:
|
|
||||||
enable-rcon=true
|
|
||||||
rcon.port=25575
|
|
||||||
rcon.password=YourPassword123
|
|
||||||
|
|
||||||
# 2. Installation
|
|
||||||
cd WebNationsGlory_ServeurBuild_Red
|
|
||||||
./install.sh
|
|
||||||
|
|
||||||
# 3. Configuration app
|
|
||||||
nano backend/.env
|
|
||||||
|
|
||||||
# 4. Lancement
|
|
||||||
./start.sh
|
|
||||||
|
|
||||||
# 5. Accès
|
|
||||||
# Ouvrir: http://localhost:4001
|
|
||||||
```
|
|
||||||
|
|
||||||
## 📚 Fichiers Importants à Connaître
|
|
||||||
|
|
||||||
| Fichier | Rôle | Éditer? |
|
|
||||||
|---------|------|--------|
|
|
||||||
| backend/.env | Configuration | ✏️ OUI |
|
|
||||||
| backend/src/server.js | Point d'entrée | ❌ Non |
|
|
||||||
| frontend/public/js/app.js | Interface | ❌ Non (sauf custom) |
|
|
||||||
| README.md | Documentation | ✏️ Opcional |
|
|
||||||
| CONFIGURATION.md | Guide détaillé | ❌ Non |
|
|
||||||
|
|
||||||
## 🎯 Fonctionnalités par Fichier
|
|
||||||
|
|
||||||
### Routes API
|
|
||||||
|
|
||||||
**auth.js** 🔐
|
|
||||||
- Création compte admin
|
|
||||||
- Connexion/Déconnexion
|
|
||||||
- Changement mot de passe RCON
|
|
||||||
|
|
||||||
**rcon.js** ⌨️
|
|
||||||
- Exécution commandes RCON
|
|
||||||
- Historique commandes
|
|
||||||
- Redémarrage serveur
|
|
||||||
- Sauvegarde monde
|
|
||||||
|
|
||||||
**logs.js** 📜
|
|
||||||
- Visualisation logs
|
|
||||||
- Recherche dans logs
|
|
||||||
- Gestion fichiers logs
|
|
||||||
|
|
||||||
**players.js** 👥
|
|
||||||
- Liste joueurs
|
|
||||||
- UUID et connexions
|
|
||||||
- Statistiques
|
|
||||||
|
|
||||||
**whitelist.js** ✅
|
|
||||||
- Ajouter joueurs
|
|
||||||
- Retirer joueurs
|
|
||||||
- Gestion format
|
|
||||||
|
|
||||||
**backup.js** 💾
|
|
||||||
- Créer backups
|
|
||||||
- Lister backups
|
|
||||||
- Supprimer backups
|
|
||||||
|
|
||||||
**server.js** ⚙️
|
|
||||||
- Lire paramètres
|
|
||||||
- Modifier paramètres
|
|
||||||
- Configuration globale
|
|
||||||
|
|
||||||
### Utils
|
|
||||||
|
|
||||||
**rcon.js** 🔌
|
|
||||||
- Client RCON (protocole Minecraft)
|
|
||||||
- Connection/Auth
|
|
||||||
- Envoi commandes
|
|
||||||
- Parsing réponses
|
|
||||||
|
|
||||||
## 🔄 Flux de Requête
|
|
||||||
|
|
||||||
```
|
|
||||||
Browser (frontend/public/js/app.js)
|
|
||||||
↓
|
|
||||||
HTTP Request
|
|
||||||
↓
|
|
||||||
Backend Express (backend/src/server.js)
|
|
||||||
↓
|
|
||||||
Route Handler (backend/src/routes/*.js)
|
|
||||||
↓
|
|
||||||
RCON Client (backend/src/utils/rcon.js)
|
|
||||||
↓
|
|
||||||
Serveur Minecraft
|
|
||||||
↓
|
|
||||||
Response → Backend → Browser
|
|
||||||
```
|
|
||||||
|
|
||||||
## 🎓 Pour Apprendre
|
|
||||||
|
|
||||||
- **JavaScript**: app.js (client-side)
|
|
||||||
- **Node.js**: server.js (backend)
|
|
||||||
- **Express**: routes/*.js (API)
|
|
||||||
- **RCON Protocol**: utils/rcon.js
|
|
||||||
- **HTML/CSS**: index.html + style.css
|
|
||||||
|
|
||||||
## 🚨 Fichiers Critiques
|
|
||||||
|
|
||||||
Ne pas modifier sans savoir:
|
|
||||||
- ✓ backend/src/utils/rcon.js - Protocole RCON
|
|
||||||
- ✓ backend/src/server.js - Point d'entrée
|
|
||||||
- ✓ backend/src/routes/auth.js - Sécurité
|
|
||||||
|
|
||||||
Peuvent être modifiés:
|
|
||||||
- ✏️ frontend/public/css/style.css - Design
|
|
||||||
- ✏️ frontend/public/js/app.js - Interface
|
|
||||||
- ✏️ backend/.env - Configuration
|
|
||||||
|
|
||||||
## 📞 Ressources
|
|
||||||
|
|
||||||
- **Node.js Docs**: https://nodejs.org/docs
|
|
||||||
- **Express Docs**: https://expressjs.com
|
|
||||||
- **Minecraft Wiki RCON**: https://wiki.vg/RCON
|
|
||||||
- **JavaScript MDN**: https://developer.mozilla.org
|
|
||||||
|
|
||||||
## ✅ Checklist d'Installation
|
|
||||||
|
|
||||||
- [ ] Node.js 14+ installé
|
|
||||||
- [ ] ./install.sh exécuté
|
|
||||||
- [ ] backend/.env configuré
|
|
||||||
- [ ] Serveur MC avec RCON activé
|
|
||||||
- [ ] Premier compte admin créé
|
|
||||||
- [ ] Test RCON validé
|
|
||||||
- [ ] Documentations lues
|
|
||||||
|
|
||||||
## 🎉 Vous êtes Prêt!
|
|
||||||
|
|
||||||
Profitez de votre interface d'administration! 🚀
|
|
||||||
|
|
||||||
Pour plus d'aide, consultez:
|
|
||||||
1. QUICKSTART.md (5 min)
|
|
||||||
2. CONFIGURATION.md (détails)
|
|
||||||
3. MAINTENANCE.md (commandes)
|
|
||||||
4. DEPLOYMENT.md (production)
|
|
||||||
|
|||||||
660
MAINTENANCE.md
660
MAINTENANCE.md
@@ -1,347 +1,469 @@
|
|||||||
# 🔧 Maintenance et Administration
|
# Maintenance - NationsGlory Web Admin
|
||||||
|
|
||||||
## Commandes de Base
|
Guide de maintenance quotidienne et dépannage du panel d'administration.
|
||||||
|
|
||||||
|
## 🔄 Opérations Quotidiennes
|
||||||
|
|
||||||
|
### Démarrer le Panel
|
||||||
|
|
||||||
### Démarrer l'application
|
|
||||||
```bash
|
```bash
|
||||||
cd WebNationsGlory_ServeurBuild_Red
|
cd /home/innotex/Documents/Projet/Serveur\ NationsGlory/WebNationsGlory_ServeurBuild_Red
|
||||||
./start.sh
|
docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
### Arrêter l'application
|
### Arrêter le Panel
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Ctrl+C dans le terminal
|
docker-compose down
|
||||||
```
|
```
|
||||||
|
|
||||||
### Redémarrer l'application
|
### Redémarrer le Panel
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. Arrêtez avec Ctrl+C
|
docker-compose restart app
|
||||||
# 2. Relancez avec ./start.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Dépannage
|
### Voir les Logs
|
||||||
|
|
||||||
### Vérifier l'état de RCON
|
|
||||||
```bash
|
```bash
|
||||||
# Test simple
|
# Logs en temps réel
|
||||||
echo "status" | timeout 2 bash -c 'exec 3<>/dev/tcp/localhost/25575; cat >&3; cat <&3' 2>/dev/null || echo "RCON non accessible"
|
docker-compose logs -f app
|
||||||
|
|
||||||
# Avec nc (netcat)
|
# Dernières 100 lignes
|
||||||
nc -w 2 localhost 25575 < /dev/null && echo "RCON OK" || echo "RCON KO"
|
docker-compose logs --tail=100 app
|
||||||
|
|
||||||
# Avec telnet
|
# Logs avec timestamp
|
||||||
telnet localhost 25575
|
docker-compose logs -t app
|
||||||
```
|
```
|
||||||
|
|
||||||
### Vérifier les logs du serveur MC
|
## 📊 Monitoring
|
||||||
|
|
||||||
|
### État des Services
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Dernières 50 lignes
|
# Vérifier que le conteneur tourne
|
||||||
tail -50 /path/to/mc-server/latest.log
|
docker-compose ps
|
||||||
|
|
||||||
# Rechercher les erreurs
|
# Détails du conteneur
|
||||||
grep ERROR /path/to/mc-server/latest.log
|
docker inspect webnationsglory_serveurbuild_red-app-1
|
||||||
|
|
||||||
# Suivre en temps réel
|
# Utilisation des ressources
|
||||||
tail -f /path/to/mc-server/latest.log
|
docker stats
|
||||||
```
|
```
|
||||||
|
|
||||||
### Vérifier si le port 3000 est utilisé
|
### Vérifier le Panel Web
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Linux/Mac
|
# Test HTTP
|
||||||
lsof -i :3000
|
curl -I http://localhost:4001
|
||||||
|
|
||||||
# Windows PowerShell
|
# Tester la page de login
|
||||||
Get-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess
|
curl http://localhost:4001 | grep -i "login"
|
||||||
|
|
||||||
# Tuer le processus (Linux/Mac)
|
|
||||||
kill -9 $(lsof -t -i :3000)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Réinitialiser Node.js
|
### Vérifier RCON
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd backend
|
# Avec rcon-cli (depuis le conteneur Minecraft)
|
||||||
|
docker exec -it mc-nationsglory rcon-cli --password VotreMotDePasse
|
||||||
|
|
||||||
# Supprimer node_modules
|
# Commande test
|
||||||
rm -rf node_modules
|
docker exec -it mc-nationsglory rcon-cli --password VotreMotDePasse list
|
||||||
rm package-lock.json
|
```
|
||||||
|
|
||||||
# Réinstaller
|
### Vérifier les Volumes
|
||||||
npm install
|
|
||||||
|
```bash
|
||||||
|
# Liste des volumes
|
||||||
|
docker volume ls | grep web
|
||||||
|
|
||||||
|
# Inspecter le volume web-admin
|
||||||
|
docker volume inspect webnationsglory_serveurbuild_red_web-admin
|
||||||
|
|
||||||
|
# Voir le contenu
|
||||||
|
docker run --rm -v webnationsglory_serveurbuild_red_web-admin:/data alpine ls -lah /data/.web-admin/
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔧 Maintenance Régulière
|
||||||
|
|
||||||
|
### Nettoyage Docker
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Supprimer les images inutilisées
|
||||||
|
docker image prune -a
|
||||||
|
|
||||||
|
# Supprimer les conteneurs arrêtés
|
||||||
|
docker container prune
|
||||||
|
|
||||||
|
# Supprimer les volumes orphelins
|
||||||
|
docker volume prune
|
||||||
|
|
||||||
|
# Tout nettoyer (attention!)
|
||||||
|
docker system prune -a --volumes
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mise à Jour du Panel
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /home/innotex/Documents/Projet/Serveur\ NationsGlory/WebNationsGlory_ServeurBuild_Red
|
||||||
|
|
||||||
|
# Pull des modifications (si git)
|
||||||
|
git pull origin main
|
||||||
|
|
||||||
|
# Rebuild de l'image
|
||||||
|
docker-compose build --no-cache
|
||||||
|
|
||||||
# Redémarrer
|
# Redémarrer
|
||||||
npm start
|
docker-compose down
|
||||||
|
docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
## Gestion des OPs
|
### Rotation des Logs RCON
|
||||||
|
|
||||||
### Ajouter un OP sur le serveur MC
|
L'historique RCON est limité automatiquement, mais vous pouvez le nettoyer manuellement :
|
||||||
```
|
|
||||||
/op NomdujoueurMC
|
|
||||||
```
|
|
||||||
|
|
||||||
### Vérifier les OPs
|
|
||||||
```bash
|
```bash
|
||||||
# Fichier ops.txt
|
# Supprimer l'historique via l'API
|
||||||
cat /path/to/mc-server/ops.txt
|
curl -X DELETE http://localhost:4001/api/rcon/history
|
||||||
|
|
||||||
# Ou ops.json (Minecraft 1.8+)
|
# Ou directement dans le volume
|
||||||
cat /path/to/mc-server/ops.json
|
docker run --rm -v webnationsglory_serveurbuild_red_web-admin:/data alpine rm /data/.web-admin/rcon-history.json
|
||||||
```
|
```
|
||||||
|
|
||||||
## Backups
|
## 💾 Backups
|
||||||
|
|
||||||
|
### Backup Manuel du Volume web-admin
|
||||||
|
|
||||||
### Créer un backup manuel
|
|
||||||
```bash
|
```bash
|
||||||
cd /path/to/mc-server
|
# Créer un dossier de backup
|
||||||
|
mkdir -p ~/backups/nationsglory
|
||||||
|
|
||||||
# Créer un tar.gz du serveur
|
# Backup du volume
|
||||||
tar -czf ../backup-$(date +%Y%m%d-%H%M%S).tar.gz .
|
docker run --rm \
|
||||||
|
-v webnationsglory_serveurbuild_red_web-admin:/data \
|
||||||
|
-v ~/backups/nationsglory:/backup \
|
||||||
|
alpine tar czf /backup/web-admin-$(date +%Y%m%d-%H%M%S).tar.gz -C /data .
|
||||||
|
|
||||||
# Avec exclusion de certains fichiers
|
echo "Backup créé dans ~/backups/nationsglory/"
|
||||||
tar -czf ../backup-$(date +%Y%m%d-%H%M%S).tar.gz \
|
|
||||||
--exclude='*.log' \
|
|
||||||
--exclude='cache' \
|
|
||||||
--exclude='.web-admin' \
|
|
||||||
.
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Restaurer un backup
|
### Restaurer un Backup
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Arrêter le serveur d'abord!
|
# Arrêter le conteneur
|
||||||
./stop.sh
|
docker-compose down
|
||||||
|
|
||||||
# Restaurer
|
# Restaurer
|
||||||
cd /backup/location
|
docker run --rm \
|
||||||
tar -xzf backup-file.tar.gz -C /path/to/mc-server
|
-v webnationsglory_serveurbuild_red_web-admin:/data \
|
||||||
|
-v ~/backups/nationsglory:/backup \
|
||||||
|
alpine sh -c "cd /data && tar xzf /backup/web-admin-YYYYMMDD-HHMMSS.tar.gz"
|
||||||
|
|
||||||
# Redémarrer
|
# Redémarrer
|
||||||
cd /path/to/mc-server
|
docker-compose up -d
|
||||||
./start.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Logs et Monitoring
|
### Backup Automatique (Cron)
|
||||||
|
|
||||||
### Voir les logs backend en temps réel
|
Créez `/opt/backup-web-admin.sh` :
|
||||||
```bash
|
|
||||||
cd backend
|
|
||||||
npm start
|
|
||||||
```
|
|
||||||
|
|
||||||
### Voir les logs RCON (historique des commandes)
|
|
||||||
```bash
|
|
||||||
cat /path/to/mc-server/.web-admin/rcon-history.json
|
|
||||||
```
|
|
||||||
|
|
||||||
### Nettoyer les vieux logs
|
|
||||||
```bash
|
|
||||||
# Supprimer les logs de plus de 30 jours
|
|
||||||
find /path/to/mc-server -name "*.log" -mtime +30 -delete
|
|
||||||
```
|
|
||||||
|
|
||||||
## Variables d'Environnement
|
|
||||||
|
|
||||||
### Changer le port
|
|
||||||
```env
|
|
||||||
# backend/.env
|
|
||||||
PORT=8080
|
|
||||||
```
|
|
||||||
|
|
||||||
### Changer le répertoire du serveur
|
|
||||||
```env
|
|
||||||
# backend/.env
|
|
||||||
SERVER_DIR=/path/to/other/mc-server
|
|
||||||
```
|
|
||||||
|
|
||||||
### Changer les identifiants RCON
|
|
||||||
```env
|
|
||||||
# backend/.env
|
|
||||||
RCON_HOST=192.168.1.100
|
|
||||||
RCON_PORT=25576
|
|
||||||
```
|
|
||||||
|
|
||||||
## Mise à Jour des Dépendances
|
|
||||||
|
|
||||||
### Vérifier les mises à jour disponibles
|
|
||||||
```bash
|
|
||||||
cd backend
|
|
||||||
npm outdated
|
|
||||||
```
|
|
||||||
|
|
||||||
### Mettre à jour les dépendances
|
|
||||||
```bash
|
|
||||||
cd backend
|
|
||||||
npm update
|
|
||||||
```
|
|
||||||
|
|
||||||
### Mettre à jour une dépendance spécifique
|
|
||||||
```bash
|
|
||||||
cd backend
|
|
||||||
npm install express@latest
|
|
||||||
```
|
|
||||||
|
|
||||||
## Sécurité
|
|
||||||
|
|
||||||
### Changer le SESSION_SECRET
|
|
||||||
```bash
|
|
||||||
# Générer une nouvelle clé
|
|
||||||
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
|
|
||||||
|
|
||||||
# Mettre à jour dans backend/.env
|
|
||||||
SESSION_SECRET=<nouvelle-cle-generee>
|
|
||||||
|
|
||||||
# Redémarrer l'application
|
|
||||||
```
|
|
||||||
|
|
||||||
### Changer le mot de passe RCON
|
|
||||||
```bash
|
|
||||||
# Via l'interface web: Dashboard → Changer RCON
|
|
||||||
# Ou éditer manuellement server.properties:
|
|
||||||
rcon.password=NewPassword123
|
|
||||||
|
|
||||||
# Redémarrer le serveur MC
|
|
||||||
```
|
|
||||||
|
|
||||||
## Performance
|
|
||||||
|
|
||||||
### Vérifier l'utilisation mémoire Node.js
|
|
||||||
```bash
|
|
||||||
ps aux | grep node
|
|
||||||
|
|
||||||
# Linux avec plus de détails
|
|
||||||
ps -eo pid,vsz,rss,comm | grep node
|
|
||||||
```
|
|
||||||
|
|
||||||
### Nettoyer les fichiers temporaires
|
|
||||||
```bash
|
|
||||||
cd backend
|
|
||||||
rm -rf node_modules
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
### L'application démarre mais l'interface ne charge pas
|
|
||||||
```bash
|
|
||||||
# Vérifier que le frontend est bien servi
|
|
||||||
curl http://localhost:3000/
|
|
||||||
# Doit retourner l'HTML
|
|
||||||
|
|
||||||
# Vérifier la console du navigateur (F12) pour les erreurs
|
|
||||||
```
|
|
||||||
|
|
||||||
### Les commandes RCON n'exécutent pas
|
|
||||||
```bash
|
|
||||||
# Vérifier que RCON est activé
|
|
||||||
grep "enable-rcon" /path/to/mc-server/server.properties
|
|
||||||
# Doit être: enable-rcon=true
|
|
||||||
|
|
||||||
# Vérifier le mot de passe RCON
|
|
||||||
grep "rcon.password" /path/to/mc-server/server.properties
|
|
||||||
|
|
||||||
# Tester RCON directement
|
|
||||||
echo "say Test" | nc localhost 25575
|
|
||||||
```
|
|
||||||
|
|
||||||
### Base de données de sessions corruptée
|
|
||||||
```bash
|
|
||||||
# Supprimer les sessions
|
|
||||||
rm -rf backend/sessions/*
|
|
||||||
|
|
||||||
# Redémarrer l'application
|
|
||||||
./start.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
## Commandes Minecraft Utiles
|
|
||||||
|
|
||||||
### Via la console web
|
|
||||||
|
|
||||||
```
|
|
||||||
/list # Liste les joueurs
|
|
||||||
/say @a Message # Message à tous
|
|
||||||
/tp @p @s # Téléporter
|
|
||||||
/weather clear # Météo
|
|
||||||
/time set day # Heure
|
|
||||||
/gamerule <règle> # Game rules
|
|
||||||
/difficulty 3 # Difficulté
|
|
||||||
/seed # Seed du monde
|
|
||||||
/spawnpoint @p 0 100 0 # Spawnpoint
|
|
||||||
```
|
|
||||||
|
|
||||||
## Scripts Automatisés
|
|
||||||
|
|
||||||
### Script de backup automatique
|
|
||||||
```bash
|
```bash
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# save-mc-backup.sh
|
BACKUP_DIR="$HOME/backups/nationsglory"
|
||||||
|
DATE=$(date +%Y%m%d-%H%M%S)
|
||||||
SERVER_DIR="/path/to/mc-server"
|
|
||||||
BACKUP_DIR="$SERVER_DIR/backups"
|
|
||||||
|
|
||||||
mkdir -p "$BACKUP_DIR"
|
mkdir -p "$BACKUP_DIR"
|
||||||
DATE=$(date +%Y%m%d_%H%M%S)
|
|
||||||
BACKUP_FILE="$BACKUP_DIR/backup_$DATE.tar.gz"
|
|
||||||
|
|
||||||
cd "$SERVER_DIR"
|
docker run --rm \
|
||||||
tar -czf "$BACKUP_FILE" \
|
-v webnationsglory_serveurbuild_red_web-admin:/data \
|
||||||
--exclude='*.log' \
|
-v "$BACKUP_DIR":/backup \
|
||||||
--exclude='cache' \
|
alpine tar czf "/backup/web-admin-$DATE.tar.gz" -C /data .
|
||||||
--exclude='.web-admin' \
|
|
||||||
.
|
|
||||||
|
|
||||||
echo "Backup créé: $BACKUP_FILE"
|
# Garder seulement les 7 derniers
|
||||||
|
ls -t "$BACKUP_DIR"/web-admin-*.tar.gz | tail -n +8 | xargs -r rm
|
||||||
|
|
||||||
# À ajouter à crontab:
|
echo "✅ Backup créé: web-admin-$DATE.tar.gz"
|
||||||
# 0 2 * * * /path/to/save-mc-backup.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Script de redémarrage programmé
|
Puis :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x /opt/backup-web-admin.sh
|
||||||
|
|
||||||
|
# Ajouter au crontab (tous les jours à 2h)
|
||||||
|
crontab -e
|
||||||
|
# Ajouter: 0 2 * * * /opt/backup-web-admin.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🐛 Dépannage
|
||||||
|
|
||||||
|
### Le Panel ne Démarre Pas
|
||||||
|
|
||||||
|
**Symptômes** : `docker-compose up -d` échoue
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Voir les logs d'erreur
|
||||||
|
docker-compose logs app
|
||||||
|
|
||||||
|
# Vérifier les ports occupés
|
||||||
|
lsof -i :4001
|
||||||
|
|
||||||
|
# Reconstruire from scratch
|
||||||
|
docker-compose down
|
||||||
|
docker-compose build --no-cache
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### Erreur de Connexion RCON
|
||||||
|
|
||||||
|
**Symptômes** : "Failed to connect to RCON"
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Vérifier que le serveur MC est démarré
|
||||||
|
docker ps | grep mc-nationsglory
|
||||||
|
|
||||||
|
# 2. Vérifier que RCON est actif
|
||||||
|
docker logs mc-nationsglory | grep RCON
|
||||||
|
|
||||||
|
# 3. Tester RCON manuellement
|
||||||
|
docker exec -it mc-nationsglory rcon-cli --password VotreMotDePasse
|
||||||
|
|
||||||
|
# 4. Vérifier le mot de passe dans docker-compose.yml
|
||||||
|
cat docker-compose.yml | grep -A 5 environment
|
||||||
|
|
||||||
|
# 5. Vérifier server.properties
|
||||||
|
docker exec mc-nationsglory cat /mc-server/server.properties | grep rcon
|
||||||
|
```
|
||||||
|
|
||||||
|
### Les Joueurs ne s'Affichent Pas
|
||||||
|
|
||||||
|
**Symptômes** : Liste vide dans la section Players
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Vérifier le dossier players
|
||||||
|
docker exec mc-nationsglory ls -la /mc-server/world/players/
|
||||||
|
|
||||||
|
# 2. Vérifier usercache.json
|
||||||
|
docker exec mc-nationsglory cat /mc-server/usercache.json
|
||||||
|
|
||||||
|
# 3. Vérifier les permissions
|
||||||
|
docker exec mc-nationsglory ls -la /mc-server/world/
|
||||||
|
|
||||||
|
# 4. Voir les logs du panel
|
||||||
|
docker-compose logs app | grep -i player
|
||||||
|
```
|
||||||
|
|
||||||
|
### Impossible de se Connecter au Panel
|
||||||
|
|
||||||
|
**Symptômes** : "Invalid credentials" ou "Not an OP"
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Vérifier ops.txt
|
||||||
|
docker exec mc-nationsglory cat /mc-server/ops.txt
|
||||||
|
|
||||||
|
# 2. Ajouter un OP si nécessaire
|
||||||
|
docker exec -it mc-nationsglory rcon-cli --password VotreMotDePasse
|
||||||
|
> op VotreNom
|
||||||
|
|
||||||
|
# 3. Vérifier le fichier users.json
|
||||||
|
cat backend/data/users.json
|
||||||
|
|
||||||
|
# 4. Vider le cache navigateur et réessayer
|
||||||
|
```
|
||||||
|
|
||||||
|
### L'Historique RCON ne se Sauvegarde Pas
|
||||||
|
|
||||||
|
**Symptômes** : Historique vide après redémarrage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Vérifier que le volume existe
|
||||||
|
docker volume ls | grep web
|
||||||
|
|
||||||
|
# 2. Vérifier les permissions
|
||||||
|
docker run --rm -v webnationsglory_serveurbuild_red_web-admin:/data alpine ls -la /data/.web-admin/
|
||||||
|
|
||||||
|
# 3. Vérifier que le dossier est créé
|
||||||
|
docker exec webnationsglory_serveurbuild_red-app-1 ls -la /mc-server/.web-admin/
|
||||||
|
|
||||||
|
# 4. Voir les logs pour erreurs d'écriture
|
||||||
|
docker-compose logs app | grep -i "history\|error"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Les Paramètres ne se Sauvegardent Pas
|
||||||
|
|
||||||
|
**Symptômes** : Modifications dans Settings non persistées
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Vérifier que le volume n'est pas en lecture seule
|
||||||
|
docker inspect webnationsglory_serveurbuild_red-app-1 | grep -A 10 Mounts
|
||||||
|
|
||||||
|
# 2. Vérifier les permissions de server.properties
|
||||||
|
docker exec mc-nationsglory ls -la /mc-server/server.properties
|
||||||
|
|
||||||
|
# 3. Tester l'écriture
|
||||||
|
docker exec webnationsglory_serveurbuild_red-app-1 touch /mc-server/test.txt
|
||||||
|
|
||||||
|
# 4. Voir les logs
|
||||||
|
docker-compose logs app | grep -i "settings\|server.properties"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Le Serveur ne Redémarre/s'Arrête Pas
|
||||||
|
|
||||||
|
**Symptômes** : Boutons Shutdown/Restart ne fonctionnent pas
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Vérifier la connexion RCON
|
||||||
|
docker exec -it mc-nationsglory rcon-cli --password VotreMotDePasse
|
||||||
|
|
||||||
|
# 2. Tester la commande stop manuellement
|
||||||
|
docker exec -it mc-nationsglory rcon-cli --password VotreMotDePasse
|
||||||
|
> stop
|
||||||
|
|
||||||
|
# 3. Voir les logs du panel
|
||||||
|
docker-compose logs -f app
|
||||||
|
# Puis cliquer sur le bouton
|
||||||
|
|
||||||
|
# 4. Vérifier la console JavaScript (F12 dans le navigateur)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Performance Lente
|
||||||
|
|
||||||
|
**Symptômes** : Le panel répond lentement
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Vérifier l'utilisation CPU/RAM
|
||||||
|
docker stats webnationsglory_serveurbuild_red-app-1
|
||||||
|
|
||||||
|
# 2. Vérifier les logs pour erreurs
|
||||||
|
docker-compose logs app | grep -i error
|
||||||
|
|
||||||
|
# 3. Nettoyer l'historique RCON si trop volumineux
|
||||||
|
curl -X DELETE http://localhost:4001/api/rcon/history
|
||||||
|
|
||||||
|
# 4. Redémarrer le conteneur
|
||||||
|
docker-compose restart app
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔍 Vérifications de Santé
|
||||||
|
|
||||||
|
### Checklist Quotidienne
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Script de vérification
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "=== Vérification Panel NationsGlory ==="
|
||||||
|
|
||||||
|
# 1. Conteneur actif
|
||||||
|
docker-compose ps | grep -q "Up" && echo "✅ Conteneur actif" || echo "❌ Conteneur arrêté"
|
||||||
|
|
||||||
|
# 2. Panel accessible
|
||||||
|
curl -s http://localhost:4001 > /dev/null && echo "✅ Panel accessible" || echo "❌ Panel inaccessible"
|
||||||
|
|
||||||
|
# 3. RCON fonctionnel
|
||||||
|
docker exec mc-nationsglory rcon-cli --password VotreMotDePasse list > /dev/null 2>&1 && echo "✅ RCON OK" || echo "❌ RCON KO"
|
||||||
|
|
||||||
|
# 4. Volume web-admin existe
|
||||||
|
docker volume ls | grep -q web-admin && echo "✅ Volume web-admin OK" || echo "❌ Volume manquant"
|
||||||
|
|
||||||
|
# 5. Espace disque
|
||||||
|
df -h / | tail -1 | awk '{print "💾 Espace disque: " $5 " utilisé"}'
|
||||||
|
|
||||||
|
echo "=== Fin de la vérification ==="
|
||||||
|
```
|
||||||
|
|
||||||
|
### Checklist Hebdomadaire
|
||||||
|
|
||||||
|
- [ ] Vérifier les logs pour erreurs : `docker-compose logs app | grep -i error`
|
||||||
|
- [ ] Nettoyer les images Docker inutilisées : `docker image prune`
|
||||||
|
- [ ] Vérifier l'espace disque : `df -h`
|
||||||
|
- [ ] Tester la connexion au panel
|
||||||
|
- [ ] Tester l'envoi de commandes RCON
|
||||||
|
- [ ] Vérifier que les backups fonctionnent
|
||||||
|
|
||||||
|
### Checklist Mensuelle
|
||||||
|
|
||||||
|
- [ ] Backup complet du volume web-admin
|
||||||
|
- [ ] Mise à jour du panel (si disponible)
|
||||||
|
- [ ] Vérifier les certificats SSL (si HTTPS)
|
||||||
|
- [ ] Nettoyer les logs anciens
|
||||||
|
- [ ] Réviser les accès OP
|
||||||
|
- [ ] Tester la restauration d'un backup
|
||||||
|
|
||||||
|
## 📝 Logs Utiles
|
||||||
|
|
||||||
|
### Emplacement des Logs
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Logs Docker du panel
|
||||||
|
docker-compose logs app
|
||||||
|
|
||||||
|
# Logs Nginx (si reverse proxy)
|
||||||
|
/var/log/nginx/nationsglory-admin-access.log
|
||||||
|
/var/log/nginx/nationsglory-admin-error.log
|
||||||
|
|
||||||
|
# Logs du serveur Minecraft
|
||||||
|
docker exec mc-nationsglory cat /mc-server/logs/latest.log
|
||||||
|
```
|
||||||
|
|
||||||
|
### Recherche dans les Logs
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Erreurs uniquement
|
||||||
|
docker-compose logs app | grep -i error
|
||||||
|
|
||||||
|
# Connexions
|
||||||
|
docker-compose logs app | grep -i "login\|auth"
|
||||||
|
|
||||||
|
# Commandes RCON
|
||||||
|
docker-compose logs app | grep -i rcon
|
||||||
|
|
||||||
|
# Dernières 24h
|
||||||
|
docker-compose logs --since 24h app
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🚨 Alertes et Notifications
|
||||||
|
|
||||||
|
### Script de Monitoring
|
||||||
|
|
||||||
|
Créez `/opt/monitor-nationsglory.sh` :
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# restart-mc-server.sh
|
WEBHOOK="https://discord.com/api/webhooks/..." # Discord webhook (optionnel)
|
||||||
|
|
||||||
echo "Redémarrage du serveur MC dans 1 minute..."
|
# Vérifier que le panel tourne
|
||||||
|
if ! curl -s http://localhost:4001 > /dev/null; then
|
||||||
|
echo "❌ ALERTE: Panel NationsGlory inaccessible!"
|
||||||
|
# curl -X POST -H 'Content-Type: application/json' \
|
||||||
|
# -d '{"content":"🚨 Panel NationsGlory DOWN!"}' \
|
||||||
|
# "$WEBHOOK"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Via RCON
|
# Vérifier RCON
|
||||||
echo "say Redémarrage dans 1 minute!" | nc localhost 25575
|
if ! docker exec mc-nationsglory rcon-cli --password VotreMotDePasse list > /dev/null 2>&1; then
|
||||||
sleep 30
|
echo "❌ ALERTE: RCON ne répond pas!"
|
||||||
echo "say 30 secondes!" | nc localhost 25575
|
exit 1
|
||||||
sleep 20
|
fi
|
||||||
echo "say 10 secondes!" | nc localhost 25575
|
|
||||||
sleep 10
|
|
||||||
echo "stop" | nc localhost 25575
|
|
||||||
|
|
||||||
sleep 5
|
echo "✅ Tout fonctionne normalement"
|
||||||
|
|
||||||
# Redémarrer
|
|
||||||
cd /path/to/mc-server
|
|
||||||
./start.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Monitoring
|
Cron toutes les 5 minutes :
|
||||||
|
|
||||||
### Vérifier l'espace disque
|
|
||||||
```bash
|
```bash
|
||||||
# Espace utilisé par le serveur
|
crontab -e
|
||||||
du -sh /path/to/mc-server
|
# Ajouter: */5 * * * * /opt/monitor-nationsglory.sh
|
||||||
|
|
||||||
# Espace libre
|
|
||||||
df -h /path/to/mc-server
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Vérifier les processus Node.js
|
## 📚 Ressources
|
||||||
```bash
|
|
||||||
ps aux | grep node
|
|
||||||
# Ou
|
|
||||||
ps aux | grep npm
|
|
||||||
```
|
|
||||||
|
|
||||||
### Vérifier les ports en écoute
|
- [README.md](README.md) - Vue d'ensemble
|
||||||
```bash
|
- [CONFIGURATION.md](CONFIGURATION.md) - Configuration détaillée
|
||||||
netstat -tlnp | grep 3000 # Node.js
|
- [DEPLOYMENT.md](DEPLOYMENT.md) - Guide de déploiement
|
||||||
netstat -tlnp | grep 25575 # RCON
|
- [CHANGELOG.md](CHANGELOG.md) - Historique des versions
|
||||||
netstat -tlnp | grep 25565 # Serveur MC
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**💡 Astuce**: Sauvegardez ces commandes pour un accès rapide!
|
**Support** : Pour tout problème non résolu, vérifier les logs avec `docker-compose logs -f app` et consulter la section Dépannage.
|
||||||
|
|||||||
194
QUICKSTART.md
194
QUICKSTART.md
@@ -1,136 +1,144 @@
|
|||||||
# 🎯 Guide Rapide - Démarrage en 5 Minutes
|
# Guide de Démarrage Rapide
|
||||||
|
|
||||||
|
Ce guide vous permettra de démarrer le panel web en moins de 5 minutes.
|
||||||
|
|
||||||
## Prérequis
|
## Prérequis
|
||||||
- Node.js 14+ installé
|
|
||||||
- Serveur Minecraft avec RCON activé
|
|
||||||
- Vous devez être OP sur le serveur
|
|
||||||
|
|
||||||
## ⚡ Installation Express
|
✅ Docker et Docker Compose installés
|
||||||
|
✅ Serveur Minecraft 1.6.4 avec RCON activé
|
||||||
|
✅ Ports 4001 et 25575 disponibles
|
||||||
|
|
||||||
### 1️⃣ Configuration du serveur MC (10 secondes)
|
## Installation en 3 Étapes
|
||||||
|
|
||||||
Éditer le fichier `server.properties` du serveur Minecraft:
|
### 1. Configuration RCON du Serveur Minecraft
|
||||||
|
|
||||||
```properties
|
Éditez \`server.properties\` de votre serveur Minecraft :
|
||||||
|
|
||||||
|
\`\`\`properties
|
||||||
enable-rcon=true
|
enable-rcon=true
|
||||||
rcon.port=25575
|
rcon.port=25575
|
||||||
rcon.password=YourPassword123
|
rcon.password=VotreMotDePasse
|
||||||
```
|
\`\`\`
|
||||||
|
|
||||||
Redémarrer le serveur MC.
|
Redémarrez le serveur Minecraft.
|
||||||
|
|
||||||
### 2️⃣ Installation de l'app (2 minutes)
|
### 2. Configuration du Panel Web
|
||||||
|
|
||||||
```bash
|
Éditez \`docker-compose.yml\` et ajustez les variables d'environnement :
|
||||||
cd /home/innotex/Documents/Projet/Serveur\ NationsGlory/WebNationsGlory_ServeurBuild_Red
|
|
||||||
|
|
||||||
# Installation automatique
|
\`\`\`yaml
|
||||||
./install.sh
|
environment:
|
||||||
```
|
- SERVER_DIR=/chemin/vers/serveur/minecraft
|
||||||
|
- RCON_PASSWORD=VotreMotDePasse # Le même que dans server.properties
|
||||||
|
- SESSION_SECRET=UnSecretAleatoire
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
### 3️⃣ Configuration (1 minute)
|
### 3. Démarrage
|
||||||
|
|
||||||
```bash
|
\`\`\`bash
|
||||||
# Éditer le fichier
|
docker-compose up -d
|
||||||
nano backend/.env
|
\`\`\`
|
||||||
```
|
|
||||||
|
|
||||||
Vérifiez:
|
C'est tout ! Le panel est maintenant accessible sur **http://localhost:4001**
|
||||||
```env
|
|
||||||
PORT=4001
|
|
||||||
SERVER_DIR=/home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red
|
|
||||||
RCON_HOST=localhost
|
|
||||||
RCON_PORT=25575
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4️⃣ Lancement (30 secondes)
|
## Première Connexion
|
||||||
|
|
||||||
```bash
|
1. Ouvrez http://localhost:4001 dans votre navigateur
|
||||||
./start.sh
|
2. Connectez-vous avec un compte OP du serveur Minecraft
|
||||||
```
|
3. Le système vérifie automatiquement que vous êtes dans \`ops.txt\`
|
||||||
|
|
||||||
Vous devriez voir:
|
## Fonctionnalités Principales
|
||||||
```
|
|
||||||
🚀 Backend Admin NationsGlory démarré sur http://localhost:4001
|
|
||||||
```
|
|
||||||
|
|
||||||
### 5️⃣ Accès (10 secondes)
|
### 📊 Dashboard
|
||||||
|
- Affiche le nombre de joueurs connectés (X/Y)
|
||||||
|
- État du serveur en temps réel
|
||||||
|
|
||||||
Ouvrez: **http://localhost:4001**
|
### ⌨️ Console RCON
|
||||||
|
- Interface style terminal Linux
|
||||||
|
- Historique persistant des commandes avec recherche
|
||||||
|
- Redémarrage/Arrêt du serveur avec cooldown
|
||||||
|
- Boutons de commandes rapides : save-all, list, time, weather...
|
||||||
|
|
||||||
## 👤 Premier Compte
|
### 👥 Players
|
||||||
|
- Liste des joueurs connectés avec support des codes couleur § de Minecraft
|
||||||
|
- Informations détaillées (UUID, dernière connexion)
|
||||||
|
|
||||||
1. Remplissez le formulaire d'enregistrement:
|
### ✅ Whitelist
|
||||||
- Nom d'utilisateur: `admin` (ou ce que vous voulez)
|
- Ajout/suppression de joueurs autorisés
|
||||||
- Mot de passe: Votre mot de passe
|
- Gestion complète de la whitelist
|
||||||
- Pseudo Minecraft: **VOTRE NOM DE JOUEUR** (doit être OP!)
|
|
||||||
|
|
||||||
2. Cliquez "Créer le compte"
|
### 📜 Logs
|
||||||
|
- Visualisation des logs du serveur
|
||||||
|
- Recherche dans les logs
|
||||||
|
|
||||||
3. Connectez-vous avec vos identifiants
|
### ⚙️ Settings
|
||||||
|
- Modification en temps réel des paramètres serveur
|
||||||
|
- Les changements sont appliqués immédiatement à \`server.properties\`
|
||||||
|
- Masquage automatique des mots de passe RCON
|
||||||
|
|
||||||
## ✅ Test Rapide
|
## Commandes Utiles
|
||||||
|
|
||||||
1. Allez à l'onglet **Console RCON**
|
\`\`\`bash
|
||||||
2. Tapez: `/time query daytime`
|
# Voir les logs du panel
|
||||||
3. Cliquez "Envoyer"
|
docker-compose logs -f app
|
||||||
4. Vous devriez voir l'heure du serveur
|
|
||||||
|
|
||||||
Si ça marche = ✓ Tout est bon!
|
# Redémarrer le panel
|
||||||
|
docker-compose restart app
|
||||||
|
|
||||||
## 🎮 Commandes Utiles
|
# Arrêter le panel
|
||||||
|
docker-compose down
|
||||||
|
|
||||||
```
|
# Reconstruire après modifications du code
|
||||||
/say Bienvenue! → Message à tous
|
docker-compose up -d --build
|
||||||
/tp @s 0 100 0 → Se téléporter
|
\`\`\`
|
||||||
/give @p diamond 64 → Donner des items
|
|
||||||
/weather clear → Météo
|
|
||||||
/difficulty 3 → Difficulté
|
|
||||||
/time set day → Midi
|
|
||||||
```
|
|
||||||
|
|
||||||
## ⚠️ Problèmes Courants
|
## Volumes Docker
|
||||||
|
|
||||||
| Problème | Solution |
|
Le projet utilise deux volumes :
|
||||||
|----------|----------|
|
|
||||||
| "Timeout RCON" | Vérifier que le serveur MC est en ligne |
|
|
||||||
| "Mot de passe incorrect" | Vérifier dans server.properties |
|
|
||||||
| "Joueur n'est pas OP" | Faire `/op NomDuJoueur` sur le serveur MC |
|
|
||||||
| "Impossible de se connecter" | Vérifier que `npm start` est lancé |
|
|
||||||
|
|
||||||
## 📁 Fichiers Importants
|
1. **mc-server** : Montage du serveur Minecraft (lecture/écriture)
|
||||||
|
2. **web-admin** : Données persistantes du panel (historique RCON, etc.)
|
||||||
|
|
||||||
```
|
Pour voir les volumes :
|
||||||
backend/
|
\`\`\`bash
|
||||||
├── .env ← Configuration (à modifier)
|
docker volume ls | grep web
|
||||||
├── package.json ← Dépendances
|
\`\`\`
|
||||||
└── src/
|
|
||||||
├── server.js ← Point d'entrée
|
|
||||||
└── routes/ ← API endpoints
|
|
||||||
|
|
||||||
frontend/
|
## Dépannage Rapide
|
||||||
└── public/
|
|
||||||
└── index.html ← Interface web
|
|
||||||
```
|
|
||||||
|
|
||||||
## 🔐 Sécurité Basique
|
### Le panel ne démarre pas
|
||||||
|
\`\`\`bash
|
||||||
|
docker-compose logs app
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
1. Changez `SESSION_SECRET` dans `.env` (ligne importante)
|
### Erreur de connexion RCON
|
||||||
2. Utilisez un mot de passe RCON fort
|
1. Vérifier que le serveur Minecraft est démarré
|
||||||
3. Ne partagez pas vos identifiants
|
2. Vérifier \`enable-rcon=true\` dans \`server.properties\`
|
||||||
|
3. Vérifier que le mot de passe RCON correspond
|
||||||
|
|
||||||
## 📖 Documentation Complète
|
### Les joueurs ne s'affichent pas
|
||||||
|
1. Vérifier que \`/world/players/\` existe dans le serveur Minecraft
|
||||||
|
2. Vérifier que \`usercache.json\` est présent
|
||||||
|
|
||||||
- **README.md** - Vue d'ensemble complète
|
### Impossible de se connecter
|
||||||
- **CONFIGURATION.md** - Configuration détaillée
|
1. Vérifier que votre nom d'utilisateur est dans \`ops.txt\`
|
||||||
- **DEPLOYMENT.md** - Déploiement en production
|
2. Vider le cache du navigateur
|
||||||
|
3. Vérifier les logs : \`docker-compose logs app\`
|
||||||
|
|
||||||
## 🆘 Besoin d'aide?
|
## Prochaines Étapes
|
||||||
|
|
||||||
1. Vérifiez les logs: `npm start` affiche tout
|
- Consultez [CONFIGURATION.md](CONFIGURATION.md) pour une configuration avancée
|
||||||
2. Testez RCON: `echo "status" | nc localhost 25575`
|
- Consultez [DEPLOYMENT.md](DEPLOYMENT.md) pour un déploiement en production
|
||||||
3. Lisez CONFIGURATION.md pour plus de détails
|
- Consultez [MAINTENANCE.md](MAINTENANCE.md) pour la maintenance et les backups
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
En cas de problème, vérifiez :
|
||||||
|
1. Les logs Docker : \`docker-compose logs app\`
|
||||||
|
2. Que le serveur Minecraft est démarré
|
||||||
|
3. Que les ports 4001 et 25575 sont disponibles
|
||||||
|
4. Que \`SERVER_DIR\` pointe vers le bon dossier
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Vous êtes prêt!** 🚀 Profitez de votre interface!
|
**Note** : Ce panel est compatible uniquement avec Minecraft 1.6.4 en raison du format spécifique des fichiers de joueurs et des codes couleur §.
|
||||||
|
|||||||
302
README.md
302
README.md
@@ -1,228 +1,134 @@
|
|||||||
# Interface Web d'Administration - NationsGlory
|
# NationsGlory Web Admin
|
||||||
|
|
||||||
Application web complète pour gérer votre serveur Minecraft 1.6.4 sans taper une seule commande!
|
Panel d'administration web pour serveur Minecraft 1.6.4 NationsGlory.
|
||||||
|
|
||||||
## 🚀 Fonctionnalités
|
## 🚀 Quick Start
|
||||||
|
|
||||||
### 🔐 Sécurité
|
```bash
|
||||||
- Authentification sécurisée par mot de passe
|
# Démarrage avec Docker Compose
|
||||||
- Seuls les OPs du serveur MC peuvent se connecter
|
docker-compose up -d
|
||||||
- Sessions sécurisées avec expiration
|
|
||||||
|
|
||||||
### ⌨️ Console RCON
|
# Le panel sera accessible sur http://localhost:4001
|
||||||
- Exécutez des commandes directement depuis l'interface
|
```
|
||||||
- Historique complet des commandes
|
|
||||||
- Réponses en temps réel
|
|
||||||
|
|
||||||
### 📊 Dashboard
|
## ✨ Fonctionnalités
|
||||||
- État du serveur en temps réel
|
|
||||||
- Nombre de joueurs connectés
|
|
||||||
- Informations rapides du serveur
|
|
||||||
|
|
||||||
### 📜 Logs
|
### 🎮 Gestion du Serveur
|
||||||
- Visualisation des logs en temps réel
|
- **Console RCON** : Interface style terminal Linux pour exécuter des commandes
|
||||||
- Recherche dans les logs
|
- **Historique des commandes** : Sauvegarde persistante avec recherche et suppression
|
||||||
- Plusieurs fichiers logs supportés
|
- **Contrôle du serveur** : Arrêt et redémarrage avec cooldown configurable
|
||||||
|
- **Paramètres en temps réel** : Modification des propriétés serveur sans redémarrage
|
||||||
|
|
||||||
### 👥 Gestion des Joueurs
|
### 👥 Gestion des Joueurs
|
||||||
- Liste de tous les joueurs ayant joué
|
- **Liste des joueurs connectés** : Affichage temps réel avec support des codes couleur Minecraft (§)
|
||||||
- UUID et dernière connexion
|
- **Compteur de joueurs** : Affichage X/Y dans le dashboard
|
||||||
- Informations détaillées
|
- **Whitelist** : Ajout/suppression de joueurs autorisés
|
||||||
|
- **Logs** : Consultation des logs serveur
|
||||||
|
|
||||||
### ✅ Whitelist
|
### 🔐 Sécurité
|
||||||
- Ajouter/supprimer des joueurs
|
- **Authentification OP** : Seuls les opérateurs du serveur peuvent se connecter
|
||||||
- Gestion complète de la whitelist
|
- **Sessions persistantes** : Gestion sécurisée des sessions
|
||||||
- Support des formats JSON et TXT
|
- **Masquage des mots de passe** : Les mots de passe RCON ne s'affichent pas en clair
|
||||||
|
|
||||||
### 💾 Backups
|
## 🏗️ Architecture
|
||||||
- Création de backups automatiques
|
|
||||||
- Gestion des anciens backups
|
|
||||||
- Suppression facile
|
|
||||||
|
|
||||||
### ⚙️ Paramètres
|
\`\`\`
|
||||||
- Modification des settings du serveur
|
WebNationsGlory/
|
||||||
- Changement du mot de passe RCON
|
|
||||||
- Gestion complète de server.properties
|
|
||||||
|
|
||||||
### 🔄 Commandes Utiles
|
|
||||||
- Redémarrage du serveur
|
|
||||||
- Sauvegarde du monde
|
|
||||||
- Notifications aux joueurs
|
|
||||||
|
|
||||||
## 📋 Prérequis
|
|
||||||
|
|
||||||
- Node.js 14+ et npm
|
|
||||||
- Serveur Minecraft avec RCON activé
|
|
||||||
- RCON correctement configuré dans server.properties
|
|
||||||
|
|
||||||
## 🔧 Installation
|
|
||||||
|
|
||||||
### 1. Préparer le serveur Minecraft
|
|
||||||
|
|
||||||
Éditer `server.properties` du serveur MC:
|
|
||||||
```properties
|
|
||||||
enable-rcon=true
|
|
||||||
rcon.port=25575
|
|
||||||
rcon.password=votreMotDePasseRcon
|
|
||||||
```
|
|
||||||
|
|
||||||
Redémarrer le serveur MC.
|
|
||||||
|
|
||||||
### 2. Installer l'interface web
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd WebNationsGlory_ServeurBuild_Red
|
|
||||||
chmod +x install.sh
|
|
||||||
./install.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. Configurer
|
|
||||||
|
|
||||||
Éditer `backend/.env`:
|
|
||||||
```env
|
|
||||||
NODE_ENV=development
|
|
||||||
PORT=4001
|
|
||||||
SESSION_SECRET=changez-cette-cle-en-production
|
|
||||||
SERVER_DIR=/path/to/NationsGlory_ServeurBuild_Red
|
|
||||||
RCON_HOST=localhost
|
|
||||||
RCON_PORT=25575
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. Lancer l'application
|
|
||||||
|
|
||||||
```bash
|
|
||||||
chmod +x start.sh
|
|
||||||
./start.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
L'interface est maintenant accessible sur: **http://localhost:4001**
|
|
||||||
|
|
||||||
## 🎯 Premier Démarrage
|
|
||||||
|
|
||||||
1. Ouvrez http://localhost:4001
|
|
||||||
2. Créez le compte admin (doit être un OP du serveur)
|
|
||||||
3. Connectez-vous
|
|
||||||
4. Explorez l'interface!
|
|
||||||
|
|
||||||
## 📁 Structure du Projet
|
|
||||||
|
|
||||||
```
|
|
||||||
WebNationsGlory_ServeurBuild_Red/
|
|
||||||
├── backend/
|
├── backend/
|
||||||
│ ├── package.json
|
│ ├── src/
|
||||||
│ ├── .env (à créer)
|
│ │ ├── routes/ # API endpoints
|
||||||
│ └── src/
|
│ │ ├── utils/ # RCON client
|
||||||
│ ├── server.js (point d'entrée)
|
│ │ └── server.js # Express app
|
||||||
│ ├── routes/
|
│ └── data/
|
||||||
│ │ ├── auth.js (authentification)
|
│ └── users.json # Utilisateurs
|
||||||
│ │ ├── rcon.js (console & contrôle)
|
|
||||||
│ │ ├── logs.js (visualisation logs)
|
|
||||||
│ │ ├── players.js (gestion joueurs)
|
|
||||||
│ │ ├── whitelist.js (gestion whitelist)
|
|
||||||
│ │ ├── backup.js (gestion backups)
|
|
||||||
│ │ └── server.js (paramètres)
|
|
||||||
│ └── utils/
|
|
||||||
│ └── rcon.js (client RCON)
|
|
||||||
├── frontend/
|
├── frontend/
|
||||||
│ └── public/
|
│ └── public/
|
||||||
│ ├── index.html
|
│ ├── css/ # Styles
|
||||||
│ ├── js/app.js
|
│ ├── js/ # SPA vanilla JS
|
||||||
│ └── css/style.css
|
│ └── index.html
|
||||||
└── start.sh
|
└── docker-compose.yml # Orchestration
|
||||||
```
|
\`\`\`
|
||||||
|
|
||||||
## 🔌 API Endpoints
|
## 🔧 Configuration
|
||||||
|
|
||||||
### Authentification
|
### Prérequis
|
||||||
- `POST /api/auth/register` - Créer un compte admin
|
- Docker & Docker Compose
|
||||||
- `POST /api/auth/login` - Se connecter
|
- Serveur Minecraft 1.6.4 avec RCON activé
|
||||||
- `GET /api/auth/check` - Vérifier la connexion
|
- Port 25575 (RCON) et 4001 (Web) disponibles
|
||||||
- `POST /api/auth/logout` - Se déconnecter
|
|
||||||
|
|
||||||
### Console RCON
|
### Variables d'environnement
|
||||||
- `POST /api/rcon/command` - Exécuter une commande
|
\`\`\`env
|
||||||
- `GET /api/rcon/history` - Historique des commandes
|
SERVER_DIR=/mc-server # Chemin vers le serveur Minecraft
|
||||||
- `POST /api/rcon/restart` - Redémarrer le serveur
|
RCON_HOST=localhost # Hôte RCON
|
||||||
- `POST /api/rcon/save` - Sauvegarder
|
RCON_PORT=25575 # Port RCON
|
||||||
|
RCON_PASSWORD=votre_mot_de_passe # Mot de passe RCON
|
||||||
|
SESSION_SECRET=secret_securise # Secret pour les sessions
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
### Serveur
|
### Serveur Minecraft (server.properties)
|
||||||
- `GET /api/server` - Récupérer les paramètres
|
\`\`\`properties
|
||||||
- `POST /api/server/update` - Mettre à jour un paramètre
|
enable-rcon=true
|
||||||
|
rcon.port=25575
|
||||||
|
rcon.password=votre_mot_de_passe
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
### Logs
|
## 📚 Documentation
|
||||||
- `GET /api/logs` - Récupérer les logs
|
|
||||||
- `GET /api/logs/files` - Lister les fichiers logs
|
|
||||||
- `GET /api/logs/file/:filename` - Lire un fichier spécifique
|
|
||||||
- `GET /api/logs/search?query=...` - Chercher dans les logs
|
|
||||||
|
|
||||||
### Joueurs
|
- [QUICKSTART.md](QUICKSTART.md) - Guide de démarrage rapide
|
||||||
- `GET /api/players` - Lister les joueurs
|
- [CONFIGURATION.md](CONFIGURATION.md) - Configuration détaillée
|
||||||
|
- [DEPLOYMENT.md](DEPLOYMENT.md) - Guide de déploiement
|
||||||
|
- [MAINTENANCE.md](MAINTENANCE.md) - Maintenance et dépannage
|
||||||
|
- [CHANGELOG.md](CHANGELOG.md) - Historique des versions
|
||||||
|
|
||||||
### Whitelist
|
## 🔐 Première Connexion
|
||||||
- `GET /api/whitelist` - Récupérer la whitelist
|
|
||||||
- `POST /api/whitelist/add` - Ajouter un joueur
|
|
||||||
- `POST /api/whitelist/remove` - Retirer un joueur
|
|
||||||
|
|
||||||
### Backups
|
1. Démarrer le serveur Minecraft
|
||||||
- `GET /api/backup` - Lister les backups
|
2. Démarrer le panel web : \`docker-compose up -d\`
|
||||||
- `POST /api/backup/create` - Créer un backup
|
3. Accéder à http://localhost:4001
|
||||||
- `POST /api/backup/delete/:filename` - Supprimer un backup
|
4. Se connecter avec un compte OP du serveur Minecraft
|
||||||
|
5. Le système vérifie automatiquement les permissions OP dans \`ops.txt\`
|
||||||
|
|
||||||
## 🆘 Dépannage
|
## 🛠️ Développement
|
||||||
|
|
||||||
### La connexion RCON échoue
|
### Structure Backend
|
||||||
- Vérifiez que RCON est activé dans server.properties
|
- **Express.js** : Serveur web Node.js 18
|
||||||
- Vérifiez le port et le mot de passe
|
- **RCON Client** : Implémentation complète du protocole Minecraft RCON (Int32LE)
|
||||||
- Assurez-vous que le serveur MC est en ligne
|
- **Sessions** : express-session avec MemoryStore
|
||||||
|
- **Authentification** : bcryptjs pour le hachage
|
||||||
|
|
||||||
### Les logs ne s'affichent pas
|
### Structure Frontend
|
||||||
- Vérifiez le chemin de SERVER_DIR dans .env
|
- **Vanilla JavaScript** : SPA sans framework
|
||||||
- Assurez-vous que les fichiers logs existent
|
- **Style Terminal** : Console RCON avec apparence Linux shell
|
||||||
|
- **API REST** : Communication avec le backend
|
||||||
|
|
||||||
|
## ⚠️ Notes Importantes
|
||||||
|
|
||||||
|
- Le serveur Minecraft doit être démarré **avant** le panel web
|
||||||
|
- Seuls les joueurs dans \`ops.txt\` peuvent se connecter
|
||||||
|
- L'historique RCON est sauvegardé dans un volume Docker nommé \`web-admin\`
|
||||||
|
- Le serveur utilise \`network_mode: host\` pour accéder au RCON local
|
||||||
|
- Compatible uniquement avec Minecraft 1.6.4 (codes couleur §)
|
||||||
|
|
||||||
|
## 📦 Volumes Docker
|
||||||
|
|
||||||
|
- \`mc-server\` : Données du serveur Minecraft (lecture/écriture)
|
||||||
|
- \`web-admin\` : Données persistantes du panel (.web-admin/)
|
||||||
|
|
||||||
|
## 🐛 Dépannage
|
||||||
|
|
||||||
|
### Le panel ne se connecte pas au RCON
|
||||||
|
1. Vérifier que \`enable-rcon=true\` dans \`server.properties\`
|
||||||
|
2. Vérifier le mot de passe RCON
|
||||||
|
3. Vérifier que le serveur Minecraft est démarré
|
||||||
|
|
||||||
### Les joueurs ne s'affichent pas
|
### Les joueurs ne s'affichent pas
|
||||||
- Attendez qu'au moins un joueur se soit connecté
|
1. Vérifier que le dossier \`/world/players/\` existe
|
||||||
- Vérifiez que usercache.json existe
|
2. Vérifier que \`usercache.json\` est présent
|
||||||
|
|
||||||
## ⚠️ Sécurité
|
### Impossible de modifier les paramètres
|
||||||
|
1. Vérifier que le volume \`mc-server\` n'est pas en lecture seule
|
||||||
|
2. Vérifier les permissions sur \`server.properties\`
|
||||||
|
|
||||||
En production:
|
## 📄 Licence
|
||||||
- Changez `SESSION_SECRET` avec une clé forte
|
|
||||||
- Utilisez HTTPS
|
|
||||||
- Placez derrière un proxy (nginx, Apache)
|
|
||||||
- Limitez l'accès par IP si possible
|
|
||||||
|
|
||||||
## 📝 Logs Applicatifs
|
Projet privé - NationsGlory Server
|
||||||
|
|
||||||
Les logs de l'application se trouvent dans:
|
|
||||||
- Backend console: directement dans le terminal
|
|
||||||
- RCON historique: `SERVER_DIR/.web-admin/rcon-history.json`
|
|
||||||
|
|
||||||
## 🎮 Commandes Minecraft Utiles
|
|
||||||
|
|
||||||
Depuis la console RCON:
|
|
||||||
- `/say Message` - Envoyer un message à tous
|
|
||||||
- `/tp @p @s` - Tp un joueur
|
|
||||||
- `/give @p diamond 64` - Donner des items
|
|
||||||
- `/weather clear` - Changer la météo
|
|
||||||
- `/time set day` - Régler l'heure
|
|
||||||
- `/difficulty 2` - Changer la difficulté
|
|
||||||
|
|
||||||
## 📞 Support
|
|
||||||
|
|
||||||
Pour les problèmes:
|
|
||||||
1. Vérifiez la configuration du .env
|
|
||||||
2. Vérifiez les logs du backend
|
|
||||||
3. Testez RCON avec un client externe
|
|
||||||
4. Vérifiez les permissions sur les fichiers du serveur
|
|
||||||
|
|
||||||
## 🔄 Mises à Jour
|
|
||||||
|
|
||||||
L'interface se met à jour automatiquement. Pour mettre à jour les dépendances:
|
|
||||||
```bash
|
|
||||||
cd backend
|
|
||||||
npm update
|
|
||||||
```
|
|
||||||
|
|
||||||
## 📄 License
|
|
||||||
|
|
||||||
MIT - Libre d'utilisation
|
|
||||||
|
|||||||
@@ -76,4 +76,43 @@ router.post('/update', isAuthenticated, async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/settings', isAuthenticated, async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { key, value } = req.body;
|
||||||
|
|
||||||
|
if (!key || value === undefined) {
|
||||||
|
return res.status(400).json({ error: 'Données manquantes' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const serverPropsFile = path.join(SERVER_DIR, 'server.properties');
|
||||||
|
let content = await fs.readFile(serverPropsFile, 'utf-8');
|
||||||
|
const lines = content.split('\n');
|
||||||
|
|
||||||
|
let found = false;
|
||||||
|
const newContent = lines.map(line => {
|
||||||
|
if (line.trim() && !line.startsWith('#')) {
|
||||||
|
const [lineKey] = line.split('=');
|
||||||
|
if (lineKey.trim() === key) {
|
||||||
|
found = true;
|
||||||
|
return `${key}=${value}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return line;
|
||||||
|
}).join('\n');
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
content = newContent + '\n' + key + '=' + value;
|
||||||
|
} else {
|
||||||
|
content = newContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
await fs.writeFile(serverPropsFile, content, 'utf-8');
|
||||||
|
res.json({ message: 'Paramètre mis à jour' });
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur modification paramètre:', error);
|
||||||
|
res.status(500).json({ error: 'Erreur serveur' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
version: "3.8"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
@@ -15,7 +13,7 @@ services:
|
|||||||
RCON_PORT: 25575
|
RCON_PORT: 25575
|
||||||
SESSION_SECRET: change-this-in-production
|
SESSION_SECRET: change-this-in-production
|
||||||
volumes:
|
volumes:
|
||||||
- /home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red:/mc-server:ro
|
- /home/innotex/Documents/Projet/Serveur NationsGlory/NationsGlory_ServeurBuild_Red:/mc-server
|
||||||
- web-admin:/mc-server/.web-admin
|
- web-admin:/mc-server/.web-admin
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
network_mode: host
|
network_mode: host
|
||||||
|
|||||||
@@ -290,9 +290,10 @@ function getDashboardHTML() {
|
|||||||
<div class="section-card">
|
<div class="section-card">
|
||||||
<h2>🎮 Contrôle du Serveur</h2>
|
<h2>🎮 Contrôle du Serveur</h2>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn-success" onclick="restartServer()">🔄 Redémarrer</button>
|
|
||||||
<button class="btn-primary" onclick="saveServer()">💾 Sauvegarder</button>
|
<button class="btn-primary" onclick="saveServer()">💾 Sauvegarder</button>
|
||||||
<button class="btn-warning" onclick="openChangeRconPasswordModal()">🔐 Changer RCON</button>
|
<button class="btn-warning" onclick="openChangeRconPasswordModal()">🔐 Changer RCON</button>
|
||||||
|
<button class="btn-danger" id="cancelRestartBtn" style="display: none;" onclick="cancelRestart()">❌ Annuler Redémarrage</button>
|
||||||
|
<button class="btn-danger" id="cancelShutdownBtnDash" style="display: none;" onclick="cancelShutdown()">❌ Annuler Arrêt</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -303,7 +304,7 @@ function getDashboardHTML() {
|
|||||||
</div>
|
</div>
|
||||||
<div class="grid-card">
|
<div class="grid-card">
|
||||||
<h3>Joueurs Connectés</h3>
|
<h3>Joueurs Connectés</h3>
|
||||||
<p class="value" id="playerCount">--</p>
|
<p class="value" id="playerCount">0/20</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid-card">
|
<div class="grid-card">
|
||||||
<h3>Version Forge</h3>
|
<h3>Version Forge</h3>
|
||||||
@@ -324,6 +325,9 @@ function getDashboardHTML() {
|
|||||||
|
|
||||||
async function loadDashboardData() {
|
async function loadDashboardData() {
|
||||||
try {
|
try {
|
||||||
|
// Charger les joueurs en ligne
|
||||||
|
await window.loadOnlinePlayers();
|
||||||
|
|
||||||
const response = await fetch(`${API_URL}/server`, {
|
const response = await fetch(`${API_URL}/server`, {
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
});
|
});
|
||||||
@@ -340,6 +344,27 @@ async function loadDashboardData() {
|
|||||||
<tr><td><strong>Max Joueurs</strong></td><td>${data.properties['max-players'] || '20'}</td></tr>
|
<tr><td><strong>Max Joueurs</strong></td><td>${data.properties['max-players'] || '20'}</td></tr>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mettre à jour le nombre de joueurs
|
||||||
|
const onlineResponse = await fetch(`${API_URL}/rcon/command`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify({ command: 'list' })
|
||||||
|
});
|
||||||
|
|
||||||
|
if (onlineResponse.ok) {
|
||||||
|
const rconData = await onlineResponse.json();
|
||||||
|
const output = rconData.response || '';
|
||||||
|
const cleanOutput = output.replace(/§[0-9a-fk-or]/gi, '');
|
||||||
|
const match = cleanOutput.match(/There are (\d+) out of maximum (\d+) players online/i);
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
const onlineCount = parseInt(match[1]);
|
||||||
|
const maxPlayers = parseInt(match[2]);
|
||||||
|
document.getElementById('playerCount').textContent = `${onlineCount}/${maxPlayers}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Erreur chargement dashboard:', e);
|
console.error('Erreur chargement dashboard:', e);
|
||||||
}
|
}
|
||||||
@@ -351,10 +376,21 @@ function getConsoleHTML() {
|
|||||||
<div class="section-card">
|
<div class="section-card">
|
||||||
<h2>⌨️ Console RCON</h2>
|
<h2>⌨️ Console RCON</h2>
|
||||||
<p style="margin-bottom: 15px; color: #666;">Exécutez des commandes directement sur le serveur</p>
|
<p style="margin-bottom: 15px; color: #666;">Exécutez des commandes directement sur le serveur</p>
|
||||||
<div class="console-output" id="consoleOutput"></div>
|
<div style="background: #1e1e1e; border-radius: 8px; padding: 15px; margin-bottom: 15px; font-family: 'Courier New', monospace; border: 1px solid #333;">
|
||||||
<div class="console-input">
|
<div id="consoleOutput" style="color: #0f0; min-height: 300px; max-height: 400px; overflow-y: auto; margin-bottom: 15px; line-height: 1.5; font-size: 13px; white-space: pre-wrap; word-wrap: break-word;"></div>
|
||||||
<input type="text" id="commandInput" placeholder="Entrez une commande..." onkeypress="if(event.key==='Enter') sendRconCommand();">
|
<div style="display: flex; gap: 5px;">
|
||||||
<button class="btn-primary" onclick="sendRconCommand()">Envoyer</button>
|
<span style="color: #0f0;">admin@nationsglory:~$</span>
|
||||||
|
<input type="text" id="commandInput" placeholder="" style="background: #1e1e1e; color: #0f0; border: none; outline: none; flex: 1; font-family: 'Courier New', monospace; font-size: 13px;" onkeypress="if(event.key==='Enter') sendRconCommand();">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3 style="margin-top: 30px; margin-bottom: 15px;"><3E>️ Actions Rapides</h3>
|
||||||
|
<div class="btn-group" style="margin-bottom: 15px; flex-wrap: wrap; gap: 10px;">
|
||||||
|
<button class="btn-primary" onclick="openSayModal()">💬 Message Chat</button>
|
||||||
|
<button class="btn-success" onclick="openRestartModal()">🔄 Redémarrer</button>
|
||||||
|
<button class="btn-warning" onclick="openShutdownModal()" style="background: #ff9800;">⏹️ Arrêter Serveur</button>
|
||||||
|
<button class="btn-danger" onclick="cancelRestart()" id="cancelRestartBtn" style="display: none;">❌ Annuler Redémarrage</button>
|
||||||
|
<button class="btn-danger" onclick="cancelShutdown()" id="cancelShutdownBtn" style="display: none;">❌ Annuler Arrêt</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 style="margin-top: 30px; margin-bottom: 15px;">📜 Historique des Commandes</h3>
|
<h3 style="margin-top: 30px; margin-bottom: 15px;">📜 Historique des Commandes</h3>
|
||||||
@@ -365,6 +401,58 @@ function getConsoleHTML() {
|
|||||||
</div>
|
</div>
|
||||||
<div id="historyContainer" style="max-height: 400px; overflow-y: auto; background: #f8f9fa; border-radius: 5px; padding: 15px; border: 1px solid #ddd;"></div>
|
<div id="historyContainer" style="max-height: 400px; overflow-y: auto; background: #f8f9fa; border-radius: 5px; padding: 15px; border: 1px solid #ddd;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal Message Chat -->
|
||||||
|
<div id="sayModal" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center;">
|
||||||
|
<div style="background: white; padding: 30px; border-radius: 8px; width: 90%; max-width: 500px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
|
||||||
|
<h3 style="margin-top: 0; margin-bottom: 20px;">💬 Envoyer un Message</h3>
|
||||||
|
<textarea id="sayInput" placeholder="Entrez votre message..." style="width: 100%; height: 100px; padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-family: Arial, sans-serif; resize: vertical; box-sizing: border-box;"></textarea>
|
||||||
|
<div style="margin-top: 15px; display: flex; gap: 10px; justify-content: flex-end;">
|
||||||
|
<button class="btn-secondary" onclick="document.getElementById('sayModal').style.display='none'">Annuler</button>
|
||||||
|
<button class="btn-primary" onclick="sendSayCommand()">Envoyer</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal Arrêt Serveur -->
|
||||||
|
<div id="shutdownModal" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center;">
|
||||||
|
<div style="background: white; padding: 30px; border-radius: 8px; width: 90%; max-width: 500px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
|
||||||
|
<h3 style="margin-top: 0; margin-bottom: 20px;">⏹️ Arrêter le Serveur</h3>
|
||||||
|
<div style="margin-bottom: 20px;">
|
||||||
|
<label style="display: block; margin-bottom: 10px; font-weight: bold;">Cooldown avant arrêt (secondes):</label>
|
||||||
|
<input type="number" id="shutdownCooldown" value="60" min="10" max="600" style="width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box;">
|
||||||
|
</div>
|
||||||
|
<div style="margin-bottom: 20px;">
|
||||||
|
<label style="display: block; margin-bottom: 10px; font-weight: bold;">Message d'avertissement:</label>
|
||||||
|
<textarea id="shutdownMessage" placeholder="Message à envoyer aux joueurs..." style="width: 100%; height: 80px; padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-family: Arial, sans-serif; resize: vertical; box-sizing: border-box;">Le serveur redémarre dans {cooldown} secondes!</textarea>
|
||||||
|
</div>
|
||||||
|
<p style="color: #ff9800; background: #fff3e0; padding: 10px; border-radius: 4px; margin-bottom: 15px; font-size: 13px;">⚠️ Un message d'avertissement sera envoyé tous les 10 secondes</p>
|
||||||
|
<div style="display: flex; gap: 10px; justify-content: flex-end;">
|
||||||
|
<button class="btn-secondary" onclick="document.getElementById('shutdownModal').style.display='none'">Annuler</button>
|
||||||
|
<button class="btn-danger" style="background: #dc3545;" onclick="shutdownServer()">Confirmer l'Arrêt</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal Redémarrage Serveur -->
|
||||||
|
<div id="restartModal" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center;">
|
||||||
|
<div style="background: white; padding: 30px; border-radius: 8px; width: 90%; max-width: 500px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
|
||||||
|
<h3 style="margin-top: 0; margin-bottom: 20px;">🔄 Redémarrer le Serveur</h3>
|
||||||
|
<div style="margin-bottom: 20px;">
|
||||||
|
<label style="display: block; margin-bottom: 10px; font-weight: bold;">Cooldown avant redémarrage (secondes):</label>
|
||||||
|
<input type="number" id="restartCooldown" value="60" min="10" max="600" style="width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box;">
|
||||||
|
</div>
|
||||||
|
<div style="margin-bottom: 20px;">
|
||||||
|
<label style="display: block; margin-bottom: 10px; font-weight: bold;">Message d'avertissement:</label>
|
||||||
|
<textarea id="restartMessage" placeholder="Message à envoyer aux joueurs..." style="width: 100%; height: 80px; padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-family: Arial, sans-serif; resize: vertical; box-sizing: border-box;">Le serveur redémarre dans {cooldown} secondes!</textarea>
|
||||||
|
</div>
|
||||||
|
<p style="color: #2196F3; background: #e3f2fd; padding: 10px; border-radius: 4px; margin-bottom: 15px; font-size: 13px;">ℹ️ Un message d'avertissement sera envoyé tous les 10 secondes</p>
|
||||||
|
<div style="display: flex; gap: 10px; justify-content: flex-end;">
|
||||||
|
<button class="btn-secondary" onclick="document.getElementById('restartModal').style.display='none'">Annuler</button>
|
||||||
|
<button class="btn-success" onclick="restartServer()">Confirmer le Redémarrage</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,7 +531,7 @@ async function sendRconCommand() {
|
|||||||
if (!command) return;
|
if (!command) return;
|
||||||
|
|
||||||
const output = document.getElementById('consoleOutput');
|
const output = document.getElementById('consoleOutput');
|
||||||
output.innerHTML += `<div style="color: var(--primary); margin-bottom: 5px;">$ ${command}</div>`;
|
output.textContent += `admin@nationsglory:~$ ${command}\n`;
|
||||||
commandInput.value = '';
|
commandInput.value = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -457,22 +545,264 @@ async function sendRconCommand() {
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
output.innerHTML += `<div style="color: #333; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid #eee;">${data.response || '(pas de réponse)'}</div>`;
|
const responseText = data.response || '(pas de réponse)';
|
||||||
|
output.textContent += `${responseText}\n`;
|
||||||
showMessage('Commande exécutée ✓', 'success', 'dashboardMessage');
|
showMessage('Commande exécutée ✓', 'success', 'dashboardMessage');
|
||||||
loadConsoleData(); // Rafraîchir l'historique
|
loadConsoleData(); // Rafraîchir l'historique
|
||||||
} else {
|
} else {
|
||||||
output.innerHTML += `<div style="color: #dc3545; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid #eee;">Erreur: ${data.error}</div>`;
|
output.textContent += `Erreur: ${data.error}\n`;
|
||||||
showMessage(data.error, 'error', 'dashboardMessage');
|
showMessage(data.error, 'error', 'dashboardMessage');
|
||||||
}
|
}
|
||||||
|
|
||||||
output.scrollTop = output.scrollHeight;
|
output.scrollTop = output.scrollHeight;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Erreur envoi commande:', e);
|
console.error('Erreur envoi commande:', e);
|
||||||
output.innerHTML += `<div style="color: #dc3545; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid #eee;">Erreur serveur: ${e.message}</div>`;
|
output.textContent += `Erreur serveur: ${e.message}\n`;
|
||||||
showMessage('Erreur serveur', 'error', 'dashboardMessage');
|
showMessage('Erreur serveur', 'error', 'dashboardMessage');
|
||||||
|
output.scrollTop = output.scrollHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Variables globales pour gérer l'arrêt du serveur
|
||||||
|
let shutdownInProgress = false;
|
||||||
|
let shutdownCancelToken = null;
|
||||||
|
|
||||||
|
window.openSayModal = function() {
|
||||||
|
document.getElementById('sayModal').style.display = 'flex';
|
||||||
|
};
|
||||||
|
|
||||||
|
window.sendSayCommand = async function() {
|
||||||
|
const message = document.getElementById('sayInput').value.trim();
|
||||||
|
if (!message) {
|
||||||
|
alert('Entrez un message');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${API_URL}/rcon/command`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify({ command: `say ${message}` })
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
showMessage('Message envoyé ✓', 'success', 'dashboardMessage');
|
||||||
|
document.getElementById('sayInput').value = '';
|
||||||
|
document.getElementById('sayModal').style.display = 'none';
|
||||||
|
loadConsoleData();
|
||||||
|
} else {
|
||||||
|
showMessage('Erreur lors de l\'envoi du message', 'error', 'dashboardMessage');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Erreur envoi message:', e);
|
||||||
|
showMessage('Erreur serveur', 'error', 'dashboardMessage');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.openShutdownModal = function() {
|
||||||
|
document.getElementById('shutdownModal').style.display = 'flex';
|
||||||
|
};
|
||||||
|
|
||||||
|
window.shutdownServer = async function() {
|
||||||
|
const cooldown = parseInt(document.getElementById('shutdownCooldown').value);
|
||||||
|
const message = document.getElementById('shutdownMessage').value.trim();
|
||||||
|
|
||||||
|
if (cooldown < 10 || cooldown > 600) {
|
||||||
|
alert('Le cooldown doit être entre 10 et 600 secondes');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!message) {
|
||||||
|
alert('Entrez un message d\'avertissement');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!confirm(`Êtes-vous sûr de vouloir arrêter le serveur dans ${cooldown} secondes?`)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
shutdownInProgress = true;
|
||||||
|
shutdownCancelToken = {};
|
||||||
|
document.getElementById('cancelShutdownBtn').style.display = 'block';
|
||||||
|
document.getElementById('shutdownModal').style.display = 'none';
|
||||||
|
|
||||||
|
showMessage(`⏳ Arrêt du serveur dans ${cooldown} secondes...`, 'warning', 'dashboardMessage');
|
||||||
|
|
||||||
|
let secondsRemaining = cooldown;
|
||||||
|
|
||||||
|
while (secondsRemaining > 0 && shutdownInProgress && shutdownCancelToken) {
|
||||||
|
if (secondsRemaining % 10 === 0 || secondsRemaining <= 10) {
|
||||||
|
// Envoyer un avertissement tous les 10 secondes (ou chaque seconde dans les 10 dernières)
|
||||||
|
const warningMsg = message.replace('{cooldown}', secondsRemaining);
|
||||||
|
await fetch(`${API_URL}/rcon/command`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify({ command: `say ${warningMsg}` })
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
secondsRemaining--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!shutdownInProgress || !shutdownCancelToken) {
|
||||||
|
// Envoyer un message dans le chat pour informer de l'annulation
|
||||||
|
await fetch(`${API_URL}/rcon/command`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify({ command: 'say Arrêt du serveur annulé!' })
|
||||||
|
}).catch(() => {});
|
||||||
|
|
||||||
|
showMessage('❌ Arrêt annulé', 'warning', 'dashboardMessage');
|
||||||
|
document.getElementById('cancelShutdownBtn').style.display = 'none';
|
||||||
|
document.getElementById('cancelShutdownBtnDash').style.display = 'none';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Envoyer la commande d'arrêt
|
||||||
|
const response = await fetch(`${API_URL}/rcon/command`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify({ command: 'stop' })
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
showMessage('✓ Serveur arrêté', 'success', 'dashboardMessage');
|
||||||
|
} else {
|
||||||
|
showMessage('Erreur lors de l\'arrêt du serveur', 'error', 'dashboardMessage');
|
||||||
|
}
|
||||||
|
|
||||||
|
shutdownInProgress = false;
|
||||||
|
shutdownCancelToken = null;
|
||||||
|
document.getElementById('cancelShutdownBtn').style.display = 'none';
|
||||||
|
document.getElementById('cancelShutdownBtnDash').style.display = 'none';
|
||||||
|
loadConsoleData();
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Erreur arrêt serveur:', e);
|
||||||
|
showMessage('Erreur serveur', 'error', 'dashboardMessage');
|
||||||
|
shutdownInProgress = false;
|
||||||
|
shutdownCancelToken = null;
|
||||||
|
document.getElementById('cancelShutdownBtn').style.display = 'none';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.cancelShutdown = function() {
|
||||||
|
if (shutdownInProgress) {
|
||||||
|
shutdownInProgress = false;
|
||||||
|
shutdownCancelToken = null;
|
||||||
|
document.getElementById('cancelShutdownBtn').style.display = 'none';
|
||||||
|
document.getElementById('cancelShutdownBtnDash').style.display = 'none';
|
||||||
|
showMessage('❌ Arrêt annulé', 'warning', 'dashboardMessage');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Variables globales pour gérer le redémarrage du serveur
|
||||||
|
let restartInProgress = false;
|
||||||
|
let restartCancelToken = null;
|
||||||
|
|
||||||
|
window.openRestartModal = function() {
|
||||||
|
document.getElementById('restartModal').style.display = 'flex';
|
||||||
|
};
|
||||||
|
|
||||||
|
window.restartServer = async function() {
|
||||||
|
const cooldown = parseInt(document.getElementById('restartCooldown').value);
|
||||||
|
const message = document.getElementById('restartMessage').value.trim();
|
||||||
|
|
||||||
|
if (cooldown < 10 || cooldown > 600) {
|
||||||
|
alert('Le cooldown doit être entre 10 et 600 secondes');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!message) {
|
||||||
|
alert('Entrez un message d\'avertissement');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!confirm(`Êtes-vous sûr de vouloir redémarrer le serveur dans ${cooldown} secondes?`)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
restartInProgress = true;
|
||||||
|
restartCancelToken = {};
|
||||||
|
document.getElementById('cancelRestartBtn').style.display = 'block';
|
||||||
|
document.getElementById('restartModal').style.display = 'none';
|
||||||
|
|
||||||
|
showMessage(`⏳ Redémarrage du serveur dans ${cooldown} secondes...`, 'warning', 'dashboardMessage');
|
||||||
|
|
||||||
|
let secondsRemaining = cooldown;
|
||||||
|
|
||||||
|
while (secondsRemaining > 0 && restartInProgress && restartCancelToken) {
|
||||||
|
if (secondsRemaining % 10 === 0 || secondsRemaining <= 10) {
|
||||||
|
// Envoyer un avertissement tous les 10 secondes (ou chaque seconde dans les 10 dernières)
|
||||||
|
const warningMsg = message.replace('{cooldown}', secondsRemaining);
|
||||||
|
await fetch(`${API_URL}/rcon/command`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify({ command: `say ${warningMsg}` })
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
secondsRemaining--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!restartInProgress || !restartCancelToken) {
|
||||||
|
// Envoyer un message dans le chat pour informer de l'annulation
|
||||||
|
await fetch(`${API_URL}/rcon/command`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify({ command: 'say Redémarrage du serveur annulé!' })
|
||||||
|
}).catch(() => {});
|
||||||
|
|
||||||
|
showMessage('❌ Redémarrage annulé', 'warning', 'dashboardMessage');
|
||||||
|
document.getElementById('cancelRestartBtn').style.display = 'none';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Envoyer la commande de redémarrage
|
||||||
|
const response = await fetch(`${API_URL}/rcon/command`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify({ command: 'stop' })
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
showMessage('✓ Serveur redémarré', 'success', 'dashboardMessage');
|
||||||
|
} else {
|
||||||
|
showMessage('Erreur lors du redémarrage du serveur', 'error', 'dashboardMessage');
|
||||||
|
}
|
||||||
|
|
||||||
|
restartInProgress = false;
|
||||||
|
restartCancelToken = null;
|
||||||
|
document.getElementById('cancelRestartBtn').style.display = 'none';
|
||||||
|
loadDashboardData();
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Erreur redémarrage serveur:', e);
|
||||||
|
showMessage('Erreur serveur', 'error', 'dashboardMessage');
|
||||||
|
restartInProgress = false;
|
||||||
|
restartCancelToken = null;
|
||||||
|
document.getElementById('cancelRestartBtn').style.display = 'none';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.cancelRestart = function() {
|
||||||
|
if (restartInProgress) {
|
||||||
|
restartInProgress = false;
|
||||||
|
restartCancelToken = null;
|
||||||
|
document.getElementById('cancelRestartBtn').style.display = 'none';
|
||||||
|
showMessage('❌ Redémarrage annulé', 'warning', 'dashboardMessage');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// ========== LOGS ==========
|
// ========== LOGS ==========
|
||||||
function getLogsHTML() {
|
function getLogsHTML() {
|
||||||
return `
|
return `
|
||||||
@@ -934,15 +1264,19 @@ function getSettingsHTML() {
|
|||||||
return `
|
return `
|
||||||
<div class="section-card">
|
<div class="section-card">
|
||||||
<h2>⚙️ Paramètres du Serveur</h2>
|
<h2>⚙️ Paramètres du Serveur</h2>
|
||||||
<table id="settingsTable">
|
<p style="margin-bottom: 15px; color: #666;">Modifiez les paramètres du serveur en temps réel</p>
|
||||||
|
<div style="margin-bottom: 15px;">
|
||||||
|
<button class="btn-secondary" onclick="loadSettingsData()">🔄 Rafraîchir</button>
|
||||||
|
</div>
|
||||||
|
<table id="settingsTable" style="width: 100%;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Paramètre</th>
|
<th style="text-align: left; width: 30%; padding: 10px; border-bottom: 2px solid #ddd;">Paramètre</th>
|
||||||
<th>Valeur</th>
|
<th style="text-align: left; width: 70%; padding: 10px; border-bottom: 2px solid #ddd;">Valeur</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr><td colspan="2" style="text-align: center;">Chargement...</td></tr>
|
<tr><td colspan="2" style="text-align: center; padding: 20px;">Chargement...</td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -961,18 +1295,57 @@ async function loadSettingsData() {
|
|||||||
|
|
||||||
if (data.properties) {
|
if (data.properties) {
|
||||||
const keys = Object.keys(data.properties).sort();
|
const keys = Object.keys(data.properties).sort();
|
||||||
tbody.innerHTML = keys.map(k => `
|
tbody.innerHTML = keys.map(k => {
|
||||||
<tr>
|
const isPassword = k.toLowerCase().includes('password') || k.toLowerCase().includes('rcon');
|
||||||
<td><strong>${k}</strong></td>
|
const inputType = isPassword ? 'password' : 'text';
|
||||||
<td>${escapeHtml(data.properties[k])}</td>
|
const value = data.properties[k];
|
||||||
</tr>
|
|
||||||
`).join('');
|
return `
|
||||||
|
<tr style="border-bottom: 1px solid #eee;">
|
||||||
|
<td style="padding: 12px; font-weight: bold;">${k}</td>
|
||||||
|
<td style="padding: 12px;">
|
||||||
|
<input
|
||||||
|
type="${inputType}"
|
||||||
|
value="${escapeHtml(value)}"
|
||||||
|
data-key="${k}"
|
||||||
|
onchange="updateSetting(this)"
|
||||||
|
style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; font-family: monospace;"
|
||||||
|
>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
`;
|
||||||
|
}).join('');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Erreur paramètres:', e);
|
console.error('Erreur paramètres:', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updateSetting(input) {
|
||||||
|
const key = input.getAttribute('data-key');
|
||||||
|
const newValue = input.value;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${API_URL}/server/settings`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify({ key, value: newValue })
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
showMessage(`✓ Paramètre ${key} modifié`, 'success', 'dashboardMessage');
|
||||||
|
} else {
|
||||||
|
const error = await response.json();
|
||||||
|
showMessage(`Erreur: ${error.error}`, 'error', 'dashboardMessage');
|
||||||
|
await loadSettingsData(); // Recharger pour annuler la modification
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Erreur modification paramètre:', e);
|
||||||
|
showMessage('Erreur serveur', 'error', 'dashboardMessage');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ========== ACTIONS ==========
|
// ========== ACTIONS ==========
|
||||||
|
|
||||||
async function restartServer() {
|
async function restartServer() {
|
||||||
|
|||||||
41
install.sh
41
install.sh
@@ -1,41 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Configuration pour l'interface web du serveur Minecraft NationsGlory
|
|
||||||
# ====================================================================
|
|
||||||
|
|
||||||
echo "🚀 Installation de l'interface web NationsGlory Admin..."
|
|
||||||
|
|
||||||
# Vérifier que Node.js est installé
|
|
||||||
if ! command -v node &> /dev/null; then
|
|
||||||
echo "❌ Node.js n'est pas installé. Veuillez l'installer d'abord."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "✓ Node.js détecté: $(node --version)"
|
|
||||||
|
|
||||||
# Créer le fichier .env
|
|
||||||
if [ ! -f backend/.env ]; then
|
|
||||||
echo "Création du fichier .env..."
|
|
||||||
cp backend/.env.example backend/.env
|
|
||||||
echo "✓ Fichier .env créé. À personnaliser dans backend/.env"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Installer les dépendances du backend
|
|
||||||
echo ""
|
|
||||||
echo "📦 Installation des dépendances backend..."
|
|
||||||
cd backend
|
|
||||||
npm install
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "✅ Installation terminée!"
|
|
||||||
echo ""
|
|
||||||
echo "📝 Prochaines étapes:"
|
|
||||||
echo "1. Modifiez backend/.env avec la bonne configuration"
|
|
||||||
echo "2. Lancez le serveur: cd backend && npm start"
|
|
||||||
echo "3. Accédez à l'interface: http://localhost:4001"
|
|
||||||
echo ""
|
|
||||||
echo "ℹ️ IMPORTANT: Activez RCON dans le server.properties du serveur MC:"
|
|
||||||
echo " - enable-rcon=true"
|
|
||||||
echo " - rcon.port=25575"
|
|
||||||
echo " - rcon.password=votre_mdp"
|
|
||||||
21
setup.sh
21
setup.sh
@@ -1,21 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Rendre les scripts exécutables
|
|
||||||
chmod +x install.sh
|
|
||||||
chmod +x start.sh
|
|
||||||
|
|
||||||
# Créer les dossiers de data s'ils n'existent pas
|
|
||||||
mkdir -p backend/data
|
|
||||||
|
|
||||||
echo "✅ Préparation complète!"
|
|
||||||
echo ""
|
|
||||||
echo "📖 Documentation:"
|
|
||||||
echo " - README.md - Vue d'ensemble"
|
|
||||||
echo " - CONFIGURATION.md - Guide de configuration détaillé"
|
|
||||||
echo " - DEPLOYMENT.md - Déploiement en production"
|
|
||||||
echo ""
|
|
||||||
echo "🚀 Pour démarrer:"
|
|
||||||
echo " 1. ./install.sh"
|
|
||||||
echo " 2. Éditer backend/.env"
|
|
||||||
echo " 3. ./start.sh"
|
|
||||||
echo ""
|
|
||||||
39
start.sh
39
start.sh
@@ -1,39 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Script de démarrage pour le serveur et l'interface web
|
|
||||||
# =========================================================
|
|
||||||
|
|
||||||
# Couleurs
|
|
||||||
RED='\033[0;31m'
|
|
||||||
GREEN='\033[0;32m'
|
|
||||||
YELLOW='\033[1;33m'
|
|
||||||
NC='\033[0m' # No Color
|
|
||||||
|
|
||||||
echo -e "${GREEN}🎮 NationsGlory Admin Panel - Démarrage${NC}"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Vérifier que le backend existe
|
|
||||||
if [ ! -d "backend" ]; then
|
|
||||||
echo -e "${RED}❌ Dossier backend non trouvé!${NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Vérifier le fichier .env
|
|
||||||
if [ ! -f "backend/.env" ]; then
|
|
||||||
echo -e "${RED}❌ Fichier backend/.env non trouvé!${NC}"
|
|
||||||
echo -e "${YELLOW}Copiez d'abord: cp backend/.env.example backend/.env${NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Charger les variables d'environnement
|
|
||||||
source backend/.env
|
|
||||||
|
|
||||||
echo -e "${GREEN}✓ Variables d'environnement chargées${NC}"
|
|
||||||
echo " - Port: $PORT"
|
|
||||||
echo " - Serveur MC: $SERVER_DIR"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Démarrer le backend
|
|
||||||
echo -e "${YELLOW}⏳ Démarrage du backend...${NC}"
|
|
||||||
cd backend
|
|
||||||
npm start
|
|
||||||
Reference in New Issue
Block a user