install.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. else
  2. echo -e "${GREEN}✅ Environnement virtuel existe déjà${NC}"
  3. fi
  4. # Étape 2 : Activation et installation des dépendances
  5. echo -e "\n${YELLOW}📦 Étape 2/5 : Installation des dépendances...${NC}"
  6. source venv/bin/activate
  7. pip install --upgrade pip
  8. pip install -r requirements.txt
  9. if [ $? -eq 0 ]; then
  10. echo -e "${GREEN}✅ Dépendances installées${NC}"
  11. else
  12. echo -e "${RED}❌ Erreur lors de l'installation des dépendances${NC}"
  13. exit 1
  14. fi
  15. # Étape 3 : Vérification du fichier .env
  16. echo -e "\n${YELLOW}🔐 Étape 3/5 : Vérification de la configuration...${NC}"
  17. if [ ! -f ".env" ]; then
  18. echo -e "${RED}❌ Fichier .env manquant !${NC}"
  19. echo "Copiez .env.example vers .env et configurez-le"
  20. exit 1
  21. else
  22. echo -e "${GREEN}✅ Fichier .env trouvé${NC}"
  23. fi
  24. # Étape 4 : Migrations
  25. echo -e "\n${YELLOW}🗄️ Étape 4/5 : Application des migrations...${NC}"
  26. python manage.py makemigrations
  27. python manage.py migrate
  28. if [ $? -eq 0 ]; then
  29. echo -e "${GREEN}✅ Migrations appliquées${NC}"
  30. else
  31. echo -e "${RED}❌ Erreur lors des migrations${NC}"
  32. exit 1
  33. fi
  34. # Étape 5 : Collecte des fichiers statiques (optionnel en dev)
  35. echo -e "\n${YELLOW}📁 Étape 5/5 : Fichiers statiques...${NC}"
  36. echo "Voulez-vous collecter les fichiers statiques ? (o/N)"
  37. read -r response
  38. if [[ "$response" =~ ^([oO][uU][iI]|[oO])$ ]]; then
  39. python manage.py collectstatic --noinput
  40. echo -e "${GREEN}✅ Fichiers statiques collectés${NC}"
  41. else
  42. echo -e "${YELLOW}⏭️ Fichiers statiques ignorés${NC}"
  43. fi
  44. echo -e "\n${GREEN}=============================================="
  45. echo "✅ Installation terminée avec succès !"
  46. echo "=============================================="
  47. echo -e "${NC}"
  48. echo "Pour démarrer le serveur :"
  49. echo " source venv/bin/activate"
  50. echo " python manage.py runserver"
  51. echo ""
  52. echo "Puis visitez : http://127.0.0.1:8000/blog/"