66 lines
2.1 KiB
Bash
66 lines
2.1 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
echo "🦊 Starting Foxy Dev Team API Container..."
|
|
|
|
# Defaults
|
|
export HOME="/home/foxy"
|
|
export FOXY_HOME="/home/foxy/.openclaw"
|
|
export OPENCLAW_TYPE="${OPENCLAW_TYPE:-standalone}"
|
|
|
|
# Ensure logs directory exists
|
|
mkdir -p "$FOXY_HOME/logs"
|
|
|
|
# --- CONFIG PATCHING ---
|
|
# If we have a config file, we must ensure it doesn't point to host-specific paths
|
|
# that don't exist in the container (like /home/openclaw)
|
|
CONFIG_FILE=""
|
|
if [ -f "$FOXY_HOME/config.json" ]; then CONFIG_FILE="$FOXY_HOME/config.json"; fi
|
|
if [ -f "$FOXY_HOME/config.yaml" ]; then CONFIG_FILE="$FOXY_HOME/config.yaml"; fi
|
|
|
|
if [ -n "$CONFIG_FILE" ]; then
|
|
echo "🔧 Patching OpenClaw config paths for container environment..."
|
|
# Replace any /home/openclaw with /home/foxy in the config file
|
|
sed -i 's/\/home\/openclaw/\/home\/foxy/g' "$CONFIG_FILE"
|
|
echo "✅ Paths updated to /home/foxy in $CONFIG_FILE"
|
|
fi
|
|
|
|
# --- GATEWAY STARTUP ---
|
|
if [ "$OPENCLAW_TYPE" = "standalone" ]; then
|
|
echo "🔧 OPENCLAW_TYPE is standalone. Starting internal Gateway..."
|
|
|
|
# Initialize default config if none found
|
|
if [ -z "$CONFIG_FILE" ]; then
|
|
echo "📦 Initializing default config..."
|
|
mkdir -p "$FOXY_HOME/workspace" "$FOXY_HOME/agents"
|
|
cat <<EOF > "$FOXY_HOME/config.json"
|
|
{
|
|
"theme": "dark",
|
|
"logLevel": "info",
|
|
"gatewayPort": 18789,
|
|
"gatewayHost": "0.0.0.0",
|
|
"workspaceDir": "$FOXY_HOME/workspace",
|
|
"agentsDir": "$FOXY_HOME/agents"
|
|
}
|
|
EOF
|
|
fi
|
|
|
|
echo "🚀 Starting OpenClaw Gateway..."
|
|
# We use 'gateway start' but ensure it binds to all interfaces
|
|
# We also use --daemon=false if possible, or standard nohup
|
|
nohup openclaw gateway start --host 0.0.0.0 > "$FOXY_HOME/logs/gateway.log" 2>&1 &
|
|
|
|
sleep 3
|
|
if pgrep -f "openclaw" > /dev/null; then
|
|
echo "✅ OpenClaw Gateway is UP."
|
|
else
|
|
echo "❌ Gateway failed to start. Checking logs..."
|
|
cat "$FOXY_HOME/logs/gateway.log"
|
|
fi
|
|
else
|
|
echo "🔗 OPENCLAW_TYPE is shared. Host gateway expected."
|
|
fi
|
|
|
|
echo "🚀 Starting Uvicorn API Server..."
|
|
exec python -m uvicorn app.main:app --host 0.0.0.0 --port 7000
|