# OSVauco · OPAX — VS Code Windows Startup # settings.json: "args": ["-NoExit","-File","G:\\Shared drives\\OS-VAUCO-DRIVE\\OSVauco\\scripts\\osv-startup.ps1"] $REPO = "G:\Shared drives\OS-VAUCO-DRIVE\OSVauco" $PING = "https://opax.vauco.no/ping" $LOG = "$REPO\docs\OSVAUCO_OPAX_SESSION_LOG.md" $W = 52 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 Set-Location $REPO Clear-Host # ---- SJEKKER (stille) ---------------------------------------- $gcOK = $false; $adcOK = $false; $opaxOK = $false; $gitOK = $false $gcAcc = "" $gitOut = git pull 2>&1 $gitOK = ($LASTEXITCODE -eq 0) try { $gcAcc = gcloud auth list --filter=status:ACTIVE --format="value(account)" 2>$null if ($gcAcc) { $gcOK = $true gcloud config set project propane-will-491900-m5 2>$null | Out-Null gcloud config set compute/region us-central1 2>$null | Out-Null } } catch {} try { $t = gcloud auth application-default print-access-token 2>$null if ($t) { $adcOK = $true } } catch {} try { $r = Invoke-RestMethod -Uri $PING -TimeoutSec 5 if ($r.status -eq 'ok') { $opaxOK = $true } } catch {} $allOK = $gitOK -and $opaxOK -and $gcOK # ---- STATUS-STRENGER (pre-computed) ------------------------- if ($gitOut -match 'Already') { $gitTxt = "✅ Git : up to date" } else { $gitTxt = "✅ Git : oppdatert" } if (-not $gitOK) { $gitTxt = "❌ Git : FEIL" } if ($gcOK) { $gcTxt = "✅ GCP : " + ($gcAcc -replace '@vauco.no','') } else { $gcTxt = "⚠ GCP : ikke logget inn" } if ($adcOK) { $adcTxt = "✅ ADC : OK" } else { $adcTxt = "⚠ ADC : gcloud auth application-default login" } if ($opaxOK) { $opaxTxt = "✅ OPAX : opax.vauco.no" } else { $opaxTxt = "❌ OPAX : nede - sjekk Cloud Run" } # ---- HJELPEFUNKSJONER --------------------------------------- function GlowBox($lines) { $seg = [math]::Floor($W / 3) Write-Host " " -NoNewline Write-Host ("█" * $seg) -NoNewline -ForegroundColor Magenta Write-Host ("█" * $seg) -NoNewline -ForegroundColor DarkGreen Write-Host ("█" * ($W - $seg * 2)) -ForegroundColor Green foreach ($line in $lines) { $pad = $W - 4 - $line.Length if ($pad -lt 0) { $line = $line.Substring(0, $W - 5) + "…"; $pad = 0 } Write-Host " " -NoNewline Write-Host "█" -NoNewline -ForegroundColor Magenta Write-Host (" " + $line + (" " * $pad) + " ") -NoNewline -ForegroundColor Green Write-Host "█" -ForegroundColor Green } Write-Host " " -NoNewline Write-Host ("█" * ($W - $seg * 2)) -NoNewline -ForegroundColor Green Write-Host ("█" * $seg) -NoNewline -ForegroundColor DarkGreen Write-Host ("█" * $seg) -ForegroundColor Magenta } function ThinBox($lines, $borderColor) { Write-Host " " -NoNewline; Write-Host ("─" * $W) -ForegroundColor $borderColor foreach ($line in $lines) { $col = if ($line -match "^✅") { 'Green' } elseif ($line -match "^❌") { 'Red' } elseif ($line -match "^⚠") { 'Yellow' } else { 'Gray' } Write-Host " " -NoNewline Write-Host "│" -NoNewline -ForegroundColor $borderColor Write-Host (" " + $line) -ForegroundColor $col } Write-Host " " -NoNewline; Write-Host ("─" * $W) -ForegroundColor $borderColor } # ---- TOPP GLOW-BOKS ----------------------------------------- Write-Host "" GlowBox @( "", " O S V A U C O · O P A X", " us-central1 · gemini-2.5-pro", " $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')", "" ) Write-Host "" # ---- NESTE OPPGAVE ------------------------------------------ Write-Host " ■ NESTE OPPGAVE" -ForegroundColor Magenta $nesteLines = @("Sjekk docs/VAUCO_OS_ROADMAP.md") if (Test-Path $LOG) { $m = [regex]::Match((Get-Content $LOG -Raw -Encoding UTF8), '(?s)## NESTE OPPGAVE\r?\n(.*?)(?=\r?\n## |$)') if ($m.Success) { $nesteLines = $m.Groups[1].Value.Trim() -split "`n" | Where-Object { $_.Trim() -and $_.Trim() -ne '---' } | Select-Object -First 2 | ForEach-Object { $_.Trim() } } } ThinBox $nesteLines Magenta Write-Host "" # ---- SISTE DOCS --------------------------------------------- Write-Host " ■ SISTE DOCS" -ForegroundColor Magenta $docLines = git -C $REPO log -3 --pretty=format:"%h %cd %s" --date=short -- docs 2>&1 | ForEach-Object { ($_ -replace '[^\x00-\x7F\u00e6\u00f8\u00e5\u00c6\u00d8\u00c5\u2014\u2013]+', '').Trim() } ThinBox $docLines DarkGreen Write-Host "" # ---- STATUS ------------------------------------------------- Write-Host " ■ STATUS" -ForegroundColor Magenta ThinBox @($gitTxt, $gcTxt, $adcTxt, $opaxTxt) Magenta Write-Host "" # ---- BUNN GLOW-BOKS ----------------------------------------- if ($allOK) { GlowBox @("", " ▶▶ ALL SYSTEMS GREEN ◀◀", "") } else { Write-Host " " -NoNewline Write-Host ("█" * $W) -ForegroundColor Yellow Write-Host " █ ⚠ PARTIAL — sjekk status over" -ForegroundColor Yellow Write-Host " " -NoNewline Write-Host ("█" * $W) -ForegroundColor Yellow } Write-Host "" # ---- CUSTOM PROMPT ------------------------------------------ function prompt { Write-Host " G:\Shared-drives\" -NoNewline -ForegroundColor Magenta Write-Host "OS" -NoNewline -ForegroundColor White Write-Host "Vauco" -NoNewline -ForegroundColor Green Write-Host " ❯" -NoNewline -ForegroundColor Green return " " }