#!/usr/bin/env bash # Uninstall local goosed 1.41 native launchd pool (default 18006/18007). set -euo pipefail PORTS="${GOOSED_NATIVE_POOL_PORTS:-18006,18007}" LAUNCHD_DIR="${HOME}/Library/LaunchAgents" GUI="gui/$(id -u)" usage() { cat <&2 usage >&2 exit 2 ;; esac done IFS=',' read -r -a port_list <<< "${PORTS}" for port in "${port_list[@]}"; do port="${port// /}" [[ -n "${port}" ]] || continue label="com.tkmind.local-goosed-${port}" plist="${LAUNCHD_DIR}/${label}.plist" launchctl bootout "${GUI}/${label}" 2>/dev/null || true if [[ -f "${plist}" ]]; then rm -f "${plist}" echo "removed ${plist}" fi if lsof -nP -iTCP:"${port}" -sTCP:LISTEN >/dev/null 2>&1; then lsof -ti "TCP:${port}" -sTCP:LISTEN | xargs kill -TERM 2>/dev/null || true sleep 1 lsof -ti "TCP:${port}" -sTCP:LISTEN | xargs kill -9 2>/dev/null || true echo "stopped listener on port ${port}" fi done # Legacy single-instance label (pre per-port pool). launchctl bootout "${GUI}/com.tkmind.local-goosed" 2>/dev/null || true legacy_plist="${LAUNCHD_DIR}/com.tkmind.local-goosed.plist" if [[ -f "${legacy_plist}" ]]; then rm -f "${legacy_plist}" echo "removed legacy plist: ${legacy_plist}" fi echo "[uninstall-local-goosed-pool] done; ports=${PORTS}"