#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="${ROOT_DIR:-${SCRIPT_DIR}}" PROVIDER_DIR="${ROOT_DIR}/universal_rebuild" SERVICES_FILE="${SERVICES_FILE:-${ROOT_DIR}/devops/config/services_list.txt}" TOKEN_FILE="${TOKEN_FILE:-}" NUBES_API_TOKEN="${NUBES_API_TOKEN:-}" if [[ -z "$NUBES_API_TOKEN" ]]; then if [[ -z "$TOKEN_FILE" ]]; then TOKEN_FILE=$(ls -t /home/naeel/terra/*.token 2>/dev/null | head -n 1 || true) fi if [[ -n "$TOKEN_FILE" && -f "$TOKEN_FILE" ]]; then NUBES_API_TOKEN=$(cat "$TOKEN_FILE") fi fi if [[ -z "$NUBES_API_TOKEN" ]]; then echo "Error: NUBES_API_TOKEN or TOKEN_FILE is required" >&2 exit 2 fi if [[ ! -f "$SERVICES_FILE" ]]; then echo "Error: services file not found: $SERVICES_FILE" >&2 exit 2 fi API_ENDPOINT="${NUBES_API_ENDPOINT:-https://deck-api.ngcloud.ru/api/v1/index.cfm}" while IFS= read -r sid; do sid="${sid//[$'\t'\r' ']}" if [[ -z "$sid" ]]; then continue fi if [[ "$sid" == \#* ]]; then continue fi svc_name=$(python3 - <