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
|
fi
|
||||||
|
|
||||||
# Load local config
|
# Load local config
|
||||||
# Two variables, api_key & dns_domain, are only set in the local config
|
# 'api_key' & 'dns_domain' must be set in the local config.
|
||||||
# Any of the other constants below can be overriden 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
|
if [[ -f /usr/local/etc/pdns.conf ]]; then
|
||||||
source /usr/local/etc/pdns.conf
|
source /usr/local/etc/pdns.conf
|
||||||
fi
|
fi
|
||||||
|
@ -139,25 +141,20 @@ function pdns::yesno() {
|
||||||
|
|
||||||
function pdns:getoptions () {
|
function pdns:getoptions () {
|
||||||
local OPTIND
|
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
|
case "${opt}" in
|
||||||
h ) # display help and exit
|
h ) # display help and exit
|
||||||
help
|
help
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
a ) # account
|
||||||
|
account=${OPTARG}
|
||||||
|
;;
|
||||||
b ) # bare - create empty zone, do not any default records
|
b ) # bare - create empty zone, do not any default records
|
||||||
bare=true
|
bare=true
|
||||||
;;
|
;;
|
||||||
z ) # zone
|
c ) # csv - output in csv format
|
||||||
zone=${OPTARG,,}
|
csv=true
|
||||||
# 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
|
|
||||||
;;
|
;;
|
||||||
d ) # domain (alias of zone)
|
d ) # domain (alias of zone)
|
||||||
zone=${OPTARG,,}
|
zone=${OPTARG,,}
|
||||||
|
@ -170,6 +167,9 @@ function pdns:getoptions () {
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
e ) # max (integer) – Maximum number of entries to return
|
||||||
|
max=${OPTARG}
|
||||||
|
;;
|
||||||
i ) # IP
|
i ) # IP
|
||||||
ip=${OPTARG}
|
ip=${OPTARG}
|
||||||
if ! pdns::validate_ip $ip; then
|
if ! pdns::validate_ip $ip; then
|
||||||
|
@ -177,33 +177,47 @@ function pdns:getoptions () {
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
l ) # ttl - Time To Live
|
||||||
|
ttl=${OPTARG}
|
||||||
|
;;
|
||||||
m ) # master - IP of master if this is a slave zone
|
m ) # master - IP of master if this is a slave zone
|
||||||
master=${OPTARG}
|
master=${OPTARG}
|
||||||
;;
|
;;
|
||||||
t ) # type
|
|
||||||
type=${OPTARG^^}
|
|
||||||
;;
|
|
||||||
a ) # account
|
|
||||||
account=${OPTARG}
|
|
||||||
;;
|
|
||||||
n ) # name - hostname for this record
|
n ) # name - hostname for this record
|
||||||
name=${OPTARG,,}
|
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
|
r ) # record data
|
||||||
record=${OPTARG}
|
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
|
s ) # status - disabled status, 0 for active 1 for inactive, default 0
|
||||||
status=${OPTARG}
|
status=${OPTARG}
|
||||||
;;
|
;;
|
||||||
|
t ) # type
|
||||||
|
type=${OPTARG^^}
|
||||||
|
;;
|
||||||
|
w ) # comment - a note about the record
|
||||||
|
comment=${OPTARG}
|
||||||
|
;;
|
||||||
x ) # eXecute - don't prompt for confirmation
|
x ) # eXecute - don't prompt for confirmation
|
||||||
execute=true
|
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"
|
echo "Invalid option: $OPTARG"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user