#!/usr/bin/env bash # OSVauco startup — auth + Gemini bootstrap for OPAX-MCP work set -euo pipefail clear # Guard: stopp hvis gcloud auth er utløpt if ! gcloud auth print-access-token >/dev/null 2>&1; then echo "⚠️ gcloud auth utløpt — kjør: gcloud auth login --no-launch-browser" exit 1 fi cat << 'BANNER' ============================================================ O S V A U C O ============================================================ O S V A U C O O P E R A T O R H U B Prosjekt: propane-will-491900-m5 · Region: us-central1 ============================================================ BANNER echo echo "=== OSVauco Auth Setup ===" echo # Lås til riktig prosjekt og region gcloud config set project propane-will-491900-m5 >/dev/null 2>&1 || true gcloud config set compute/region us-central1 >/dev/null 2>&1 || true PROJECT=$(gcloud config get-value project 2>/dev/null) REGION=$(gcloud config get-value compute/region 2>/dev/null) ACCOUNT=$(gcloud auth list --filter=status:ACTIVE --format="value(account)" 2>/dev/null) echo " Project : ${PROJECT}" echo " Region : ${REGION}" echo " Account : ${ACCOUNT}" # Sjekk ADC (Application Default Credentials) ADC_OK=0 if gcloud auth application-default print-access-token >/dev/null 2>&1; then ADC_OK=1 fi echo if [ "$ADC_OK" -eq 1 ]; then echo " ADC : OK" else echo " ADC : MISSES TOKEN (kjør: gcloud auth application-default login)" fi # Sync til .env i prosjektet ENV_FILE="$HOME/OSVauco/.env" mkdir -p "$(dirname "$ENV_FILE")" touch "$ENV_FILE" grep -q '^GOOGLE_CLOUD_PROJECT=' "$ENV_FILE" || echo "GOOGLE_CLOUD_PROJECT=${PROJECT}" >> "$ENV_FILE" grep -q '^GOOGLE_CLOUD_LOCATION=' "$ENV_FILE" || echo "GOOGLE_CLOUD_LOCATION=${REGION}" >> "$ENV_FILE" echo " .env : oppdatert" echo echo "=== Auth complete ===" echo " Project : ${PROJECT}" echo " Region : ${REGION}" echo " Account : ${ACCOUNT}" echo read -r -p "[OSVauco] Starte Gemini-CLI nå med oppstartsrapport? (y/N): " ANSWER case "$ANSWER" in y|Y) echo echo "[OSVauco] Starter Gemini-CLI fra ~/OSVauco ..." echo "[OSVauco] Første melding som sendes inn er @.gemini/GEMINI.md" echo cd "$HOME/OSVauco" ( printf '@.gemini/GEMINI.md '; cat ) | gemini ;; *) echo echo "[OSVauco] OK, holder deg i vanlig shell. Kjør 'gemini' når du vil inn i TUI." ;; esac