dotfiles/bin/flush-dns

34 lines
693 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
shopt -s extglob
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?(.[0-3])) sudo discoveryutil mdnsflushcache
;;
10.6?(.*)) sudo dscacheutil -flushcache
;;
*) sudo killall -HUP mDNSResponder
;;
esac
;;
*) sorry
;;
esac
exit 0