#!/bin/bash # Email Alerts Deployment Script # Server: 104.225.217.215 # Port: 5237 echo "🚀 Deploying Email Alerts Application..." # Update system echo "📦 Updating system packages..." apt update && apt upgrade -y # Install required packages echo "📦 Installing required packages..." apt install -y python3 python3-pip python3-venv nginx ufw # Create application directory echo "📁 Setting up application directory..." mkdir -p /root/email_alerts cd /root/email_alerts # Copy application files (assuming you'll upload them) echo "📋 Application files should be uploaded to /root/email_alerts/" # Create virtual environment echo "🐍 Creating Python virtual environment..." python3 -m venv venv source venv/bin/activate # Install dependencies echo "📦 Installing Python dependencies..." pip install flask python-dotenv requests google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client twilio groq # Set up firewall echo "🔥 Configuring firewall..." ufw allow 22/tcp ufw allow 80/tcp ufw allow 443/tcp ufw allow 5237/tcp ufw --force enable # Set up systemd service echo "⚙️ Setting up systemd service..." cp email-alerts.service /etc/systemd/system/ systemctl daemon-reload systemctl enable email-alerts systemctl start email-alerts # Check service status echo "📊 Checking service status..." systemctl status email-alerts echo "✅ Deployment complete!" echo "🌐 Application will be accessible at: http://104.225.217.215:5237" echo "📝 Logs available at: /root/email_alerts/email_alerts.log" echo "" echo "🔧 Useful commands:" echo " Start service: systemctl start email-alerts" echo " Stop service: systemctl stop email-alerts" echo " Restart service: systemctl restart email-alerts" echo " View logs: journalctl -u email-alerts -f" echo " View app logs: tail -f /root/email_alerts/email_alerts.log"