boot/opax: fjern automatisk auth, ADC-refresh og git pull

This commit is contained in:
Chris Christiansen 2026-09-06 19:55:20 +00:00
parent d20aba5462
commit 96be923b55
2 changed files with 29 additions and 55 deletions

View File

@ -57,30 +57,24 @@ printf "${NC}${DIM} Vauco OS · Operasjonsplatform · %s${NC}\n" "$(date '+
printf "${DIM} ──────────────────────────────────────────────────────${NC}\n\n" printf "${DIM} ──────────────────────────────────────────────────────${NC}\n\n"
# ============================================================================= # =============================================================================
# 1. AUTH # 1. AUTH & CREDENTIALS
# ============================================================================= # =============================================================================
printf "${BOLD}${CYAN}[ AUTH ]${NC}\n" printf "${BOLD}${CYAN}[ AUTH & CREDENTIALS ]${NC}\n"
if ! gcloud auth print-access-token >/dev/null 2>&1; then
warn "gcloud auth utløpt — kjører login (no-browser)..." # Informativ gcloud CLI-status. Starter aldri login og stopper ikke boot.
gcloud auth login --no-launch-browser if gcloud auth print-access-token >/dev/null 2>&1; then
else
ACCT=$(gcloud auth list --filter=status:ACTIVE --format='value(account)' 2>/dev/null | head -1) ACCT=$(gcloud auth list --filter=status:ACTIVE --format='value(account)' 2>/dev/null | head -1)
ok "gcloud auth ($ACCT)" ok "gcloud CLI-bruker ($ACCT)"
else
warn "gcloud CLI ikke innlogget. Kjør 'gcloud auth login' for manuelle operasjoner."
fi fi
ADC_FILE="$HOME/.config/gcloud/.osvauco-adc-renewed" # Informativ ADC-status. Endrer aldri credentials eller miljøvariabler.
NEED_ADC=0 if [[ -n "${GOOGLE_APPLICATION_CREDENTIALS:-}" ]]; then
if ! gcloud auth application-default print-access-token >/dev/null 2>&1; then warn "GOOGLE_APPLICATION_CREDENTIALS er satt. Dette kan overstyre VM-ens standard credentials."
NEED_ADC=1 printf " ${DIM}Boot-scriptet endrer ikke denne. For å fjerne: unset GOOGLE_APPLICATION_CREDENTIALS${NC}\n"
elif [[ ! -f "$ADC_FILE" ]] || [[ $(($(date +%s) - $(stat -c %Y "$ADC_FILE" 2>/dev/null || echo 0))) -gt 28800 ]]; then
NEED_ADC=1
fi
if [[ $NEED_ADC -eq 1 ]]; then
warn "ADC utløpt eller >8t — fornyer..."
gcloud auth application-default login --no-launch-browser \
--scopes="https://www.googleapis.com/auth/cloud-platform" && touch "$ADC_FILE"
else else
ok "ADC OK" ok "ADC/runtime: GOOGLE_APPLICATION_CREDENTIALS ikke satt. VM metadata/ADC vil bli brukt."
fi fi
# ============================================================================= # =============================================================================
@ -97,55 +91,36 @@ fi
ok "region = $GOOGLE_CLOUD_LOCATION (LÅST)" ok "region = $GOOGLE_CLOUD_LOCATION (LÅST)"
# ============================================================================= # =============================================================================
# 3. REPO + GITHUB STATUS # 3. REPOSITORY STATUS
# ============================================================================= # =============================================================================
printf "${BOLD}${CYAN}[ REPO + GITHUB ]${NC}\n" printf "${BOLD}${CYAN}[ REPOSITORY STATUS ]${NC}\n"
if [[ -d "$OSVAUCO_DIR/.git" ]]; then if [[ -d "$OSVAUCO_DIR/.git" ]]; then
cd "$OSVAUCO_DIR" cd "$OSVAUCO_DIR"
BRANCH=$(git branch --show-current)
git fetch --quiet origin 2>/dev/null && ok "git fetch OK" || warn "git fetch feilet (offline?)"
# Pull BRANCH=$(git branch --show-current 2>/dev/null || true)
if git pull --ff-only origin "$BRANCH" >/dev/null 2>&1; then
ok "git pull OK (branch: $BRANCH)" if [[ -n "$BRANCH" ]]; then
ok "Aktiv branch: $BRANCH"
else else
warn "git pull ikke fast-forward — sjekk 'git status'" warn "Kunne ikke finne aktiv Git-branch"
fi fi
# Ahead/behind DIRTY=$(git status --porcelain 2>/dev/null | wc -l | tr -d ' ')
AHEAD=$(git rev-list --count "origin/$BRANCH..HEAD" 2>/dev/null || echo "?")
BEHIND=$(git rev-list --count "HEAD..origin/$BRANCH" 2>/dev/null || echo "?")
if [[ "$AHEAD" == "0" && "$BEHIND" == "0" ]]; then
ok "sync med origin/$BRANCH"
else
warn "ahead=$AHEAD behind=$BEHIND vs origin/$BRANCH"
fi
# Uncommitted
DIRTY=$(git status --porcelain | wc -l)
if [[ "$DIRTY" == "0" ]]; then if [[ "$DIRTY" == "0" ]]; then
ok "working tree clean" ok "Working tree: rent"
else else
warn "$DIRTY uncommitted endringer ('git status' for liste)" warn "Working tree: $DIRTY lokale endring(er) uten commit"
fi fi
# Last commit LAST_COMMIT=$(git log -1 --oneline 2>/dev/null || true)
LAST=$(git log -1 --format='%h %s (%cr)' 2>/dev/null)
printf " ${DIM}last:${NC} %s\n" "$LAST"
# gh CLI auth if [[ -n "$LAST_COMMIT" ]]; then
if command -v gh >/dev/null 2>&1; then printf " ${DIM}Siste lokale commit: ${LAST_COMMIT}${NC}\n"
if gh auth status >/dev/null 2>&1; then
GH_USER=$(gh api user --jq '.login' 2>/dev/null || echo "?")
ok "gh CLI auth ($GH_USER)"
OPEN_PR=$(gh pr list --head "$BRANCH" --json number,title --jq '.[0] | "PR #\(.number): \(.title)"' 2>/dev/null)
[[ -n "$OPEN_PR" ]] && printf " ${DIM}pr:${NC} %s\n" "$OPEN_PR"
else
warn "gh CLI ikke autentisert — kjør: gh auth login"
fi
else
warn "gh CLI ikke installert — installer: sudo apt install gh"
fi fi
printf " ${DIM}Remote-status kontrolleres ikke automatisk. Ved behov: git fetch origin && git status -sb${NC}\n"
else else
fail "Repo ikke funnet på $OSVAUCO_DIR" fail "Repo ikke funnet på $OSVAUCO_DIR"
fi fi

