#!/usr/bin/env bash
set -euo pipefail
URL="https://sber911-ift-iam.delta.sbrf.ru/"
OUT_FILE="dev_server/proxyConstants.mjs"
echo "Paste cookie, then press Ctrl+D"
COOKIE_VALUE=$(cat)
echo
echo "========== DEBUG =========="
echo "Length in bash : ${#COOKIE_VALUE}"
# Сколько байт реально хранит bash
printf "%s" "$COOKIE_VALUE" > /tmp/cookie.raw
echo "Bytes : $(wc -c < /tmp/cookie.raw)"
echo "Lines : $(wc -l < /tmp/cookie.raw)"
echo "MD5 : $(md5sum /tmp/cookie.raw | cut -d' ' -f1)"
echo "First 50 chars:"
head -c 50 /tmp/cookie.raw
echo
echo "Last 50 chars:"
tail -c 50 /tmp/cookie.raw
echo
echo "==========================="
echo
python3 <<'PY'
import json
from pathlib import Path
cookie = Path("/tmp/cookie.raw").read_text(encoding="utf-8")
Path("dev_server/proxyConstants.mjs").write_text(
"export const URL = 'https://sber911-ift-iam.delta.sbrf.ru/'\n"
f"export const cookie = {json.dumps(cookie)}\n",
encoding="utf-8"
)
PY
echo
echo "Generated file:"
echo "Bytes: $(wc -c < "$OUT_FILE")"
echo "MD5 : $(md5sum "$OUT_FILE" | cut -d' ' -f1)"
echo
echo "Last 120 chars of generated file:"
tail -c 120 "$OUT_FILE"
echo
node dev_server/proxy.mjs &
npm run dev