dotfiles/bin/flush-dns

37 lines
763 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
OS=$(uname -s)
REL=$(uname -r)
function sorry()
{
echo "Sorry. I do not know how to flush the DNS on this OS."
echo "Once you find out, edit $(readlink ${0})."
exit 1
}
case ${OS} in
Darwin) PROD_VER=$(sw_vers -productVersion)
case ${PROD_VER} in
10.10.3|\
10.10.2|\
10.10.1|\
10.10.0|\
10.10) sudo discoveryutil mdnsflushcache
;;
10.6.*|\
10.6) sudo dscacheutil -flushcache
;;
*) sudo killall -HUP mDNSResponder
;;
esac
;;
*) sorry
;;
esac
exit 0