#!/bin/bash

# Service Guardian Demo Script
set -e

echo "========================================"
echo "   Service Guardian Demo"
echo "========================================"
echo ""

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

echo -e "${BLUE}This demo will show you how to use Service Guardian${NC}"
echo ""

# Create a demo .env file
echo -e "${YELLOW}Creating demo configuration...${NC}"
cat > /root/.service-guardian/.env.demo <<EOF
# Demo SMTP Configuration (replace with your settings)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=demo@example.com
SMTP_PASS=demo-password
ALERT_TO=admin@example.com
ALERT_FROM=Service Guardian <demo@example.com>

# Monitoring Settings
CHECK_INTERVAL=30
MAX_RESTART_ATTEMPTS=5
RESTART_DELAY=10
EOF

echo -e "${GREEN}✓${NC} Demo configuration created"
echo ""

echo -e "${BLUE}Available commands:${NC}"
echo ""

echo "1. Initialize configuration:"
echo "   service-guardian init"
echo ""

echo "2. Add services to monitor:"
echo "   service-guardian add mysql"
echo "   service-guardian add nginx"
echo "   service-guardian add ssh"
echo ""

echo "3. List monitored services:"
echo "   service-guardian list"
echo ""

echo "4. Check service status:"
echo "   service-guardian status"
echo ""

echo "5. Start monitoring (foreground mode for testing):"
echo "   service-guardian start --foreground"
echo ""

echo "6. View logs:"
echo "   service-guardian logs"
echo ""

echo "7. Send test email:"
echo "   service-guardian test-email"
echo ""

echo -e "${YELLOW}To configure real email alerts:${NC}"
echo "   1. Edit /root/.service-guardian/.env"
echo "   2. Add your SMTP credentials"
echo "   3. For Gmail, use an App Password"
echo ""

echo -e "${GREEN}Demo setup complete! Try the commands above.${NC}"