add options for searcing, reorder opts
This commit is contained in:
parent
f1a246c8d4
commit
9f590234c9
64
bin/pdns.sh
64
bin/pdns.sh
|
@ -13,8 +13,10 @@ if [ "${EUID}" -ne 0 ]; then
|
|||
fi
|
||||
|
||||
# Load local config
|
||||
# Two variables, api_key & dns_domain, are only set in the local config
|
||||
# Any of the other constants below can be overriden in the local config
|
||||
# 'api_key' & 'dns_domain' must be set in the local config.
|
||||
# If 'account' is set in the local config it is set for all 'zone' & 'comment' PDNS entries.
|
||||
# 'account' can also be set/overridden on command line.
|
||||
# Any of the other constants below can be overriden in the local config.
|
||||
if [[ -f /usr/local/etc/pdns.conf ]]; then
|
||||
source /usr/local/etc/pdns.conf
|
||||
fi
|
||||
|
@ -139,25 +141,20 @@ function pdns::yesno() {
|
|||
|
||||
function pdns:getoptions () {
|
||||
local OPTIND
|
||||
while getopts "hbz:d:i:m:t:a:n:r:c:l:s:x" opt ; do
|
||||
while getopts "ha:bcd:e:i:l:m:n:o:q:r:s:t:w:xz:" opt ; do
|
||||
case "${opt}" in
|
||||
h ) # display help and exit
|
||||
help
|
||||
exit
|
||||
;;
|
||||
a ) # account
|
||||
account=${OPTARG}
|
||||
;;
|
||||
b ) # bare - create empty zone, do not any default records
|
||||
bare=true
|
||||
;;
|
||||
z ) # zone
|
||||
zone=${OPTARG,,}
|
||||
# pdns stores zone name without trailing dot, remove if found
|
||||
if [[ ${zone: -1} = '.' ]]; then
|
||||
zone=${zone::-1}
|
||||
fi
|
||||
if ! pdns::validate_domain $zone; then
|
||||
echo "ERROR: $zone is not a valid domain name."
|
||||
exit
|
||||
fi
|
||||
c ) # csv - output in csv format
|
||||
csv=true
|
||||
;;
|
||||
d ) # domain (alias of zone)
|
||||
zone=${OPTARG,,}
|
||||
|
@ -170,6 +167,9 @@ function pdns:getoptions () {
|
|||
exit
|
||||
fi
|
||||
;;
|
||||
e ) # max (integer) – Maximum number of entries to return
|
||||
max=${OPTARG}
|
||||
;;
|
||||
i ) # IP
|
||||
ip=${OPTARG}
|
||||
if ! pdns::validate_ip $ip; then
|
||||
|
@ -177,33 +177,47 @@ function pdns:getoptions () {
|
|||
exit
|
||||
fi
|
||||
;;
|
||||
l ) # ttl - Time To Live
|
||||
ttl=${OPTARG}
|
||||
;;
|
||||
m ) # master - IP of master if this is a slave zone
|
||||
master=${OPTARG}
|
||||
;;
|
||||
t ) # type
|
||||
type=${OPTARG^^}
|
||||
;;
|
||||
a ) # account
|
||||
account=${OPTARG}
|
||||
;;
|
||||
n ) # name - hostname for this record
|
||||
name=${OPTARG,,}
|
||||
;;
|
||||
o ) # object_type - Type of data to search for, one of 'all', 'zone', 'record', 'comment'
|
||||
object=${OPTARG,,}
|
||||
;;
|
||||
q ) # query - The string to search for
|
||||
query=${OPTARG}
|
||||
;;
|
||||
r ) # record data
|
||||
record=${OPTARG}
|
||||
;;
|
||||
c ) # comment - a note about the record
|
||||
comment=${OPTARG}
|
||||
;;
|
||||
l ) # ttl - Time To Live
|
||||
ttl=${OPTARG}
|
||||
;;
|
||||
s ) # status - disabled status, 0 for active 1 for inactive, default 0
|
||||
status=${OPTARG}
|
||||
;;
|
||||
t ) # type
|
||||
type=${OPTARG^^}
|
||||
;;
|
||||
w ) # comment - a note about the record
|
||||
comment=${OPTARG}
|
||||
;;
|
||||
x ) # eXecute - don't prompt for confirmation
|
||||
execute=true
|
||||
;;
|
||||
z ) # zone
|
||||
zone=${OPTARG,,}
|
||||
# pdns stores zone name without trailing dot, remove if found
|
||||
if [[ ${zone: -1} = '.' ]]; then
|
||||
zone=${zone::-1}
|
||||
fi
|
||||
if ! pdns::validate_domain $zone; then
|
||||
echo "ERROR: $zone is not a valid domain name."
|
||||
exit
|
||||
fi
|
||||
;;
|
||||
\? )
|
||||
echo "Invalid option: $OPTARG"
|
||||
exit 1
|
||||
|
|
Loading…
Reference in New Issue
Block a user