View File

@ -79,7 +79,6 @@ printf "${DIM} ─────────────────────
printf "${BOLD}${WHITE}Preflight${NC} printf "${BOLD}${WHITE}Preflight${NC}
" "
run_check "gcloud auth" "gcloud auth print-access-token" "Kjør: gcloud auth login --no-launch-browser" true || return 1 run_check "gcloud auth" "gcloud auth print-access-token" "Kjør: gcloud auth login --no-launch-browser" true || return 1
run_check "ADC (application-default)" "gcloud auth application-default print-access-token" "Kjør: gcloud auth application-default login" true || return 1
run_check "project = $GOOGLE_CLOUD_PROJECT" "[[ "$(gcloud config get-value project 2>/dev/null)" == "$GOOGLE_CLOUD_PROJECT" ]]" "Kjør: gcloud config set project $GOOGLE_CLOUD_PROJECT" false run_check "project = $GOOGLE_CLOUD_PROJECT" "[[ "$(gcloud config get-value project 2>/dev/null)" == "$GOOGLE_CLOUD_PROJECT" ]]" "Kjør: gcloud config set project $GOOGLE_CLOUD_PROJECT" false
run_check "HANDOFF.md finnes" "[[ -f '$HANDOFF' ]]" "Mangler: $HANDOFF" false run_check "HANDOFF.md finnes" "[[ -f '$HANDOFF' ]]" "Mangler: $HANDOFF" false
run_check "MASTERPLAN.md finnes" "[[ -f '$MASTERPLAN' ]]" "Mangler MASTERPLAN" false run_check "MASTERPLAN.md finnes" "[[ -f '$MASTERPLAN' ]]" "Mangler MASTERPLAN" false