#!/bin/bash # WaouW v2.0 COMPLETE - Build script pour WSL # Création du package de déploiement depuis Windows/WSL set -euo pipefail # Colors GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' log() { echo -e "${GREEN}[INFO]${NC} $1" } error() { echo -e "${RED}[ERROR]${NC} $1" } success() { echo -e "${BLUE}[SUCCESS]${NC} $1" } clear echo "" echo "██╗ ██╗ █████╗ ██████╗ ██╗ ██╗██╗ ██╗" echo "██║ ██║██╔══██╗██╔═══██╗██║ ██║██║ ██║" echo "██║ █╗ ██║███████║██║ ██║██║ ██║██║ █╗ ██║" echo "██║███╗██║██╔══██║██║ ██║██║ ██║██║███╗██║" echo "╚███╔███╔╝██║ ██║╚██████╔╝╚██████╔╝╚███╔███╔╝" echo " ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══╝╚══╝ " echo "" echo " v2.0 COMPLETE - BUILD WSL" echo " Préparation package depuis WSL" echo "======================================" echo "" # Vérifier qu'on est dans le bon répertoire if [[ ! -f "../ARCHITECTURE.md" ]]; then error "Exécutez ce script depuis le dossier DEPLOY du projet WaouW" exit 1 fi log "Vérification des prérequis WSL..." # Vérifier si on est dans WSL if [[ ! -f /proc/version ]] || ! grep -q Microsoft /proc/version 2>/dev/null; then error "Ce script doit être exécuté depuis WSL (Windows Subsystem for Linux)" exit 1 fi # Vérifier zip if ! command -v zip &> /dev/null; then log "Installation de zip..." sudo apt-get update -qq sudo apt-get install -y zip fi success "Environnement WSL validé" echo "" log "Nettoyage des fichiers temporaires..." rm -f waouw-deploy.zip rm -rf waouw-deploy-temp log "Création du répertoire temporaire..." mkdir -p waouw-deploy-temp log "Copie des fichiers du projet..." # Aller au répertoire parent (racine du projet) cd .. # Copier les fichiers essentiels log "- Copie de la documentation..." cp ARCHITECTURE.md waouw-deploy-temp/ cp README.md waouw-deploy-temp/ cp GUIDE-UTILISATEUR-FINAL.md waouw-deploy-temp/ log "- Copie du dossier DEPLOY/..." cp -r DEPLOY waouw-deploy-temp/ log "- Copie du dossier BACKEND/..." cp -r BACKEND waouw-deploy-temp/ log "- Copie du dossier UI/..." cp -r UI waouw-deploy-temp/ log "- Copie du dossier DEVICE_AGENT/..." cp -r DEVICE_AGENT waouw-deploy-temp/ # Copier TESTS s'il existe if [[ -d "TESTS" ]]; then log "- Copie du dossier TESTS/..." cp -r TESTS waouw-deploy-temp/ fi log "Création du script d'installation principal..." # Créer le script d'installation principal cat > waouw-deploy-temp/install.sh << 'EOF' #!/bin/bash # WaouW v2.0 COMPLETE - Installation automatique sur Raspberry Pi # Script d'entrée principal set -euo pipefail echo "" echo "=== WaouW v2.0 COMPLETE - Installation Automatique ===" echo "" # Vérifier qu'on est sur le bon système if [[ ! -f /etc/os-release ]]; then echo "[ERREUR] Système non supporté (pas de /etc/os-release)" exit 1 fi # Aller dans le bon répertoire cd "$(dirname "$0")" echo "Démarrage de l'installation complète..." echo "Cela peut prendre 15-30 minutes selon votre connexion internet." echo "" # Rendre les scripts exécutables chmod +x DEPLOY/install-complete.sh chmod +x DEPLOY/install-from-package.sh # Lancer l'installation depuis le package ./DEPLOY/install-from-package.sh echo "" echo "🎉 Installation WaouW v2.0 COMPLETE terminée !" EOF chmod +x waouw-deploy-temp/install.sh log "Création du fichier README de déploiement..." cat > waouw-deploy-temp/README-DEPLOIEMENT.md << 'EOF' # WaouW v2.0 COMPLETE - Package de Déploiement ## 🚀 Installation Rapide sur Raspberry Pi ```bash # 1. Décompresser l'archive unzip waouw-deploy.zip cd waouw-deploy # 2. Lancer l'installation ./install.sh # 3. Attendre 15-30 minutes # 4. Accéder à l'interface # https://IP-DU-PI ou https://waouw.local ``` ## 🔐 Premier Accès - **URL** : `https://waouw.local` ou `https://[IP-DU-PI]` - **Login** : `admin` - **Password** : `admin` ⚠️ **CHANGEZ immédiatement ce mot de passe !** ## 🌐 Services Inclus | Service | URL | Description | |---------|-----|-------------| | **Interface principale** | `/` | Dashboard et gestion | | **Webmail** | `/webmail` | Roundcube | | **Cloud** | `/nextcloud` | Stockage personnel | | **Admin Email** | `/mailadmin` | Gestion comptes email | | **Sécurité** | `/security` | Fail2ban + monitoring | | **VPN** | `/vpn` | OpenVPN administration | | **Webmin** | `:10000` | Administration système | ## 📋 Prérequis - **Raspberry Pi 4** (4GB+ RAM recommandé) - **Carte SD** 32GB+ (Classe 10) - **Raspberry Pi OS Lite 64-bit** - **Connexion Internet** pour l'installation ## 🆘 Dépannage - **Logs** : `waouw logs` - **Status** : `waouw status` - **Redémarrer** : `waouw restart` Voir `GUIDE-UTILISATEUR-FINAL.md` pour plus de détails. EOF log "Nettoyage des fichiers inutiles..." # Nettoyer les fichiers temporaires et de développement find waouw-deploy-temp -name "*.pyc" -delete find waouw-deploy-temp -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true find waouw-deploy-temp -name ".git" -type d -exec rm -rf {} + 2>/dev/null || true find waouw-deploy-temp -name "node_modules" -type d -exec rm -rf {} + 2>/dev/null || true find waouw-deploy-temp -name ".vscode" -type d -exec rm -rf {} + 2>/dev/null || true log "Création de l'archive ZIP..." # Retourner dans DEPLOY pour créer l'archive cd DEPLOY zip -r waouw-deploy.zip waouw-deploy-temp/ -q # Calculer la taille ARCHIVE_SIZE=$(du -h waouw-deploy.zip | cut -f1) log "Nettoyage final..." rm -rf waouw-deploy-temp echo "" success "Package de déploiement créé avec succès !" echo "" echo "📦 Fichier : waouw-deploy.zip" echo "📏 Taille : $ARCHIVE_SIZE" echo "" echo "📍 Emplacement WSL :" echo " $(pwd)/waouw-deploy.zip" echo "" echo "📍 Emplacement Windows :" WINDOWS_PATH=$(wslpath -w "$(pwd)/waouw-deploy.zip") echo " $WINDOWS_PATH" echo "" echo "=== INSTRUCTIONS DE DÉPLOIEMENT ===" echo "" echo "1️⃣ Transférer vers Raspberry Pi :" echo " scp waouw-deploy.zip pi@[IP-PI]:~/" echo "" echo "2️⃣ Sur le Raspberry Pi :" echo " unzip waouw-deploy.zip" echo " cd waouw-deploy" echo " ./install.sh" echo "" echo "3️⃣ Accès après installation :" echo " https://[IP-PI] ou https://waouw.local" echo " Login: admin / admin (à changer !)" echo ""