#!/usr/bin/env bash set -euo pipefail boot_raw="$(sysctl -n kern.boottime)" boot_epoch="$(printf '%s\n' "$boot_raw" | sed -E 's/^\{ sec = ([0-9]+),.*/\1/')" if [[ ! "$boot_epoch" =~ ^[0-9]+$ ]]; then echo "BLOCKER darwin_boot_epoch_unavailable" exit 65 fi now_epoch="$(date +%s)" uptime_seconds=$((now_epoch - boot_epoch)) if (( uptime_seconds < 0 )); then echo "BLOCKER darwin_uptime_invalid" exit 65 fi uid="$(id -u)" launch_label="com.momo.ollama111-allow-proxy" if launchctl print "gui/${uid}/${launch_label}" >/dev/null 2>&1; then startup_enabled="enabled" else startup_enabled="unknown" fi if curl --max-time 2 -fsS http://127.0.0.1:11434/api/tags >/dev/null 2>&1; then startup_active="active" else startup_active="inactive" fi printf 'boot_id=darwin_%s uptime_seconds=%s systemd_state=darwin_ssh startup_enabled=%s startup_active=%s\n' \ "$boot_epoch" "$uptime_seconds" "$startup_enabled" "$startup_active"