Start-Script für macOS (start-macos.command)

Bequemer Launcher für den Mac: prüft pwsh, installiert bei Bedarf einmalig
Microsoft.Graph.Authentication, gibt einen belegten Port frei (auf macOS kein
Auto-Kill) und startet Start.ps1; Argumente (-Port/-NoBrowser) werden
durchgereicht. .gitattributes erzwingt LF für *.sh/*.command, damit der Shebang
auf macOS nicht durch CRLF zerschossen wird.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-09-16 16:04:38 +02:00
co-authored by Claude Opus 4.8
parent 51c2f56dec
commit 2c20f25837
2 changed files with 58 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
#!/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 "$@"