Date : 10-12-2025 Statut : En attente de validation
Créer une suite de scripts shell permettant de tout gérer de manière autonome :
/mnt/stock_36to/data/docker/scripts/
├── deploy/ # Scripts de déploiement
│ ├── deploy.sh # Script principal : deploy.sh hellocar prod
│ ├── deploy-service.sh # Déploie un service : deploy-service.sh hellocar api prod
│ └── rollback.sh # Rollback : rollback.sh hellocar api prod
│
├── nginx/ # Scripts Nginx (existants + nouveaux)
│ ├── generate-config.sh # Génère une config Nginx
│ ├── deploy-config.sh # Déploie sur le serveur Nginx
│ ├── list-configs.sh # Liste toutes les configs actives
│ └── disable-config.sh # Désactive une config
│
├── dns/ # Scripts DNS o2switch
│ ├── list-records.sh # Liste tous les enregistrements
│ ├── list-wildcards.sh # Liste les wildcards avec infos
│ ├── add-wildcard.sh # Ajoute un wildcard : add-wildcard.sh 33802
│ ├── update-wildcard.sh # Met à jour un wildcard
│ ├── delete-record.sh # Supprime un enregistrement
│ └── check-ssl-expiry.sh # Vérifie expiration SSL
│
├── docker/ # Scripts Docker
│ ├── list-containers.sh # Liste les containers
│ ├── logs.sh # Voir les logs : logs.sh hellocar-api-prod
│ ├── restart.sh # Redémarre : restart.sh hellocar-api-prod
│ ├── stop.sh # Stop un container
│ └── cleanup.sh # Nettoie images/volumes non utilisés
│
├── status/ # Scripts de monitoring
│ ├── health.sh # État de santé global
│ ├── check-urls.sh # Test toutes les URLs
│ └── disk-usage.sh # Espace disque
│
└── lib/ # Fonctions partagées
├── config.sh # Variables globales (IPs, credentials)
├── colors.sh # Couleurs pour output
└── utils.sh # Fonctions utilitaires
deploy.sh# Déployer tout HelloCar en prod
./deploy.sh hellocar prod
# Déployer seulement l'API
./deploy.sh hellocar prod api
# Déployer API et Admin
./deploy.sh hellocar prod api,admin
# Déployer R7 en dev
./deploy.sh r7 dev
Workflow :
list-wildcards.sh./list-wildcards.sh
# Output :
# ┌─────────────────────────────┬─────────────────┬──────────┐
# │ Wildcard │ IP │ TTL │
# ├─────────────────────────────┼─────────────────┼──────────┤
# │ *.33800.nowhere84.com │ 82.65.119.221 │ 14400 │
# │ *.33801.nowhere84.com │ 82.65.119.221 │ 14400 │
# └─────────────────────────────┴─────────────────┴──────────┘
add-wildcard.sh# Ajouter un wildcard pour un nouveau sous-domaine
./add-wildcard.sh 33802
# Créera :
# - *.33802.nowhere84.com → 82.65.119.221
# - 33802.nowhere84.com → 82.65.119.221
check-ssl-expiry.sh./check-ssl-expiry.sh
# Output :
# Certificat *.33800.nowhere84.com : expire dans 45 jours (2025-01-25)
logs.sh# Voir les logs d'un container
./logs.sh hellocar-api-prod
# Avec options
./logs.sh hellocar-api-prod --follow
./logs.sh hellocar-api-prod --tail 100
health.sh./health.sh
# Output :
# ┌───────────────────────┬────────┬────────┬─────────┐
# │ Container │ Status │ CPU │ Memory │
# ├───────────────────────┼────────┼────────┼─────────┤
# │ hellocar-api-prod │ 🟢 UP │ 2.1% │ 128MB │
# │ hellocar-public-prod │ 🟢 UP │ 1.5% │ 256MB │
# │ hellocar-admin-prod │ 🟢 UP │ 1.2% │ 245MB │
# └───────────────────────┴────────┴────────┴─────────┘
lib/config.sh# IPs des serveurs
PROD_DOCKER_HOST="192.168.1.11"
DEV_DOCKER_HOST="192.168.1.12"
NGINX_HOST="192.168.1.104"
# o2switch API
O2SWITCH_API_URL="https://yellow.o2switch.net:2083"
O2SWITCH_USERNAME="deas8499"
O2SWITCH_PASSWORD="d9fx-RNEz-xfK("
O2SWITCH_DOMAIN="nowhere84.com"
# GitHub
GITHUB_USER="gouroubleu"
GITHUB_TOKEN="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"
# Paths
SECRETS_PATH="/mnt/stock_36to/data/docker/secrets"
SCRIPTS_PATH="/mnt/stock_36to/data/docker/scripts"
# IP publique pour DNS
PUBLIC_IP="82.65.119.221"
# Projets connus
declare -A PROJECTS
PROJECTS[hellocar]="api:4510,public:4501,admin:4500"
PROJECTS[r7]="app:4600"
| Commande | Description |
|---|---|
deploy.sh hellocar prod |
Déploie tout HelloCar en prod |
deploy.sh hellocar prod api |
Déploie seulement l'API |
deploy.sh r7 dev |
Déploie R7 en dev |
logs.sh hellocar-api-prod |
Voir les logs |
health.sh |
État de tous les containers |
list-wildcards.sh |
Liste les wildcards DNS |
add-wildcard.sh 33802 |
Ajoute un wildcard |
check-urls.sh |
Test toutes les URLs |
À chaque connexion (local ou SSH), affichage automatique :
╔══════════════════════════════════════════════════════════════════╗
║ 🚀 PROD-PORTAINER - Toolbox ║
╠══════════════════════════════════════════════════════════════════╣
║ DÉPLOIEMENT ║
║ deploy hellocar prod Déploie tout HelloCar ║
║ deploy hellocar prod api Déploie seulement l'API ║
║ deploy r7 dev Déploie R7 en dev ║
║ ║
║ DOCKER ║
║ health État de tous les containers ║
║ logs <container> Voir les logs ║
║ restart <container> Redémarrer un container ║
║ ║
║ NGINX ║
║ nginx-list Liste les configs actives ║
║ nginx-deploy <file> Déploie une config ║
║ ║
║ DNS (o2switch) ║
║ dns-list Liste tous les enregistrements ║
║ dns-wildcards Liste les wildcards ║
║ dns-add-wildcard <prefix> Ajoute *.prefix.nowhere84.com ║
║ dns-ssl-check Vérifie expiration SSL ║
║ ║
║ INFOS ║
║ status Résumé complet du serveur ║
║ help Affiche ce menu ║
╚══════════════════════════════════════════════════════════════════╝
Projets déployés : hellocar (3 services) | r7 (1 service)
Dernière mise à jour : 10-12-2025
/mnt/stock_36to/data/docker/scripts/motd.sh qui génère ce message~/.bashrc pour l'afficher à la connexiondeploy → deploy.shhealth → health.shlogs → logs.shDis-moi si cette architecture te convient et on commence !