add new vdns scripts, for sudo access
This commit is contained in:
parent
507835b779
commit
9938f8059a
29
bin/vdns-rr-del.sh
Executable file
29
bin/vdns-rr-del.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# pdns-tools
|
||||
# https://git.stack-source.com/msb/pdns-tools
|
||||
# Copyright (c) 2024 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# load include file
|
||||
source /usr/local/sbin/pdns.sh
|
||||
|
||||
help()
|
||||
{
|
||||
/usr/local/sbin/pdns-rr-del.sh -p $thisfilename -h
|
||||
}
|
||||
|
||||
pdns:getoptions "$@"
|
||||
|
||||
# check for zone
|
||||
if [[ -z $zone ]]; then
|
||||
echo "zone is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
zone_exists=$(/usr/local/bin/vdns-zone-ext.sh -z $zone)
|
||||
if [[ $zone_exists = "true" ]]; then
|
||||
/usr/local/sbin/pdns-rr-del.sh $@
|
||||
else
|
||||
echo Zone $zone not found.
|
||||
fi
|
29
bin/vdns-rr-rep.sh
Executable file
29
bin/vdns-rr-rep.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# pdns-tools
|
||||
# https://git.stack-source.com/msb/pdns-tools
|
||||
# Copyright (c) 2024 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# load include file
|
||||
source /usr/local/sbin/pdns.sh
|
||||
|
||||
help()
|
||||
{
|
||||
/usr/local/sbin/pdns-rr-rep.sh -p $thisfilename -h
|
||||
}
|
||||
|
||||
pdns:getoptions "$@"
|
||||
|
||||
# check for zone
|
||||
if [[ -z $zone ]]; then
|
||||
echo "zone is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
zone_exists=$(/usr/local/bin/vdns-zone-ext.sh -z $zone)
|
||||
if [[ $zone_exists = "true" ]]; then
|
||||
/usr/local/sbin/pdns-rr-rep.sh $@
|
||||
else
|
||||
echo Zone $zone not found.
|
||||
fi
|
35
bin/vdns-zone-add.sh
Executable file
35
bin/vdns-zone-add.sh
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# pdns-tools
|
||||
# https://git.stack-source.com/msb/pdns-tools
|
||||
# Copyright (c) 2024 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# load include file
|
||||
source /usr/local/sbin/pdns.sh
|
||||
|
||||
help()
|
||||
{
|
||||
echo "Add new zone to DNS"
|
||||
echo ""
|
||||
echo "usage: $thisfilename -z <zone> [-h]"
|
||||
echo ""
|
||||
echo " -h Print this help."
|
||||
echo " -z <zone> Zone (domain name) to add."
|
||||
}
|
||||
|
||||
pdns:getoptions "$@"
|
||||
|
||||
# check for zone
|
||||
if [[ -z $zone ]]; then
|
||||
echo "zone is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
zone_exists=$(/usr/local/sbin/pdns-zone-ext.sh -z $zone)
|
||||
if [[ $zone_exists = "true" ]]; then
|
||||
echo Zone $zone already exists.
|
||||
exit 1
|
||||
else
|
||||
/usr/local/bin/pdns-zone-add.sh -z $zone -w hostname=$hostname/$zone
|
||||
fi
|
29
bin/vdns-zone-del.sh
Executable file
29
bin/vdns-zone-del.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# pdns-tools
|
||||
# https://git.stack-source.com/msb/pdns-tools
|
||||
# Copyright (c) 2024 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# load include file
|
||||
source /usr/local/sbin/pdns.sh
|
||||
|
||||
help()
|
||||
{
|
||||
/usr/local/sbin/pdns-zone-del.sh -p $thisfilename -h
|
||||
}
|
||||
|
||||
pdns:getoptions "$@"
|
||||
|
||||
# check for zone
|
||||
if [[ -z $zone ]]; then
|
||||
echo "zone is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
zone_exists=$(/usr/local/bin/vdns-zone-ext.sh -z $zone)
|
||||
if [[ $zone_exists = "true" ]]; then
|
||||
/usr/local/sbin/pdns-zone-del.sh $@
|
||||
else
|
||||
echo Zone $zone not found.
|
||||
fi
|
29
bin/vdns-zone-exp.sh
Executable file
29
bin/vdns-zone-exp.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# pdns-tools
|
||||
# https://git.stack-source.com/msb/pdns-tools
|
||||
# Copyright (c) 2024 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# load include file
|
||||
source /usr/local/sbin/pdns.sh
|
||||
|
||||
help()
|
||||
{
|
||||
/usr/local/sbin/pdns-zone-exp.sh -p $thisfilename -h
|
||||
}
|
||||
|
||||
pdns:getoptions "$@"
|
||||
|
||||
# check for zone
|
||||
if [[ -z $zone ]]; then
|
||||
echo "zone is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
zone_exists=$(/usr/local/bin/vdns-zone-ext.sh -z $zone)
|
||||
if [[ $zone_exists = "true" ]]; then
|
||||
/usr/local/sbin/pdns-zone-exp.sh $@
|
||||
else
|
||||
echo Zone $zone not found.
|
||||
fi
|
38
bin/vdns-zone-ext.sh
Executable file
38
bin/vdns-zone-ext.sh
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# pdns-tools
|
||||
# https://git.stack-source.com/msb/pdns-tools
|
||||
# Copyright (c) 2024 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# load include file
|
||||
source /usr/local/sbin/pdns.sh
|
||||
|
||||
help()
|
||||
{
|
||||
echo "Check if Zone exists (and is associated with this server)."
|
||||
echo ""
|
||||
echo "usage: $thisfilename -z <zone> [-h]"
|
||||
echo ""
|
||||
echo " -h Print this help."
|
||||
echo " -z <zone> Zone (domain name) check."
|
||||
}
|
||||
|
||||
pdns:getoptions "$@"
|
||||
|
||||
# check for zone
|
||||
if [[ -z $zone ]]; then
|
||||
echo "zone is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SEARCH=($(/usr/local/bin/vdns-zone-lst.sh -q $zone))
|
||||
if [[ ${#SEARCH[@]} = 1 ]]; then
|
||||
if [[ "${SEARCH[0]}" = $zone ]]; then
|
||||
echo true
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo false
|
||||
exit 1
|
50
bin/vdns-zone-lst.sh
Executable file
50
bin/vdns-zone-lst.sh
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# pdns-tools
|
||||
# https://git.stack-source.com/msb/pdns-tools
|
||||
# Copyright (c) 2024 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# load include file
|
||||
source /usr/local/sbin/pdns.sh
|
||||
|
||||
help()
|
||||
{
|
||||
echo "List Zones exists that are in DNS and associated with this server."
|
||||
echo ""
|
||||
echo "usage: $thisfilename [-q <query>] [-h]"
|
||||
echo ""
|
||||
echo " -h Print this help."
|
||||
echo " -q <query> Optional search term."
|
||||
echo " Can be a domain, or a partial string with * for wildcard."
|
||||
echo " If using wildcard put the query in single quotes. e.g.:"
|
||||
echo " $thisfilename (returns all domains)."
|
||||
echo " $thisfilename -q example.com (returns domain example.com, if found)."
|
||||
echo " $thisfilename -q '*example*' (returns any domain with example as part of the name)."
|
||||
}
|
||||
|
||||
pdns:getoptions "$@"
|
||||
|
||||
if [[ -z $query ]]; then
|
||||
query=*
|
||||
fi
|
||||
|
||||
SEARCH=($(/usr/local/sbin/pdns-search.sh -q hostname=$hostname/$query -c))
|
||||
|
||||
# check for header row output, this indicates one or more results were found
|
||||
if [[ "${SEARCH[0]}" = "content,name,object_type,type,zone,zone_id" ]]; then
|
||||
# remove header row
|
||||
SEARCH=("${SEARCH[@]:1}")
|
||||
# check each row to verify data and output zone (domain) if it validates
|
||||
for ROW in "${SEARCH[@]}"; do
|
||||
# turn row into array
|
||||
readarray -d , -t row_array < <(echo $ROW)
|
||||
# get zone, strip ending dot
|
||||
zone=$(sed 's/.$//' <<< "${row_array[4]}")
|
||||
# compare row to expected/valid result
|
||||
if [[ $ROW = "hostname=$hostname/$zone,$zone.,comment,SOA,$zone.,$zone." ]]; then
|
||||
# got a match
|
||||
echo $zone
|
||||
fi
|
||||
done
|
||||
fi
|
Loading…
Reference in New Issue
Block a user