Download entrypoint.sh from xjackkx/g2: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/spaces/xjackkx/g2/resolve/main/entrypoint.sh
- Command line
-
hf download hf://spaces/xjackkx/g2/entrypoint.sh
-
curl -L -o entrypoint.sh https://huggingface.co/spaces/xjackkx/g2/resolve/main/entrypoint.sh
1.28 kB
| set -e | |
| PORT="${PORT:-7860}" | |
| HOST="${HOST:-0.0.0.0}" | |
| CONFIG_PATH="${GEMINI_WEB2API_CONFIG:-/app/config.json}" | |
| echo "Starting gemini-web2api (host=${HOST}, port=${PORT})..." | |
| # 1) config.json: CONFIG_JSON_B64 secret > existing mount > generate default | |
| if [ -n "${CONFIG_JSON_B64:-}" ]; then | |
| echo "${CONFIG_JSON_B64}" | base64 -d > "${CONFIG_PATH}" | |
| echo "config.json loaded from CONFIG_JSON_B64." | |
| elif [ -f "${CONFIG_PATH}" ]; then | |
| echo "config.json found at ${CONFIG_PATH}." | |
| else | |
| cat > "${CONFIG_PATH}" <<EOF | |
| { | |
| "host": "${HOST}", | |
| "port": ${PORT}, | |
| "cookie_file": null, | |
| "proxy": null, | |
| "api_keys": [] | |
| } | |
| EOF | |
| echo "Default config.json generated." | |
| fi | |
| # 2) Cookie from Space/Docker secret (plain text cookie file content) | |
| if [ -n "${GEMINI_COOKIE:-}" ]; then | |
| COOKIE_PATH="${COOKIE_FILE:-/tmp/cookies.txt}" | |
| printf '%s\n' "${GEMINI_COOKIE}" > "${COOKIE_PATH}" | |
| export GEMINI_COOKIE_FILE="${COOKIE_PATH}" | |
| echo "Cookie written to ${COOKIE_PATH}." | |
| elif [ -z "${GEMINI_COOKIE_FILE:-}" ]; then | |
| echo "Warning: no GEMINI_COOKIE / GEMINI_COOKIE_FILE; anonymous mode (limited)." | |
| fi | |
| # 3) Launch (env overrides + CLI port as final lock for HF 7860) | |
| exec python -m gemini_web2api --config "${CONFIG_PATH}" --port "${PORT}" | |