| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #!/bin/bash
- # Script d'installation et de mise à jour
- echo "🚀 Installation et mise à jour du Blog Duhaz"
- echo "=============================================="
- # Couleurs pour le terminal
- RED='\033[0;31m'
- GREEN='\033[0;32m'
- YELLOW='\033[1;33m'
- NC='\033[0m' # No Color
- # Étape 1 : Création de l'environnement virtuel
- echo -e "\n${YELLOW}📦 Étape 1/5 : Création de l'environnement virtuel...${NC}"
- if [ ! -d "venv" ]; then
- python3 -m venv venv
- echo -e "${GREEN}✅ Environnement virtuel créé${NC}"
- else
- echo -e "${GREEN}✅ Environnement virtuel existe déjà${NC}"
- fi
- # Étape 2 : Activation et installation des dépendances
- echo -e "\n${YELLOW}📦 Étape 2/5 : Installation des dépendances...${NC}"
- source venv/bin/activate
- pip install --upgrade pip
- pip install -r requirements.txt
- if [ $? -eq 0 ]; then
- echo -e "${GREEN}✅ Dépendances installées${NC}"
- else
- echo -e "${RED}❌ Erreur lors de l'installation des dépendances${NC}"
- exit 1
- fi
- # Étape 3 : Vérification du fichier .env
- echo -e "\n${YELLOW}🔐 Étape 3/5 : Vérification de la configuration...${NC}"
- if [ ! -f ".env" ]; then
- echo -e "${RED}❌ Fichier .env manquant !${NC}"
- echo "Copiez .env.example vers .env et configurez-le"
- exit 1
- else
- echo -e "${GREEN}✅ Fichier .env trouvé${NC}"
- fi
- # Étape 4 : Migrations
- echo -e "\n${YELLOW}🗄️ Étape 4/5 : Application des migrations...${NC}"
- python manage.py makemigrations
- python manage.py migrate
- if [ $? -eq 0 ]; then
- echo -e "${GREEN}✅ Migrations appliquées${NC}"
- else
- echo -e "${RED}❌ Erreur lors des migrations${NC}"
- exit 1
- fi
- # Étape 5 : Collecte des fichiers statiques (optionnel en dev)
- echo -e "\n${YELLOW}📁 Étape 5/5 : Fichiers statiques...${NC}"
- echo "Voulez-vous collecter les fichiers statiques ? (o/N)"
- read -r response
- if [[ "$response" =~ ^([oO][uU][iI]|[oO])$ ]]; then
- python manage.py collectstatic --noinput
- echo -e "${GREEN}✅ Fichiers statiques collectés${NC}"
- else
- echo -e "${YELLOW}⏭️ Fichiers statiques ignorés${NC}"
- fi
- echo -e "\n${GREEN}=============================================="
- echo "✅ Installation terminée avec succès !"
- echo "=============================================="
- echo -e "${NC}"
- echo "Pour démarrer le serveur :"
- echo " source venv/bin/activate"
- echo " python manage.py runserver"
- echo ""
- echo "Puis visitez : http://127.0.0.1:8000/blog/"
|