Files
EventHubAiRouter/scripts/fetch-vless-subscription.sh
T
aleksey a2d238d92e
CI / build-gateway (push) Failing after 16s
CI / sync-config (push) Failing after 0s
feat(agent): hierarchical executor with path resolve, runtime probe, quiet UI
Make Zed Agent closer to Cursor: deterministic DevOps path index, live Traefik
port probe before blind edits, stop-after-edit, and quieter Russian progress.
2026-08-13 11:41:27 +03:00

42 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Fetch vless.conf from Happ/mireon subscription (JSON or plain vless:// lines).
# Env: VLESS_SUB_URL, VLESS_UA, VLESS_HWID (Happ → Settings / app id)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
if [[ -f "${ROOT}/.env" ]]; then
set -a
# shellcheck disable=SC1091
source "${ROOT}/.env"
set +a
fi
SUB_URL="${VLESS_SUB_URL:?set VLESS_SUB_URL}"
OUT="${1:-${ROOT}/vless/vless.conf}"
UA="${VLESS_UA:-Happ/3.3.6/Windows/2607171516600}"
HWID="${VLESS_HWID:-}"
TMP="$(mktemp)"
trap 'rm -f "${TMP}"' EXIT
CURL=(curl -fsSL -A "$UA")
[[ -n "$HWID" ]] && CURL+=(-H "x-hwid: ${HWID}")
"${CURL[@]}" "$SUB_URL" | tr -d '\n\r' | base64 -d >"${TMP}" 2>/dev/null || "${CURL[@]}" "$SUB_URL" >"${TMP}"
pick="$(grep -E '^vless://' "${TMP}" | grep -v '@0\.0\.0\.0:1' | head -1 || true)"
if [[ -z "$pick" ]]; then
pick="$(python3 "${SCRIPT_DIR}/vless-from-subscription-json.py" "${TMP}")" || true
fi
if [[ -z "$pick" ]]; then
echo "fetch-vless-subscription: no valid vless URI" >&2
head -c 400 "${TMP}" >&2
exit 1
fi
mkdir -p "$(dirname "$OUT")"
printf '%s\n' "$pick" >"$OUT"
chmod 600 "$OUT"
echo "Wrote $(wc -c <"$OUT") bytes -> $OUT"