Last active
May 18, 2016 18:58
-
-
Save walbert947/d8e1dc15aaebfbe2a4c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Searches a Google Cloud DNS record set | |
# Author: William Albert (@walbert947) | |
# (NOTE: The program depends on the Google Cloud SDK.) | |
# | |
# | |
# The DNS zone to search | |
dns_zone='example-com' | |
show_help() { | |
cat << EOF | |
Usage: ${0##*/} [-h] [-z DNS_ZONE] SEARCH_TERM | |
Search a Google Cloud DNS record set for a particular term. Partial matches | |
are supported. If DNS_ZONE is not specified, a hard-coded default will be | |
used. | |
-h display this help and exit | |
-z DNS_ZONE Use DNS_ZONE as the zone to search | |
EOF | |
} | |
OPTIND=1 | |
while getopts "hz:" opt; do | |
case "${opt}" in | |
h) | |
show_help | |
exit 0 | |
;; | |
z) | |
dns_zone=$OPTARG | |
;; | |
\?) | |
show_help >&2 | |
exit 1 | |
;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
if [[ "$#" -ne 1 ]]; then | |
echo "${0##*/}: No search term specified" >&2 | |
echo "Try ${0##*/} -h for more information." | |
exit 1 | |
fi | |
gcloud dns record-sets list -z "${dns_zone}" | grep --color -F "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment