#!/usr/bin/env bash # OSVauco startup — auth + Gemini bootstrap for OPAX-MCP work set -euo pipefail GREEN="$(tput setaf 2 || true)" RED="$(tput setaf 1 || true)" YELLOW="$(tput setaf 3 || true)" RESET="$(tput sgr0 || true)" clear # Guard: stopp hvis gcloud auth er utløpt if ! gcloud auth print-access-token >/dev/null 2>&1; then echo "${RED}⚠️ gcloud auth utløpt — kjør: gcloud auth login --no-launch-browser${RESET}" 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 : ${GREEN}OK${RESET}" else echo " ADC : ${YELLOW}MISSES TOKEN${RESET} (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 : ${GREEN}oppdatert${RESET}" echo echo "=== Auth status ===" echo " Project : ${PROJECT}" echo " Region : ${REGION}" echo " Account : ${ACCOUNT}" if [ "$ADC_OK" -eq 1 ]; then echo " Status : ${GREEN}GRØNN${RESET} (gcloud + ADC på plass)" else echo " Status : ${YELLOW}GUL${RESET} (gcloud OK, men ADC mangler)" fi 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