furt/scripts/start.sh
michael 9b19b6a95b fix(scripts): resolve lua51 detection failure and remove obsolete environment system
- Fix variable inconsistency: LUA_CMD -> LUA_COMMAND throughout script
- Remove obsolete .env/environment loading - furt reads furt.conf directly
- Add config check for furt.conf (system or project location)
- Implement robust lua51 detection with fallback to lua5.1
- Support all target distributions: Arch, OpenBSD, Debian, FreeBSD
- Add clear installation instructions for missing dependencies
- Allow custom lua path via LUA_COMMAND variable override

This resolves the lua51 detection regression and simplifies the boot process
by eliminating dual config systems (environment vs furt.conf).

Fixes DAW/furt#91
2025-08-29 22:01:38 +02:00

66 lines
1.7 KiB
Bash
Executable file

#!/bin/sh
# furt-lua/scripts/start.sh - Bereinigt ohne obsoletes Environment-System
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
echo -e "${GREEN}=== Furt Lua HTTP-Server Startup ===${NC}"
# User can override this manually if needed:
LUA_COMMAND=""
# Config check first (like old .env check)
if [ ! -f "/usr/local/etc/furt/furt.conf" ] && [ ! -f "$PROJECT_DIR/config/furt.conf" ]; then
echo -e "${RED}Error: furt.conf not found${NC}"
echo "Create config first in /usr/local/etc/furt/furt.conf 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 " FreeBSD: pkg install lua51"
echo ""
echo "Or set: LUA_COMMAND=/custom/path/lua51 at top of this script"
exit 1
fi
echo -e "${GREEN}Found Lua:${NC} $LUA_COMMAND"
# Dependency checks (lua-socket, lua-cjson)
$LUA_COMMAND -e "require('socket')" 2>/dev/null || {
echo -e "${RED}Error: lua-socket not found${NC}"
exit 1
}
$LUA_COMMAND -e "require('cjson')" 2>/dev/null || {
echo -e "${RED}Error: lua-cjson not found${NC}"
exit 1
}
cd "$PROJECT_DIR"
echo -e "${GREEN}Starting Furt...${NC}"
# Furt liest selbst seine Config aus furt.conf
exec "$LUA_COMMAND" src/main.lua