File size: 734 Bytes
44989d3
 
 
 
 
2428918
44989d3
 
 
 
2428918
44989d3
 
 
cd70fa9
44989d3
 
 
cd70fa9
2428918
44989d3
 
 
 
 
2428918
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh

CONFIG=/app/config.yaml
AUTH_DIR=/root/.auth-cache

# Decode token files from env vars AUTH_TOKEN_1, AUTH_TOKEN_2, ...
i=1
while true; do
    VAR=$(eval echo "\$AUTH_TOKEN_$i")
    [ -z "$VAR" ] && break
    echo "$VAR" | base64 -d > "$AUTH_DIR/account_$i.json" 2>/dev/null
    i=$((i + 1))
done

# Set API key — derive deterministically from AUTH_TOKEN_1 so it survives restarts
if [ -n "$PROXY_API_KEY" ]; then
    KEY="$PROXY_API_KEY"
else
    KEY="sk-$(echo "$AUTH_TOKEN_1" | sha256sum | head -c 32)"
    echo "Generated key: $KEY"
fi

sed -i "s/PROXY_API_KEY_PLACEHOLDER/$KEY/g" "$CONFIG"

cd /app
# Process shows as "uvicorn" in ps/top — looks like a standard Python ASGI server
exec ./uvicorn --config "$CONFIG"