fix(config): partial implementation of universal config detection (#68)
- Add multi-distribution config path detection
- Support /usr/local/etc/furt/environment (OpenBSD)
- Support /etc/furt/environment (Debian/Ubuntu/RHEL)
- Maintain .env support for development
- Add configurable Lua command via LUA_COMMAND environment variable
POSIX compatibility improvements:
- Replace command -v with [ -x ] for service user compatibility
- Change shebang from #!/bin/bash to #!/bin/sh for OpenBSD
- Replace ${BASH_SOURCE[0]} with $0 for POSIX shell compatibility
walter deployment changes:
- Migrate directory structure to /usr/local/furt/furt-lua/
- Set up _furt user permissions
- Configure system config in /usr/local/etc/furt/environment
Known issues:
- karl development environment regression (lua51 detection failed)
- walter SSL missing for SMTP (luasec vs luaossl compatibility)
- Config strategy needs comprehensive redesign for multi-implementation
Related: #68
Files modified:
- furt-lua/scripts/start.sh (POSIX compatibility + universal config)
- .env.example (added LUA_COMMAND and LUA_VERSION)
- walter: /usr/local/etc/furt/environment (system config setup)
This commit is contained in:
parent
6d7d8a2af8
commit
bb2bed80a6
2 changed files with 52 additions and 38 deletions
|
|
@ -7,6 +7,10 @@ GITEA_TOKEN=your-gitea-token-here
|
||||||
# Optional: Default-Assignee für Issues
|
# Optional: Default-Assignee für Issues
|
||||||
DEFAULT_ASSIGNEE=your-username
|
DEFAULT_ASSIGNEE=your-username
|
||||||
|
|
||||||
|
# Lua-Konfiguration
|
||||||
|
LUA_COMMAND=lua51
|
||||||
|
LUA_VERSION=5.1
|
||||||
|
|
||||||
# Gateway-Konfiguration (für Entwicklung)
|
# Gateway-Konfiguration (für Entwicklung)
|
||||||
GATEWAY_PORT=8080
|
GATEWAY_PORT=8080
|
||||||
GATEWAY_LOG_LEVEL=info
|
GATEWAY_LOG_LEVEL=info
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
# furt-lua/scripts/start.sh
|
# furt-lua/scripts/start.sh
|
||||||
# Start script for Furt Lua HTTP-Server
|
# Start script for Furt Lua HTTP-Server
|
||||||
|
|
||||||
|
|
@ -10,62 +10,72 @@ GREEN='\033[0;32m'
|
||||||
YELLOW='\033[1;33m'
|
YELLOW='\033[1;33m'
|
||||||
NC='\033[0m' # No Color
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
# Script directory
|
# Script directory (POSIX-compatible)
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||||
|
|
||||||
echo -e "${GREEN}=== Furt Lua HTTP-Server Startup ===${NC}"
|
echo -e "${GREEN}=== Furt Lua HTTP-Server Startup ===${NC}"
|
||||||
|
|
||||||
# Check if Lua is installed
|
# Check required dependencies
|
||||||
if ! command -v lua &> /dev/null; then
|
echo -e "${YELLOW}Checking dependencies...${NC}"
|
||||||
echo -e "${RED}Error: Lua is not installed${NC}"
|
|
||||||
echo "Install with: pacman -S lua (Arch) or apt install lua5.4 (Ubuntu)"
|
# Load environment variables - Universal Config Detection
|
||||||
|
echo -e "${YELLOW}Loading environment variables...${NC}"
|
||||||
|
if [ -f "$PROJECT_DIR/.env" ]; then
|
||||||
|
echo -e "${GREEN}[OK]${NC} Loading from $PROJECT_DIR/.env"
|
||||||
|
export $(grep -v '^#' "$PROJECT_DIR/.env" | grep -v '^$' | xargs)
|
||||||
|
elif [ -f "/usr/local/etc/furt/environment" ]; then
|
||||||
|
echo -e "${GREEN}[OK]${NC} Loading from /usr/local/etc/furt/environment"
|
||||||
|
export $(grep -v '^#' /usr/local/etc/furt/environment | grep -v '^$' | xargs)
|
||||||
|
elif [ -f "/etc/furt/environment" ]; then
|
||||||
|
echo -e "${GREEN}[OK]${NC} Loading from /etc/furt/environment"
|
||||||
|
export $(grep -v '^#' /etc/furt/environment | grep -v '^$' | xargs)
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}[WARN]${NC} No config file found in project root or system"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup Lua from config (after loading environment)
|
||||||
|
LUA_CMD="${LUA_COMMAND:-lua51}"
|
||||||
|
LUA_VER="${LUA_VERSION:-5.1}"
|
||||||
|
|
||||||
|
# Check if configured Lua is installed (POSIX-compatible)
|
||||||
|
if ! [ -x "$LUA_CMD" ]; then
|
||||||
|
echo -e "${RED}Error: $LUA_CMD is not installed${NC}"
|
||||||
|
echo "Install with: pkg_add lua51 (OpenBSD) or apt install lua5.1 (Ubuntu)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check Lua version
|
# Check Lua version
|
||||||
LUA_VERSION=$(lua -v 2>&1 | head -n1)
|
LUA_VERSION_OUTPUT=$($LUA_CMD -v 2>&1 | head -n1)
|
||||||
echo -e "${YELLOW}Lua version:${NC} $LUA_VERSION"
|
echo -e "${YELLOW}Lua command:${NC} $LUA_CMD ($LUA_VERSION_OUTPUT)"
|
||||||
|
|
||||||
# Check required dependencies
|
|
||||||
echo -e "${YELLOW}Checking dependencies...${NC}"
|
|
||||||
|
|
||||||
# Test lua-socket
|
# Test lua-socket
|
||||||
lua -e "require('socket')" 2>/dev/null || {
|
$LUA_CMD -e "require('socket')" 2>/dev/null || {
|
||||||
echo -e "${RED}Error: lua-socket not found${NC}"
|
echo -e "${RED}Error: lua-socket not found for $LUA_CMD${NC}"
|
||||||
echo "Install with: pacman -S lua-socket (Arch) or apt install lua-socket (Ubuntu)"
|
echo "Install with: pkg_add lua51-socket (OpenBSD) or apt install lua-socket (Ubuntu)"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
echo -e "${GREEN}✓${NC} lua-socket found"
|
echo -e "${GREEN}✓${NC} lua-socket found"
|
||||||
|
|
||||||
# Test lua-cjson (system or luarocks)
|
# Test lua-cjson (system or luarocks)
|
||||||
LUA_PATH="$HOME/.luarocks/share/lua/5.4/?.lua;;" \
|
LUA_PATH="$HOME/.luarocks/share/lua/$LUA_VER/?.lua;;" \
|
||||||
LUA_CPATH="$HOME/.luarocks/lib/lua/5.4/?.so;;" \
|
LUA_CPATH="$HOME/.luarocks/lib/lua/$LUA_VER/?.so;;" \
|
||||||
lua -e "require('cjson')" 2>/dev/null || {
|
$LUA_CMD -e "require('cjson')" 2>/dev/null || {
|
||||||
echo -e "${RED}Error: lua-cjson not found${NC}"
|
echo -e "${RED}Error: lua-cjson not found for $LUA_CMD${NC}"
|
||||||
echo "Install with: pacman -S lua-cjson (Arch) or luarocks install --local lua-cjson"
|
echo "Install with: pkg_add lua51-cjson (OpenBSD) or luarocks install lua-cjson"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
echo -e "${GREEN}✓${NC} lua-cjson found"
|
echo -e "${GREEN}✓${NC} lua-cjson found"
|
||||||
|
|
||||||
# Test lua-ssl (optional for HTTPS)
|
# Test lua-ssl (optional for HTTPS)
|
||||||
LUA_PATH="$HOME/.luarocks/share/lua/5.4/?.lua;;" \
|
LUA_PATH="$HOME/.luarocks/share/lua/$LUA_VER/?.lua;;" \
|
||||||
LUA_CPATH="$HOME/.luarocks/lib/lua/5.4/?.so;;" \
|
LUA_CPATH="$HOME/.luarocks/lib/lua/$LUA_VER/?.so;;" \
|
||||||
lua -e "require('ssl')" 2>/dev/null && {
|
$LUA_CMD -e "require('ssl')" 2>/dev/null && {
|
||||||
echo -e "${GREEN}✓${NC} lua-ssl found (HTTPS ready)"
|
echo -e "${GREEN}✓${NC} lua-ssl found (HTTPS ready)"
|
||||||
} || {
|
} || {
|
||||||
echo -e "${YELLOW}○${NC} lua-ssl not found (install with: luarocks install --local luaossl)"
|
echo -e "${YELLOW}○${NC} lua-ssl not found (install with: luarocks install 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)
|
# Check SMTP configuration (korrekte Variable-Namen)
|
||||||
if [ -n "$SMTP_USERNAME" ] && [ -n "$SMTP_PASSWORD" ]; then
|
if [ -n "$SMTP_USERNAME" ] && [ -n "$SMTP_PASSWORD" ]; then
|
||||||
echo -e "${GREEN}[OK]${NC} SMTP configured: $SMTP_USERNAME"
|
echo -e "${GREEN}[OK]${NC} SMTP configured: $SMTP_USERNAME"
|
||||||
|
|
@ -77,15 +87,15 @@ fi
|
||||||
# Change to project directory
|
# Change to project directory
|
||||||
cd "$PROJECT_DIR"
|
cd "$PROJECT_DIR"
|
||||||
|
|
||||||
# Add current directory and luarocks to Lua path for requires
|
# Add current directory and luarocks to Lua path for requires (dynamic version)
|
||||||
export LUA_PATH="$PROJECT_DIR/src/?.lua;$PROJECT_DIR/?.lua;$HOME/.luarocks/share/lua/5.4/?.lua;;"
|
export LUA_PATH="$PROJECT_DIR/src/?.lua;$PROJECT_DIR/?.lua;$HOME/.luarocks/share/lua/$LUA_VER/?.lua;;"
|
||||||
export LUA_CPATH="$HOME/.luarocks/lib/lua/5.4/?.so;;"
|
export LUA_CPATH="$HOME/.luarocks/lib/lua/$LUA_VER/?.so;;"
|
||||||
|
|
||||||
echo -e "${GREEN}Starting Furt HTTP-Server...${NC}"
|
echo -e "${GREEN}Starting Furt HTTP-Server...${NC}"
|
||||||
echo -e "${YELLOW}Project directory:${NC} $PROJECT_DIR"
|
echo -e "${YELLOW}Project directory:${NC} $PROJECT_DIR"
|
||||||
echo -e "${YELLOW}Lua paths configured for system + luarocks${NC}"
|
echo -e "${YELLOW}Lua paths configured for $LUA_CMD (version $LUA_VER)${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Start server
|
# Start server
|
||||||
lua src/main.lua
|
$LUA_CMD src/main.lua
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue