Catalyst / admin/AirportCyberSimulator 14.8 GB / 57.8 GB 40.0 GB free
Help Sign in

admin / AirportCyberSimulator

public

Airport Cyber Attack Simulation Application

Code Issues Pull requests Pipelines Packages Security Insights Wiki Settings
AirportCyberSimulator / airport-cyber-sim / sim.ps1 3021 B · main
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
<#
.SYNOPSIS
  Convenience wrapper around 'docker compose' for the Airport Cyber Resilience Simulator.

.DESCRIPTION
  Run from the project root. Requires Docker Desktop to be installed and running.

.EXAMPLE
  .\sim.ps1 up          # build (if needed) and start in the background
  .\sim.ps1 down        # stop and remove containers
  .\sim.ps1 logs        # tail service logs
  .\sim.ps1 rebuild     # clean no-cache rebuild, then start
  .\sim.ps1 status      # show container + health state
  .\sim.ps1 open        # open the kiosk in the default browser
#>

[CmdletBinding()]
param(
    [Parameter(Position = 0)]
    [ValidateSet('up', 'down', 'logs', 'rebuild', 'restart', 'status', 'shell', 'open', 'clean', 'help')]
    [string]$Command = 'help'
)

$ErrorActionPreference = 'Stop'
$Service = 'airport-cyber-sim'
$Url = 'http://localhost:8000'

# Always operate from the directory this script lives in (the project root).
Set-Location -Path $PSScriptRoot

function Assert-Docker {
    if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
        Write-Host "Docker is not on PATH. Install Docker Desktop for Windows and ensure it is running." -ForegroundColor Red
        exit 1
    }
    docker info *> $null
    if (-not $?) {
        Write-Host "Docker Desktop does not appear to be running. Start it and try again." -ForegroundColor Red
        exit 1
    }
}

switch ($Command) {
    'up' {
        Assert-Docker
        docker compose up --build -d
        Write-Host "Airport Cyber Resilience Simulator running at $Url" -ForegroundColor Green
    }
    'down' {
        Assert-Docker
        docker compose down
    }
    'logs' {
        Assert-Docker
        docker compose logs -f $Service
    }
    'rebuild' {
        Assert-Docker
        docker compose build --no-cache
        docker compose up -d
        Write-Host "Rebuilt and running at $Url" -ForegroundColor Green
    }
    'restart' {
        Assert-Docker
        docker compose restart $Service
    }
    'status' {
        Assert-Docker
        docker compose ps
        $health = docker inspect --format '{{.State.Health.Status}}' $Service 2>$null
        if ($health) { Write-Host "Health: $health" -ForegroundColor Cyan }
    }
    'shell' {
        Assert-Docker
        docker compose exec $Service /bin/bash
    }
    'open' {
        Start-Process $Url
    }
    'clean' {
        Assert-Docker
        docker compose down --rmi local --remove-orphans
    }
    default {
        Write-Host @"
Airport Cyber Resilience Simulator - Docker helper

Usage: .\sim.ps1 <command>

  up        Build (if needed) and start in the background
  down      Stop and remove containers
  logs      Tail service logs
  rebuild   Clean no-cache rebuild, then start
  restart   Restart the service
  status    Show container status and health
  shell     Open a shell inside the running container
  open      Open the kiosk ($Url) in the default browser
  clean     Stop and remove containers + local image
"@ -ForegroundColor Gray
    }
}