furt/scripts/start.sh
michael c15b01a0a6 fix(config): unify config path detection across all scripts
- Add platform detection to start.sh for consistent config paths
- BSD systems: /usr/local/etc/furt/furt.conf
- Linux systems: /etc/furt/furt.conf
- Now consistent with setup-directories.sh and validate-config.sh
- Follows DAW service separation standards

Fixes #103
2025-09-05 17:21:25 +02:00

82 lines
2 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 [ "$(uname)" = "OpenBSD" ] || [ "$(uname)" = "FreeBSD" ]; then
CONFIG_FILE="/usr/local/etc/furt/furt.conf"
else
CONFIG_FILE="/etc/furt/furt.conf"
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 " 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}"
# Service vs Interactive Detection
if [ ! -t 0 ] || [ ! -t 1 ]; then
# Service mode - Background
"$LUA_COMMAND" src/main.lua &
else
# Interactive mode - Foreground
exec "$LUA_COMMAND" src/main.lua
fi
# Furt liest selbst seine Config aus furt.conf
#exec "$LUA_COMMAND" src/main.lua