#!/bin/bash
# Simple cPanel Deployment Script

echo "🚀 Starting cPanel Deployment..."

# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color

# Step 1: Pull latest code (if using git)
echo -e "\n${YELLOW}▶ Pulling latest code...${NC}"
git pull origin main || echo "Git pull skipped"

# Step 2: Install/update dependencies
echo -e "\n${YELLOW}▶ Installing dependencies...${NC}"
pip install -r requirements.txt --user

# Step 3: Run migrations
echo -e "\n${YELLOW}▶ Running migrations...${NC}"
python manage.py migrate --noinput

# Step 4: Collect static files
echo -e "\n${YELLOW}▶ Collecting static files...${NC}"
python manage.py collectstatic --noinput --clear

# Step 5: Restart application
echo -e "\n${YELLOW}▶ Restarting application...${NC}"
touch tmp/restart.txt

echo -e "\n${GREEN}✓ Deployment complete!${NC}"
echo -e "\nPlease verify:"
echo "  1. Check your site is loading"
echo "  2. Test login functionality"
echo "  3. Review error logs if needed"
