#!/bin/bash

# Script to remove old HTML pages from server
# Run this on your production server

echo "🗑️  Removing old HTML pages directory..."

# Navigate to public directory
cd "$(dirname "$0")/public" || exit 1

# Check if pages directory exists
if [ -d "pages" ]; then
    echo "📁 Found 'pages' directory"
    
    # List files before deletion
    echo "Files to be removed:"
    ls -la pages/
    
    # Create backup first
    echo "💾 Creating backup..."
    tar -czf "../pages_backup_$(date +%Y%m%d_%H%M%S).tar.gz" pages/
    
    # Remove the directory
    echo "🗑️  Removing pages directory..."
    rm -rf pages/
    
    echo "✅ Old HTML pages directory removed!"
    echo "📦 Backup saved to: pages_backup_*.tar.gz"
else
    echo "ℹ️  'pages' directory not found. It may have already been removed."
fi

# Also check for index.html
if [ -f "index.html" ]; then
    echo "⚠️  Found index.html - renaming to backup..."
    mv index.html index.html.old_backup
    echo "✅ index.html renamed to index.html.old_backup"
fi

echo ""
echo "✅ Cleanup complete!"
echo ""
echo "📝 Next steps:"
echo "   1. Clear browser cache"
echo "   2. Test your Laravel routes:"
echo "      - https://yourdomain.com/services"
echo "      - https://yourdomain.com/about"
echo "      - https://yourdomain.com/contact"
echo "      - https://yourdomain.com/apply"
echo ""
echo "   Old URLs will now redirect to Laravel routes automatically!"

