furt/scripts/start.sh

127 lines
3.2 KiB
Bash
Raw Normal View History

#!/bin/sh
# scripts/start.sh
feat(furt): implement complete Lua HTTP-Server for digital sovereignty (#63) - Add furt-lua/ directory with pure Lua implementation - Replace planned Go implementation with Corporate-free technology - Complete Week 1 Challenge: HTTP-Server to production-ready in 48min - HTTP-Server in pure Lua (185 lines, lua-socket based) - JSON API endpoints with request/response parsing - Modular architecture: each file < 200 lines - Error handling for 404, 400, validation scenarios - GET /health - Service health check with timestamp - POST /test - Development testing with request echo - POST /v1/mail/send - Mail service foundation with validation - Comprehensive error responses with structured JSON - Smart startup script with dependency auto-detection - Automated test suite with lua-socket HTTP client - Manual curl test suite for development workflow - Complete documentation and installation guide - FROM: Go (Google-controlled) → TO: Lua (PUC-Rio University) - Corporate-free dependency chain: lua-socket + lua-cjson + lua-ssl - Performance superior: < 1ms response time, minimal memory usage - Foundation for planned C+Lua hybrid architecture - furt-lua/src/main.lua - HTTP-Server implementation - furt-lua/config/server.lua - Lua-based configuration - furt-lua/scripts/start.sh - Startup with dependency checks - furt-lua/scripts/test_curl.sh - Manual testing suite - furt-lua/tests/test_http.lua - Automated test framework - furt-lua/README.md - Implementation documentation - README.md - Document Go→Lua migration strategy - .gitignore - Add Lua artifacts, luarocks, issue-scripts All endpoints tested and working: ✓ Health check returns proper JSON status ✓ Test endpoint processes POST requests with JSON ✓ Mail endpoint validates required fields (name, email, message) ✓ Error handling returns appropriate HTTP status codes Ready for Week 2: SMTP integration with mail.dragons-at-work.de Completes #63 Related #62
2025-06-17 20:40:40 +02:00
set -e
# Colors
feat(furt): implement complete Lua HTTP-Server for digital sovereignty (#63) - Add furt-lua/ directory with pure Lua implementation - Replace planned Go implementation with Corporate-free technology - Complete Week 1 Challenge: HTTP-Server to production-ready in 48min - HTTP-Server in pure Lua (185 lines, lua-socket based) - JSON API endpoints with request/response parsing - Modular architecture: each file < 200 lines - Error handling for 404, 400, validation scenarios - GET /health - Service health check with timestamp - POST /test - Development testing with request echo - POST /v1/mail/send - Mail service foundation with validation - Comprehensive error responses with structured JSON - Smart startup script with dependency auto-detection - Automated test suite with lua-socket HTTP client - Manual curl test suite for development workflow - Complete documentation and installation guide - FROM: Go (Google-controlled) → TO: Lua (PUC-Rio University) - Corporate-free dependency chain: lua-socket + lua-cjson + lua-ssl - Performance superior: < 1ms response time, minimal memory usage - Foundation for planned C+Lua hybrid architecture - furt-lua/src/main.lua - HTTP-Server implementation - furt-lua/config/server.lua - Lua-based configuration - furt-lua/scripts/start.sh - Startup with dependency checks - furt-lua/scripts/test_curl.sh - Manual testing suite - furt-lua/tests/test_http.lua - Automated test framework - furt-lua/README.md - Implementation documentation - README.md - Document Go→Lua migration strategy - .gitignore - Add Lua artifacts, luarocks, issue-scripts All endpoints tested and working: ✓ Health check returns proper JSON status ✓ Test endpoint processes POST requests with JSON ✓ Mail endpoint validates required fields (name, email, message) ✓ Error handling returns appropriate HTTP status codes Ready for Week 2: SMTP integration with mail.dragons-at-work.de Completes #63 Related #62
2025-06-17 20:40:40 +02:00
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
feat(furt): implement complete Lua HTTP-Server for digital sovereignty (#63) - Add furt-lua/ directory with pure Lua implementation - Replace planned Go implementation with Corporate-free technology - Complete Week 1 Challenge: HTTP-Server to production-ready in 48min - HTTP-Server in pure Lua (185 lines, lua-socket based) - JSON API endpoints with request/response parsing - Modular architecture: each file < 200 lines - Error handling for 404, 400, validation scenarios - GET /health - Service health check with timestamp - POST /test - Development testing with request echo - POST /v1/mail/send - Mail service foundation with validation - Comprehensive error responses with structured JSON - Smart startup script with dependency auto-detection - Automated test suite with lua-socket HTTP client - Manual curl test suite for development workflow - Complete documentation and installation guide - FROM: Go (Google-controlled) → TO: Lua (PUC-Rio University) - Corporate-free dependency chain: lua-socket + lua-cjson + lua-ssl - Performance superior: < 1ms response time, minimal memory usage - Foundation for planned C+Lua hybrid architecture - furt-lua/src/main.lua - HTTP-Server implementation - furt-lua/config/server.lua - Lua-based configuration - furt-lua/scripts/start.sh - Startup with dependency checks - furt-lua/scripts/test_curl.sh - Manual testing suite - furt-lua/tests/test_http.lua - Automated test framework - furt-lua/README.md - Implementation documentation - README.md - Document Go→Lua migration strategy - .gitignore - Add Lua artifacts, luarocks, issue-scripts All endpoints tested and working: ✓ Health check returns proper JSON status ✓ Test endpoint processes POST requests with JSON ✓ Mail endpoint validates required fields (name, email, message) ✓ Error handling returns appropriate HTTP status codes Ready for Week 2: SMTP integration with mail.dragons-at-work.de Completes #63 Related #62
2025-06-17 20:40:40 +02:00
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
feat(furt): implement complete Lua HTTP-Server for digital sovereignty (#63) - Add furt-lua/ directory with pure Lua implementation - Replace planned Go implementation with Corporate-free technology - Complete Week 1 Challenge: HTTP-Server to production-ready in 48min - HTTP-Server in pure Lua (185 lines, lua-socket based) - JSON API endpoints with request/response parsing - Modular architecture: each file < 200 lines - Error handling for 404, 400, validation scenarios - GET /health - Service health check with timestamp - POST /test - Development testing with request echo - POST /v1/mail/send - Mail service foundation with validation - Comprehensive error responses with structured JSON - Smart startup script with dependency auto-detection - Automated test suite with lua-socket HTTP client - Manual curl test suite for development workflow - Complete documentation and installation guide - FROM: Go (Google-controlled) → TO: Lua (PUC-Rio University) - Corporate-free dependency chain: lua-socket + lua-cjson + lua-ssl - Performance superior: < 1ms response time, minimal memory usage - Foundation for planned C+Lua hybrid architecture - furt-lua/src/main.lua - HTTP-Server implementation - furt-lua/config/server.lua - Lua-based configuration - furt-lua/scripts/start.sh - Startup with dependency checks - furt-lua/scripts/test_curl.sh - Manual testing suite - furt-lua/tests/test_http.lua - Automated test framework - furt-lua/README.md - Implementation documentation - README.md - Document Go→Lua migration strategy - .gitignore - Add Lua artifacts, luarocks, issue-scripts All endpoints tested and working: ✓ Health check returns proper JSON status ✓ Test endpoint processes POST requests with JSON ✓ Mail endpoint validates required fields (name, email, message) ✓ Error handling returns appropriate HTTP status codes Ready for Week 2: SMTP integration with mail.dragons-at-work.de Completes #63 Related #62
2025-06-17 20:40:40 +02:00
echo -e "${GREEN}=== Furt Lua HTTP-Server Startup ===${NC}"
# User can override this manually if needed:
LUA_COMMAND=""
# Config check first
if [ "$(uname)" = "OpenBSD" ]; then
CONFIG_FILE="/usr/local/etc/furt/furt.conf"
PID_FILE="/var/run/furt/furt.pid"
else
CONFIG_FILE="/etc/furt/furt.conf"
PID_FILE="/var/run/furt/furt.pid"
fi
if [ ! -f "$CONFIG_FILE" ] && [ ! -f "$PROJECT_DIR/config/furt.conf" ]; then
echo -e "${RED}Error: furt.conf not found${NC}"
echo "Create config first in $CONFIG_FILE or $PROJECT_DIR/config/furt.conf"
exit 1
fi
if [ -z "$LUA_COMMAND" ]; then
# Test standard distribution paths
for cmd in lua51 lua5.1; do
if command -v "$cmd" >/dev/null 2>&1; then
LUA_COMMAND="$cmd"
break
fi
done
fi
if [ -z "$LUA_COMMAND" ]; then
echo -e "${RED}Error: No Lua 5.1 found${NC}"
echo "Install options:"
echo " Arch: pacman -S lua51"
echo " OpenBSD: pkg_add lua51"
echo " Debian: apt install lua5.1"
echo ""
echo "Or set: LUA_COMMAND=/custom/path/lua51 at top of this script"
feat(furt): implement complete Lua HTTP-Server for digital sovereignty (#63) - Add furt-lua/ directory with pure Lua implementation - Replace planned Go implementation with Corporate-free technology - Complete Week 1 Challenge: HTTP-Server to production-ready in 48min - HTTP-Server in pure Lua (185 lines, lua-socket based) - JSON API endpoints with request/response parsing - Modular architecture: each file < 200 lines - Error handling for 404, 400, validation scenarios - GET /health - Service health check with timestamp - POST /test - Development testing with request echo - POST /v1/mail/send - Mail service foundation with validation - Comprehensive error responses with structured JSON - Smart startup script with dependency auto-detection - Automated test suite with lua-socket HTTP client - Manual curl test suite for development workflow - Complete documentation and installation guide - FROM: Go (Google-controlled) → TO: Lua (PUC-Rio University) - Corporate-free dependency chain: lua-socket + lua-cjson + lua-ssl - Performance superior: < 1ms response time, minimal memory usage - Foundation for planned C+Lua hybrid architecture - furt-lua/src/main.lua - HTTP-Server implementation - furt-lua/config/server.lua - Lua-based configuration - furt-lua/scripts/start.sh - Startup with dependency checks - furt-lua/scripts/test_curl.sh - Manual testing suite - furt-lua/tests/test_http.lua - Automated test framework - furt-lua/README.md - Implementation documentation - README.md - Document Go→Lua migration strategy - .gitignore - Add Lua artifacts, luarocks, issue-scripts All endpoints tested and working: ✓ Health check returns proper JSON status ✓ Test endpoint processes POST requests with JSON ✓ Mail endpoint validates required fields (name, email, message) ✓ Error handling returns appropriate HTTP status codes Ready for Week 2: SMTP integration with mail.dragons-at-work.de Completes #63 Related #62
2025-06-17 20:40:40 +02:00
exit 1
fi
echo -e "${GREEN}Found Lua:${NC} $LUA_COMMAND"
feat(furt): implement complete Lua HTTP-Server for digital sovereignty (#63) - Add furt-lua/ directory with pure Lua implementation - Replace planned Go implementation with Corporate-free technology - Complete Week 1 Challenge: HTTP-Server to production-ready in 48min - HTTP-Server in pure Lua (185 lines, lua-socket based) - JSON API endpoints with request/response parsing - Modular architecture: each file < 200 lines - Error handling for 404, 400, validation scenarios - GET /health - Service health check with timestamp - POST /test - Development testing with request echo - POST /v1/mail/send - Mail service foundation with validation - Comprehensive error responses with structured JSON - Smart startup script with dependency auto-detection - Automated test suite with lua-socket HTTP client - Manual curl test suite for development workflow - Complete documentation and installation guide - FROM: Go (Google-controlled) → TO: Lua (PUC-Rio University) - Corporate-free dependency chain: lua-socket + lua-cjson + lua-ssl - Performance superior: < 1ms response time, minimal memory usage - Foundation for planned C+Lua hybrid architecture - furt-lua/src/main.lua - HTTP-Server implementation - furt-lua/config/server.lua - Lua-based configuration - furt-lua/scripts/start.sh - Startup with dependency checks - furt-lua/scripts/test_curl.sh - Manual testing suite - furt-lua/tests/test_http.lua - Automated test framework - furt-lua/README.md - Implementation documentation - README.md - Document Go→Lua migration strategy - .gitignore - Add Lua artifacts, luarocks, issue-scripts All endpoints tested and working: ✓ Health check returns proper JSON status ✓ Test endpoint processes POST requests with JSON ✓ Mail endpoint validates required fields (name, email, message) ✓ Error handling returns appropriate HTTP status codes Ready for Week 2: SMTP integration with mail.dragons-at-work.de Completes #63 Related #62
2025-06-17 20:40:40 +02:00
# Dependency checks
# Socket check
$LUA_COMMAND -e "require('socket')" 2>/dev/null || {
echo -e "${RED}Error: lua-socket not found${NC}"
echo "Install options:"
echo " Arch: pacman -S lua51-socket"
echo " OpenBSD: pkg_add lua-socket"
echo " Debian: apt install lua-socket"
feat(furt): implement complete Lua HTTP-Server for digital sovereignty (#63) - Add furt-lua/ directory with pure Lua implementation - Replace planned Go implementation with Corporate-free technology - Complete Week 1 Challenge: HTTP-Server to production-ready in 48min - HTTP-Server in pure Lua (185 lines, lua-socket based) - JSON API endpoints with request/response parsing - Modular architecture: each file < 200 lines - Error handling for 404, 400, validation scenarios - GET /health - Service health check with timestamp - POST /test - Development testing with request echo - POST /v1/mail/send - Mail service foundation with validation - Comprehensive error responses with structured JSON - Smart startup script with dependency auto-detection - Automated test suite with lua-socket HTTP client - Manual curl test suite for development workflow - Complete documentation and installation guide - FROM: Go (Google-controlled) → TO: Lua (PUC-Rio University) - Corporate-free dependency chain: lua-socket + lua-cjson + lua-ssl - Performance superior: < 1ms response time, minimal memory usage - Foundation for planned C+Lua hybrid architecture - furt-lua/src/main.lua - HTTP-Server implementation - furt-lua/config/server.lua - Lua-based configuration - furt-lua/scripts/start.sh - Startup with dependency checks - furt-lua/scripts/test_curl.sh - Manual testing suite - furt-lua/tests/test_http.lua - Automated test framework - furt-lua/README.md - Implementation documentation - README.md - Document Go→Lua migration strategy - .gitignore - Add Lua artifacts, luarocks, issue-scripts All endpoints tested and working: ✓ Health check returns proper JSON status ✓ Test endpoint processes POST requests with JSON ✓ Mail endpoint validates required fields (name, email, message) ✓ Error handling returns appropriate HTTP status codes Ready for Week 2: SMTP integration with mail.dragons-at-work.de Completes #63 Related #62
2025-06-17 20:40:40 +02:00
exit 1
}
# JSON library check
if ! ($LUA_COMMAND -e "require('cjson')" 2>/dev/null || $LUA_COMMAND -e "require('dkjson')" 2>/dev/null); then
echo -e "${RED}Error: No JSON library found${NC}"
echo "Install options:"
echo " Arch: pacman -S lua51-dkjson"
echo " OpenBSD: pkg_add lua-cjson"
echo " Debian: apt install lua-cjson"
feat(furt): implement complete Lua HTTP-Server for digital sovereignty (#63) - Add furt-lua/ directory with pure Lua implementation - Replace planned Go implementation with Corporate-free technology - Complete Week 1 Challenge: HTTP-Server to production-ready in 48min - HTTP-Server in pure Lua (185 lines, lua-socket based) - JSON API endpoints with request/response parsing - Modular architecture: each file < 200 lines - Error handling for 404, 400, validation scenarios - GET /health - Service health check with timestamp - POST /test - Development testing with request echo - POST /v1/mail/send - Mail service foundation with validation - Comprehensive error responses with structured JSON - Smart startup script with dependency auto-detection - Automated test suite with lua-socket HTTP client - Manual curl test suite for development workflow - Complete documentation and installation guide - FROM: Go (Google-controlled) → TO: Lua (PUC-Rio University) - Corporate-free dependency chain: lua-socket + lua-cjson + lua-ssl - Performance superior: < 1ms response time, minimal memory usage - Foundation for planned C+Lua hybrid architecture - furt-lua/src/main.lua - HTTP-Server implementation - furt-lua/config/server.lua - Lua-based configuration - furt-lua/scripts/start.sh - Startup with dependency checks - furt-lua/scripts/test_curl.sh - Manual testing suite - furt-lua/tests/test_http.lua - Automated test framework - furt-lua/README.md - Implementation documentation - README.md - Document Go→Lua migration strategy - .gitignore - Add Lua artifacts, luarocks, issue-scripts All endpoints tested and working: ✓ Health check returns proper JSON status ✓ Test endpoint processes POST requests with JSON ✓ Mail endpoint validates required fields (name, email, message) ✓ Error handling returns appropriate HTTP status codes Ready for Week 2: SMTP integration with mail.dragons-at-work.de Completes #63 Related #62
2025-06-17 20:40:40 +02:00
exit 1
fi
feat(furt): implement complete Lua HTTP-Server for digital sovereignty (#63) - Add furt-lua/ directory with pure Lua implementation - Replace planned Go implementation with Corporate-free technology - Complete Week 1 Challenge: HTTP-Server to production-ready in 48min - HTTP-Server in pure Lua (185 lines, lua-socket based) - JSON API endpoints with request/response parsing - Modular architecture: each file < 200 lines - Error handling for 404, 400, validation scenarios - GET /health - Service health check with timestamp - POST /test - Development testing with request echo - POST /v1/mail/send - Mail service foundation with validation - Comprehensive error responses with structured JSON - Smart startup script with dependency auto-detection - Automated test suite with lua-socket HTTP client - Manual curl test suite for development workflow - Complete documentation and installation guide - FROM: Go (Google-controlled) → TO: Lua (PUC-Rio University) - Corporate-free dependency chain: lua-socket + lua-cjson + lua-ssl - Performance superior: < 1ms response time, minimal memory usage - Foundation for planned C+Lua hybrid architecture - furt-lua/src/main.lua - HTTP-Server implementation - furt-lua/config/server.lua - Lua-based configuration - furt-lua/scripts/start.sh - Startup with dependency checks - furt-lua/scripts/test_curl.sh - Manual testing suite - furt-lua/tests/test_http.lua - Automated test framework - furt-lua/README.md - Implementation documentation - README.md - Document Go→Lua migration strategy - .gitignore - Add Lua artifacts, luarocks, issue-scripts All endpoints tested and working: ✓ Health check returns proper JSON status ✓ Test endpoint processes POST requests with JSON ✓ Mail endpoint validates required fields (name, email, message) ✓ Error handling returns appropriate HTTP status codes Ready for Week 2: SMTP integration with mail.dragons-at-work.de Completes #63 Related #62
2025-06-17 20:40:40 +02:00
# SSL/TLS library check
$LUA_COMMAND -e "require('ssl')" 2>/dev/null || {
echo -e "${RED}Error: SSL/TLS library not found${NC}"
echo "Install options:"
echo " Arch: pacman -S lua51-sec"
echo " OpenBSD: pkg_add luasec"
echo " Debian: apt install lua-sec"
exit 1
}
feat(furt): implement complete Lua HTTP-Server for digital sovereignty (#63) - Add furt-lua/ directory with pure Lua implementation - Replace planned Go implementation with Corporate-free technology - Complete Week 1 Challenge: HTTP-Server to production-ready in 48min - HTTP-Server in pure Lua (185 lines, lua-socket based) - JSON API endpoints with request/response parsing - Modular architecture: each file < 200 lines - Error handling for 404, 400, validation scenarios - GET /health - Service health check with timestamp - POST /test - Development testing with request echo - POST /v1/mail/send - Mail service foundation with validation - Comprehensive error responses with structured JSON - Smart startup script with dependency auto-detection - Automated test suite with lua-socket HTTP client - Manual curl test suite for development workflow - Complete documentation and installation guide - FROM: Go (Google-controlled) → TO: Lua (PUC-Rio University) - Corporate-free dependency chain: lua-socket + lua-cjson + lua-ssl - Performance superior: < 1ms response time, minimal memory usage - Foundation for planned C+Lua hybrid architecture - furt-lua/src/main.lua - HTTP-Server implementation - furt-lua/config/server.lua - Lua-based configuration - furt-lua/scripts/start.sh - Startup with dependency checks - furt-lua/scripts/test_curl.sh - Manual testing suite - furt-lua/tests/test_http.lua - Automated test framework - furt-lua/README.md - Implementation documentation - README.md - Document Go→Lua migration strategy - .gitignore - Add Lua artifacts, luarocks, issue-scripts All endpoints tested and working: ✓ Health check returns proper JSON status ✓ Test endpoint processes POST requests with JSON ✓ Mail endpoint validates required fields (name, email, message) ✓ Error handling returns appropriate HTTP status codes Ready for Week 2: SMTP integration with mail.dragons-at-work.de Completes #63 Related #62
2025-06-17 20:40:40 +02:00
cd "$PROJECT_DIR"
echo -e "${GREEN}Starting Furt...${NC}"
# PID-File cleanup function
cleanup_pid() {
if [ -f "$PID_FILE" ]; then
rm -f "$PID_FILE"
fi
}
# Service vs Interactive Detection
if [ ! -t 0 ] || [ ! -t 1 ]; then
# Service mode - Background + PID-File
echo -e "${GREEN}Service mode: Background + PID-File${NC}"
# Start process in background
"$LUA_COMMAND" src/main.lua &
PID=$!
# Write PID-File
echo "$PID" > "$PID_FILE"
echo -e "${GREEN}Furt started (PID: $PID, PID-File: $PID_FILE)${NC}"
# Verify process is still running after short delay
sleep 1
if ! kill -0 "$PID" 2>/dev/null; then
echo -e "${RED}Error: Process died immediately${NC}"
cleanup_pid
exit 1
fi
echo -e "${GREEN}Service startup successful${NC}"
else
# Interactive mode - Foreground (no PID-File)
echo -e "${GREEN}Interactive mode: Foreground${NC}"
exec "$LUA_COMMAND" src/main.lua
fi