Files
digiserver-v2/clean_for_deployment.sh
2025-11-17 22:03:52 +02:00

86 lines
2.4 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Clean development data before Docker deployment
# This script removes all development data to ensure a fresh start
set -e
echo "🧹 Cleaning DigiServer v2 for deployment..."
echo ""
# Confirm action
read -p "This will delete ALL data (database, uploads, logs). Continue? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "❌ Cancelled"
exit 1
fi
echo ""
echo "📦 Cleaning development data..."
# Remove database files
if [ -d "instance" ]; then
echo " 🗄️ Removing database files..."
rm -rf instance/*.db
rm -rf instance/*.db-*
echo " ✅ Database cleaned"
else
echo " No instance directory found"
fi
# Remove uploaded media
if [ -d "app/static/uploads" ]; then
echo " 📁 Removing uploaded media files..."
find app/static/uploads -type f -not -name '.gitkeep' -delete 2>/dev/null || true
find app/static/uploads -type d -empty -not -path "app/static/uploads" -delete 2>/dev/null || true
echo " ✅ Uploads cleaned"
else
echo " No uploads directory found"
fi
# Remove additional upload directory if exists
if [ -d "static/uploads" ]; then
echo " 📁 Removing static uploads..."
find static/uploads -type f -not -name '.gitkeep' -delete 2>/dev/null || true
find static/uploads -type d -empty -not -path "static/uploads" -delete 2>/dev/null || true
echo " ✅ Static uploads cleaned"
fi
# Remove log files
echo " 📝 Removing log files..."
find . -name "*.log" -type f -delete 2>/dev/null || true
echo " ✅ Logs cleaned"
# Remove Python cache
echo " 🐍 Removing Python cache..."
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
find . -type f -name "*.pyo" -delete 2>/dev/null || true
echo " ✅ Python cache cleaned"
# Remove Flask session files if any
if [ -d "flask_session" ]; then
echo " 🔐 Removing session files..."
rm -rf flask_session
echo " ✅ Sessions cleaned"
fi
# Summary
echo ""
echo "✨ Cleanup complete!"
echo ""
echo "📊 Summary:"
echo " - Database: Removed"
echo " - Uploaded media: Removed"
echo " - Logs: Removed"
echo " - Python cache: Removed"
echo ""
echo "🚀 Ready for deployment!"
echo ""
echo "Next steps:"
echo " 1. Build Docker image: docker compose build"
echo " 2. Start container: docker compose up -d"
echo " 3. Access at: http://localhost:80"
echo " 4. Login with: admin / admin123"
echo ""