furt/furt-lua/scripts/start.sh
michael 6d7d8a2af8 feat(smtp): complete native Lua SMTP integration for production mail delivery
- Add native Lua SMTP client with SSL/TLS support for mail.dragons-at-work.de:465
- Implement POST /v1/mail/send endpoint with real email delivery functionality
- Add environment variable integration (SMTP_*) for secure credential management
- Add comprehensive input validation and error handling for mail requests
- Add health check endpoint with SMTP configuration status reporting
- Add multi-line SMTP response handling for robust server communication
- Add request ID tracking system for debugging and monitoring
- Update start.sh script for automatic .env loading and dependency checking
- Add complete testing suite for SMTP functionality verification

This completes the Week 2 Challenge migration from Go to pure Lua HTTP server
with full production-ready SMTP capabilities. The implementation eliminates all
Google/corporate dependencies while achieving superior performance (18ms response
time) and maintaining digital sovereignty principles.

Real mail delivery confirmed: test email successfully sent to admin@dragons-at-work.de
Ready for Hugo website integration and production deployment with security layer.

Closes #65
2025-06-19 09:52:15 +02:00

91 lines
2.8 KiB
Bash
Executable file

#!/bin/bash
# furt-lua/scripts/start.sh
# Start script for Furt Lua HTTP-Server
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
echo -e "${GREEN}=== Furt Lua HTTP-Server Startup ===${NC}"
# Check if Lua is installed
if ! command -v lua &> /dev/null; then
echo -e "${RED}Error: Lua is not installed${NC}"
echo "Install with: pacman -S lua (Arch) or apt install lua5.4 (Ubuntu)"
exit 1
fi
# Check Lua version
LUA_VERSION=$(lua -v 2>&1 | head -n1)
echo -e "${YELLOW}Lua version:${NC} $LUA_VERSION"
# Check required dependencies
echo -e "${YELLOW}Checking dependencies...${NC}"
# Test lua-socket
lua -e "require('socket')" 2>/dev/null || {
echo -e "${RED}Error: lua-socket not found${NC}"
echo "Install with: pacman -S lua-socket (Arch) or apt install lua-socket (Ubuntu)"
exit 1
}
echo -e "${GREEN}${NC} lua-socket found"
# Test lua-cjson (system or luarocks)
LUA_PATH="$HOME/.luarocks/share/lua/5.4/?.lua;;" \
LUA_CPATH="$HOME/.luarocks/lib/lua/5.4/?.so;;" \
lua -e "require('cjson')" 2>/dev/null || {
echo -e "${RED}Error: lua-cjson not found${NC}"
echo "Install with: pacman -S lua-cjson (Arch) or luarocks install --local lua-cjson"
exit 1
}
echo -e "${GREEN}${NC} lua-cjson found"
# Test lua-ssl (optional for HTTPS)
LUA_PATH="$HOME/.luarocks/share/lua/5.4/?.lua;;" \
LUA_CPATH="$HOME/.luarocks/lib/lua/5.4/?.so;;" \
lua -e "require('ssl')" 2>/dev/null && {
echo -e "${GREEN}${NC} lua-ssl found (HTTPS ready)"
} || {
echo -e "${YELLOW}${NC} lua-ssl not found (install with: luarocks install --local luaossl)"
}
# Load environment variables from project root
echo -e "${YELLOW}Loading environment variables...${NC}"
if [ -f "../.env" ]; then
echo -e "${GREEN}[OK]${NC} Loading from ../.env"
export $(grep -v '^#' ../.env | grep -v '^$' | xargs)
else
echo -e "${YELLOW}[WARN]${NC} No .env file found in project root"
fi
# Check SMTP configuration (korrekte Variable-Namen)
if [ -n "$SMTP_USERNAME" ] && [ -n "$SMTP_PASSWORD" ]; then
echo -e "${GREEN}[OK]${NC} SMTP configured: $SMTP_USERNAME"
else
echo -e "${YELLOW}[WARN]${NC} SMTP credentials missing in .env"
echo "Add SMTP_USERNAME and SMTP_PASSWORD to .env"
fi
# Change to project directory
cd "$PROJECT_DIR"
# Add current directory and luarocks to Lua path for requires
export LUA_PATH="$PROJECT_DIR/src/?.lua;$PROJECT_DIR/?.lua;$HOME/.luarocks/share/lua/5.4/?.lua;;"
export LUA_CPATH="$HOME/.luarocks/lib/lua/5.4/?.so;;"
echo -e "${GREEN}Starting Furt HTTP-Server...${NC}"
echo -e "${YELLOW}Project directory:${NC} $PROJECT_DIR"
echo -e "${YELLOW}Lua paths configured for system + luarocks${NC}"
echo ""
# Start server
lua src/main.lua