File size: 1,717 Bytes
1caafb1 | 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #!/bin/bash
# Replace environment variables in config
envsubst < /app/config.template.yaml > /app/config.yaml
# Keep auth files on the persistent bucket mount.
AUTH_DIR="/data/auths"
mkdir -p "${AUTH_DIR}"
# Try to refresh CLI Proxy API from the latest GitHub release, but keep
# the bundled binary as a fallback so a transient GitHub failure does not
# block startup.
echo "=== Checking latest CLI Proxy API release ==="
TMP_DIR=$(mktemp -d)
LATEST_URL=$(curl -fsSL https://api.github.com/repos/router-for-me/CLIProxyAPI/releases/latest | jq -r '.assets[] | select(.name | test("linux.*amd64.*tar.gz")) | .browser_download_url' | head -n 1)
if [ -n "${LATEST_URL}" ] && [ "${LATEST_URL}" != "null" ]; then
if curl -fsSL "${LATEST_URL}" -o "${TMP_DIR}/cli-proxy-api.tar.gz" && tar -xzf "${TMP_DIR}/cli-proxy-api.tar.gz" -C "${TMP_DIR}"; then
LATEST_BIN=$(find "${TMP_DIR}" -name "cli-proxy-api" -type f | head -n 1)
if [ -n "${LATEST_BIN}" ]; then
install -m 755 "${LATEST_BIN}" /app/cli-proxy-api
echo "=== Updated CLI Proxy API from latest GitHub release ==="
else
echo "=== Latest release extracted without cli-proxy-api; using bundled binary ==="
fi
else
echo "=== Latest release download failed; using bundled binary ==="
fi
else
echo "=== Latest release lookup failed; using bundled binary ==="
fi
rm -rf "${TMP_DIR}"
echo "=== Downloading auth files from Supabase ==="
/app/supabase-sync.sh download || echo "Supabase download skipped"
echo "=== Auth files loaded: $(find "${AUTH_DIR}" -name "*.json" | wc -l) ==="
# Start file watcher in background (sync changes to Supabase)
/app/supabase-sync.sh watch &
exec /app/cli-proxy-api -config /app/config.yaml
|