#!/bin/bash # fix_pragma_dns.command # macOS temporary DNS fix for pragma.academic-ruc.cc set -e HOSTS="/etc/hosts" DOMAIN="pragma.academic-ruc.cc" CF_IP="104.21.2.164" if [ "$(id -u)" -ne 0 ]; then echo "" echo "=== pragma DNS temporary fix ===" echo "Need administrator permission. Enter your Mac login password:" echo "" sudo "$0" exit $? fi echo "" echo "Domain: $DOMAIN" echo "Cloudflare IP: $CF_IP" echo "This script adds a temporary hosts entry and flushes DNS cache." echo "" if grep -q "$DOMAIN" "$HOSTS"; then echo "Existing hosts entry:" grep "$DOMAIN" "$HOSTS" echo "" echo "No changes made. Remove the old entry manually if it is outdated." else printf "\n# Cloudflare pragma - temporary DNS fix\n%s %s\n" "$CF_IP" "$DOMAIN" >> "$HOSTS" echo "Added: $CF_IP $DOMAIN" fi echo "" echo "Flushing DNS cache..." dscacheutil -flushcache || true killall -HUP mDNSResponder 2>/dev/null || true echo "Done. Restart your browser, Claude Code, Codex CLI, or Cherry Studio." echo "" echo "Press any key to close..." read -r -n 1