#!/usr/bin/env bash # # Intune Manager - Start auf macOS (funktioniert auch unter Linux). # # Verwendung: # - Im Finder doppelklicken (Datei muss ausfuehrbar sein: chmod +x start-macos.command) # - oder im Terminal: ./start-macos.command # ./start-macos.command -Port 8090 # ./start-macos.command -NoBrowser # # Alle Argumente werden unveraendert an Start.ps1 durchgereicht. # set -euo pipefail # In das Verzeichnis dieses Scripts wechseln (= Repo-Root), egal von wo gestartet. cd "$(dirname "$0")" echo "==============================================" echo " Intune Manager - Start (macOS)" echo "==============================================" # 1) PowerShell 7 vorhanden? if ! command -v pwsh >/dev/null 2>&1; then echo "FEHLER: PowerShell 7 (pwsh) ist nicht installiert." echo " Installieren mit: brew install --cask powershell" exit 1 fi # 2) Graph-Auth-Modul vorhanden? Sonst einmalig installieren. if ! pwsh -NoProfile -Command "if (Get-Module -ListAvailable Microsoft.Graph.Authentication) { exit 0 } else { exit 1 }"; then echo "Installiere Microsoft.Graph.Authentication (einmalig, CurrentUser)..." pwsh -NoProfile -Command "Install-Module Microsoft.Graph.Authentication -Scope CurrentUser -Force" fi # 3) Port aus den Argumenten lesen (Default 8077) - nur fuer die Port-Freigabe unten. PORT=8077 args=("$@") for ((i=0; i<${#args[@]}; i++)); do if [[ "${args[$i]}" == "-Port" && $((i+1)) -lt ${#args[@]} ]]; then PORT="${args[$((i+1))]}" fi done # 4) Belegten Port freigeben (auf macOS gibt es keinen automatischen Instanz-Kill). if lsof -ti ":$PORT" >/dev/null 2>&1; then echo "Port $PORT ist belegt - beende alte Instanz..." lsof -ti ":$PORT" | xargs kill 2>/dev/null || true sleep 1 fi # 5) Server starten. Argumente 1:1 an Start.ps1 weitergeben. echo "Starte Server auf http://localhost:$PORT/ (Beenden mit Ctrl+C)" echo "" exec pwsh -NoProfile -File ./Start.ps1 "$@"