#!/usr/bin/env bash # uninstall-macos.sh — remove ahfail from macOS (manual/script install) # For Homebrew installs: brew uninstall ahfail, then run this to clean up PAM. set -euo pipefail INSTALL_DIR="/usr/local/lib/ahfail" BOLD=$(tput bold 2>/dev/null || true) RESET=$(tput sgr0 2>/dev/null || true) step() { echo "${BOLD}==> $*${RESET}"; } [[ "$(uname)" == "Darwin" ]] || { echo "This script is for macOS only." >&2; exit 1; } # ── 1. Remove PAM config line ───────────────────────────────────────────────── step "Removing ahfail from PAM configuration..." removed_pam=0 for pam_file in /etc/pam.d/screensaverui /etc/pam.d/screensaver; do if [[ -f "$pam_file" ]] && grep -q "ahfail" "$pam_file"; then echo " Patching ${pam_file}..." sudo sed -i '' '/ahfail/d' "$pam_file" removed_pam=1 fi done [[ $removed_pam -eq 0 ]] && echo " No ahfail PAM entries found." # ── 2. Remove binaries ──────────────────────────────────────────────────────── step "Removing binaries..." if [[ -d "$INSTALL_DIR" ]]; then sudo rm -rf "$INSTALL_DIR" echo " Removed ${INSTALL_DIR}." else echo " ${INSTALL_DIR} not found — skipping." fi echo "" echo "${BOLD}Done.${RESET}"